libfchat 1.8 → 2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/libfchat/fchat.rb +12 -12
- data/lib/libfchat/version.rb +1 -1
- data/lib/libfchat/webapi.rb +123 -10
- metadata +23 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b4088d994319f517d0b3a0e1318d01b55f9e170a
|
4
|
+
data.tar.gz: 63efbbaf06c0ec58a11037e6c4193030398af55c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dac120724c1989743ddea6e27e18e1cc9179625cc2769f6f9ac90ca52a45cc8c61c2b8d5f40b4fd5ef347bdf61f7b6cc79a563d1403880206552c803ae5e2815
|
7
|
+
data.tar.gz: f7e6929005dbd654761250182e9678f7dbf2ac28fc61b87beab9992fab5fcaf9015b7f602da6786638ad3e29711c6a5df1d4e768123cd588dd9796b8e3df3767
|
data/lib/libfchat/fchat.rb
CHANGED
@@ -14,7 +14,7 @@ module Libfchat
|
|
14
14
|
require 'libfchat/version'
|
15
15
|
require 'libfchat/webapi'
|
16
16
|
require 'pp'
|
17
|
-
|
17
|
+
|
18
18
|
class Fchat
|
19
19
|
attr_reader :ticket
|
20
20
|
attr_reader :websocket
|
@@ -22,7 +22,7 @@ module Libfchat
|
|
22
22
|
attr_reader :version
|
23
23
|
attr_reader :clientname
|
24
24
|
attr_reader :me
|
25
|
-
|
25
|
+
|
26
26
|
attr_reader :chat_max
|
27
27
|
attr_reader :priv_max
|
28
28
|
attr_reader :lfrp_max
|
@@ -38,7 +38,7 @@ module Libfchat
|
|
38
38
|
attr_accessor :logger
|
39
39
|
|
40
40
|
##
|
41
|
-
# Initialize the object with the name and version.
|
41
|
+
# Initialize the object with the name and version.
|
42
42
|
# Default to just identifying as the library
|
43
43
|
|
44
44
|
def initialize(clientname="libfchat-ruby by Jippen Faddoul ( http://github.com/jippen/libfchat-ruby )",version=Libfchat::VERSION, level=Logger::DEBUG)
|
@@ -86,7 +86,7 @@ module Libfchat
|
|
86
86
|
|
87
87
|
def login(server,account,password,character,timeout=30)
|
88
88
|
webapi = Libfchat::WebAPI.new
|
89
|
-
@ticket = webapi.
|
89
|
+
@ticket = webapi.getApiTicket(account, password)
|
90
90
|
@me = character
|
91
91
|
|
92
92
|
EM.run {
|
@@ -123,7 +123,7 @@ module Libfchat
|
|
123
123
|
# ====================================================== #
|
124
124
|
# Always respond to these #
|
125
125
|
# ====================================================== #
|
126
|
-
|
126
|
+
|
127
127
|
##
|
128
128
|
# Respond to keepalive ping messages
|
129
129
|
def got_PIN(message)
|
@@ -155,7 +155,7 @@ module Libfchat
|
|
155
155
|
raise "ERROR: Do not know how to handle VAR #{message}"
|
156
156
|
end
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
##
|
160
160
|
# Store list of ops
|
161
161
|
def got_ADL(message)
|
@@ -195,7 +195,7 @@ module Libfchat
|
|
195
195
|
'message' => ""
|
196
196
|
}
|
197
197
|
end
|
198
|
-
|
198
|
+
|
199
199
|
##
|
200
200
|
# Handle user changing status
|
201
201
|
def got_STA(message)
|
@@ -205,7 +205,7 @@ module Libfchat
|
|
205
205
|
'message' => message['statusmsg']
|
206
206
|
}
|
207
207
|
end
|
208
|
-
|
208
|
+
|
209
209
|
##
|
210
210
|
# Handle user logging off
|
211
211
|
def got_FLN(message)
|
@@ -214,7 +214,7 @@ module Libfchat
|
|
214
214
|
room['characters'].delete(message['character'])
|
215
215
|
end
|
216
216
|
end
|
217
|
-
|
217
|
+
|
218
218
|
##
|
219
219
|
# Store data about newly joined chatroom
|
220
220
|
def got_JCH(message)
|
@@ -271,7 +271,7 @@ module Libfchat
|
|
271
271
|
# ====================================================== #
|
272
272
|
|
273
273
|
##
|
274
|
-
# Performs an account ban against a characters account.
|
274
|
+
# Performs an account ban against a characters account.
|
275
275
|
#
|
276
276
|
# *This command requires chat op or higher.*
|
277
277
|
def ACB(character)
|
@@ -332,7 +332,7 @@ module Libfchat
|
|
332
332
|
end
|
333
333
|
|
334
334
|
##
|
335
|
-
# This command is used by an admin or channel owner to set a new
|
335
|
+
# This command is used by an admin or channel owner to set a new
|
336
336
|
# channel description.
|
337
337
|
#
|
338
338
|
# *This command requires channel op or higher.*
|
@@ -533,7 +533,7 @@ module Libfchat
|
|
533
533
|
end
|
534
534
|
|
535
535
|
##
|
536
|
-
# Advertises the first open private channel owned by the client
|
536
|
+
# Advertises the first open private channel owned by the client
|
537
537
|
# in the given channel
|
538
538
|
def RAN(channel)
|
539
539
|
json = {:channel => channel }
|
data/lib/libfchat/version.rb
CHANGED
@@ -2,5 +2,5 @@ module Libfchat
|
|
2
2
|
# We're doing this because we might write tests that deal
|
3
3
|
# with other versions of Libfchat and we are unsure how to
|
4
4
|
# handle this better.
|
5
|
-
VERSION = "
|
5
|
+
VERSION = "2.0" unless defined?(::Libfchat::VERSION)
|
6
6
|
end
|
data/lib/libfchat/webapi.rb
CHANGED
@@ -4,26 +4,139 @@ module Libfchat
|
|
4
4
|
rescue LoadError
|
5
5
|
#I don't actually NEED rubygems, unless on 1.8
|
6
6
|
end
|
7
|
-
require 'net/
|
7
|
+
require 'net/https'
|
8
8
|
require 'multi_json'
|
9
|
-
|
9
|
+
|
10
10
|
class WebAPI
|
11
11
|
attr_reader :ticket
|
12
|
+
attr_reader :baseurl
|
12
13
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
'account' => account,
|
17
|
-
'password' => password)
|
14
|
+
def initialize(baseurl="https://www.f-list.net")
|
15
|
+
@baseurl = baseurl
|
16
|
+
end
|
18
17
|
|
18
|
+
def post(endpoint, params)
|
19
|
+
uri = URI("#{@baseurl}#{endpoint}")
|
20
|
+
if @ticket
|
21
|
+
params['ticket'] = @ticket
|
22
|
+
end
|
23
|
+
res = Net::HTTP.post_form(uri, params)
|
19
24
|
json = MultiJson.load(res.body)
|
20
|
-
if json['
|
21
|
-
|
22
|
-
|
25
|
+
if json['error'] != ""
|
26
|
+
raise json['error']
|
27
|
+
end
|
28
|
+
return json
|
29
|
+
end
|
30
|
+
|
31
|
+
def get(endpoint)
|
32
|
+
uri = URI(@baseurl)
|
33
|
+
res = Net::HTTP.get(uri)
|
34
|
+
json = MultiJson.load(res.body)
|
35
|
+
if json['error'] != ""
|
23
36
|
raise json['error']
|
24
37
|
end
|
25
38
|
return json
|
26
39
|
end
|
27
40
|
|
41
|
+
def get_ticket(account, password)
|
42
|
+
# Deprecated
|
43
|
+
return self.getApiTicket(account, password)
|
44
|
+
end
|
45
|
+
|
46
|
+
def getApiTicket(account, password)
|
47
|
+
json = self.post("/json/getApiTicket.php",
|
48
|
+
'account' => account,
|
49
|
+
'password' => password)
|
50
|
+
|
51
|
+
if json['ticket']
|
52
|
+
@ticket = json['ticket']
|
53
|
+
return json
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Bookmarks
|
58
|
+
def bookmark_add(name)
|
59
|
+
return self.post("/json/api/bookmark-add.php",
|
60
|
+
'name' => name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bookmark_list()
|
64
|
+
return self.get("/json/api/bookmark-list.php")
|
65
|
+
end
|
66
|
+
|
67
|
+
def bookmark_remove(name)
|
68
|
+
return self.post("/json/api/bookmark-remove.php",
|
69
|
+
'name' => name)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Character data
|
73
|
+
def character_data(name)
|
74
|
+
return self.post("/json/api/character-data.php",
|
75
|
+
'name' => name)
|
76
|
+
end
|
77
|
+
|
78
|
+
def character_list()
|
79
|
+
return self.get("/json/api/character-list.php")
|
80
|
+
end
|
81
|
+
|
82
|
+
# Misc data
|
83
|
+
def group_list()
|
84
|
+
return self.get("/json/api/group-list.php")
|
85
|
+
end
|
86
|
+
|
87
|
+
def ignore_list()
|
88
|
+
return self.get("/json/api/ignore-list.php")
|
89
|
+
end
|
90
|
+
|
91
|
+
def info_list()
|
92
|
+
return self.get("/json/api/info-list.php")
|
93
|
+
end
|
94
|
+
|
95
|
+
def kink_list()
|
96
|
+
return self.get("/json/api/kink-list.php")
|
97
|
+
end
|
98
|
+
|
99
|
+
def mapping_list()
|
100
|
+
return self.get("/json/api/mapping-list.php")
|
101
|
+
end
|
102
|
+
|
103
|
+
# Handling friend requests, friend list data
|
104
|
+
def friend_list()
|
105
|
+
return self.get("/json/api/friend-list.php")
|
106
|
+
end
|
107
|
+
|
108
|
+
def friend_remove(source_name, dest_name)
|
109
|
+
return self.post("/json/api/friend-remove.php",
|
110
|
+
"source_name" => source_name,
|
111
|
+
"dest_name" => dest_name)
|
112
|
+
end
|
113
|
+
|
114
|
+
def request_accept(request_id)
|
115
|
+
return self.post("/json/api/request-accept.php",
|
116
|
+
"request_id" => request_id)
|
117
|
+
end
|
118
|
+
|
119
|
+
def request_cancel(request_id)
|
120
|
+
return self.post("/json/api/request-cancel.php",
|
121
|
+
"request_id" => request_id)
|
122
|
+
end
|
123
|
+
|
124
|
+
def request_deny(request_id)
|
125
|
+
return self.post("/json/api/request-deny.php",
|
126
|
+
"request_id" => request_id)
|
127
|
+
end
|
128
|
+
|
129
|
+
def request_list()
|
130
|
+
return self.get("/json/api/request-list.php")
|
131
|
+
end
|
132
|
+
|
133
|
+
def request_pending()
|
134
|
+
return self.get("/json/api/request-pending.php")
|
135
|
+
end
|
136
|
+
|
137
|
+
def request_send()
|
138
|
+
return self.get("/json/api/request-send.php")
|
139
|
+
end
|
140
|
+
|
28
141
|
end
|
29
142
|
end
|
metadata
CHANGED
@@ -1,80 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libfchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
5
|
-
prerelease:
|
4
|
+
version: '2.0'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ryan Gooler
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: turn
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
19
|
+
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0
|
26
|
+
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: miniunit
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: multi_json
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
54
|
+
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: faye-websocket
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0
|
61
|
+
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0
|
68
|
+
version: '0'
|
78
69
|
description: A library for connecting to F-chat ( http://f-list.net )
|
79
70
|
email: cheetahmorph@gmail.com
|
80
71
|
executables: []
|
@@ -87,26 +78,25 @@ files:
|
|
87
78
|
homepage: http://github.com/jippen/libfchat-ruby
|
88
79
|
licenses:
|
89
80
|
- MIT
|
81
|
+
metadata: {}
|
90
82
|
post_install_message:
|
91
83
|
rdoc_options: []
|
92
84
|
require_paths:
|
93
85
|
- lib
|
94
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
87
|
requirements:
|
97
|
-
- -
|
88
|
+
- - ">="
|
98
89
|
- !ruby/object:Gem::Version
|
99
90
|
version: '0'
|
100
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
92
|
requirements:
|
103
|
-
- -
|
93
|
+
- - ">="
|
104
94
|
- !ruby/object:Gem::Version
|
105
95
|
version: '0'
|
106
96
|
requirements: []
|
107
97
|
rubyforge_project:
|
108
|
-
rubygems_version:
|
98
|
+
rubygems_version: 2.6.11
|
109
99
|
signing_key:
|
110
|
-
specification_version:
|
100
|
+
specification_version: 4
|
111
101
|
summary: A library for connection to F-chat
|
112
102
|
test_files: []
|