libfchat 0.2.0 → 1.0.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.
- data/lib/libfchat/fchat.rb +329 -15
- data/lib/libfchat/version.rb +1 -1
- metadata +1 -1
data/lib/libfchat/fchat.rb
CHANGED
@@ -33,13 +33,11 @@ module Libfchat
|
|
33
33
|
# commands that may or may not exist.
|
34
34
|
|
35
35
|
def method_missing(method_name, *args, &block)
|
36
|
-
puts "Method_missing: #{method_name}"
|
37
36
|
# Try to handle all three-letter strings
|
38
|
-
|
39
|
-
|
40
|
-
puts "Dunno how to handle #{method_name.to_s}"
|
37
|
+
if method_name.to_s[4,7] =~ /[A-Z]{3}/
|
38
|
+
#puts "Dunno how to handle #{method_name.to_s}"
|
41
39
|
else
|
42
|
-
|
40
|
+
super(method_name,*args,&block)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -54,9 +52,8 @@ module Libfchat
|
|
54
52
|
@websocket = Faye::WebSocket::Client.new(server)
|
55
53
|
|
56
54
|
@websocket.onopen = lambda do |event|
|
57
|
-
|
55
|
+
#When we connect, log in
|
58
56
|
self.send('IDN',account,character,ticket)
|
59
|
-
puts "Authentication sent"
|
60
57
|
end
|
61
58
|
|
62
59
|
@websocket.onclose = lambda do |event|
|
@@ -64,11 +61,23 @@ module Libfchat
|
|
64
61
|
end
|
65
62
|
|
66
63
|
@websocket.onmessage = lambda do |event|
|
67
|
-
|
64
|
+
type = event.data[0,3]
|
65
|
+
begin
|
66
|
+
data = MultiJson.load(event.data[4..-1])
|
67
|
+
rescue
|
68
|
+
data = MultiJson.load('{}')
|
69
|
+
end
|
70
|
+
puts "<< [#{type}] #{data}"
|
71
|
+
begin
|
72
|
+
self.send("got_#{type}",data)
|
73
|
+
rescue
|
74
|
+
end
|
68
75
|
end
|
69
76
|
}
|
70
77
|
end
|
71
78
|
|
79
|
+
##
|
80
|
+
# Generic message sender
|
72
81
|
def send_message(type,json)
|
73
82
|
jsonstr = ::MultiJson.dump(json)
|
74
83
|
msg = "#{type} #{jsonstr}"
|
@@ -76,33 +85,172 @@ module Libfchat
|
|
76
85
|
@websocket.send(msg)
|
77
86
|
end
|
78
87
|
|
88
|
+
# ====================================================== #
|
89
|
+
# Always respond to pings #
|
90
|
+
# ====================================================== #
|
91
|
+
|
92
|
+
##
|
93
|
+
# Respond to keepalive ping messages
|
94
|
+
def got_PIN(message)
|
95
|
+
self.send('PIN')
|
96
|
+
end
|
97
|
+
|
79
98
|
# ====================================================== #
|
80
99
|
# All commands that can be sent by a client have helpers #
|
81
100
|
# ====================================================== #
|
82
101
|
|
83
102
|
##
|
84
103
|
# Performs an account ban against a characters account.
|
104
|
+
#
|
85
105
|
# *This command requires chat op or higher.*
|
86
|
-
|
87
106
|
def ACB(character)
|
88
|
-
json = {
|
107
|
+
json = {:character => character}
|
89
108
|
self.send('send_message','ACB',json)
|
90
109
|
end
|
91
110
|
|
92
111
|
##
|
93
112
|
# Adds a character to the chat operator list.
|
113
|
+
#
|
94
114
|
# *This command is admin only.*
|
95
|
-
|
96
115
|
def AOP(character)
|
97
|
-
json = {
|
116
|
+
json = {:character => character}
|
98
117
|
self.send('send_message','AOP',json)
|
99
118
|
end
|
100
119
|
|
120
|
+
##
|
121
|
+
# Requests a list of currently connected alts for a characters account.
|
122
|
+
#
|
123
|
+
# *This command requires chat op or higher.*
|
124
|
+
def AWC(character)
|
125
|
+
json = {:character => character}
|
126
|
+
self.send('send_message','AWC',json)
|
127
|
+
end
|
128
|
+
|
129
|
+
##
|
130
|
+
# Broadcasts a message to all connections.
|
131
|
+
# *This command is admin only.*
|
132
|
+
def BRO(message)
|
133
|
+
json = {:message => message}
|
134
|
+
self.send('send_message','AWC',json)
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# Request the channel banlist.
|
139
|
+
#
|
140
|
+
# *This command requires channel op or higher.*
|
141
|
+
def CBL(channel)
|
142
|
+
json = {:channel => channel}
|
143
|
+
self.send('send_message','CBL',json)
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# Bans a character from a channel
|
148
|
+
#
|
149
|
+
# *This command requires channel op or higher.*
|
150
|
+
def CBU(channel,character)
|
151
|
+
json = {:channel => channel,
|
152
|
+
:character => character}
|
153
|
+
self.send('send_message','CBU',json)
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# Create an Ad-hoc Channel
|
158
|
+
def CCR(channel)
|
159
|
+
json = {:channel => channel}
|
160
|
+
self.send('send_message','CCR',json)
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# This command is used by an admin or channel owner to set a new
|
165
|
+
# channel description.
|
166
|
+
#
|
167
|
+
# *This command requires channel op or higher.*
|
168
|
+
def CCR(channel)
|
169
|
+
json = {:channel => channel}
|
170
|
+
self.send('send_message','CCR',json)
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# Request a list of all public channels
|
175
|
+
def CHA()
|
176
|
+
self.send('send_message','CHA',{})
|
177
|
+
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# Sends an invitation for a channel to a user
|
181
|
+
def CIU(channel,character)
|
182
|
+
json = {:channel => channel,
|
183
|
+
:character => character }
|
184
|
+
self.send('send_message','CIU',json)
|
185
|
+
end
|
186
|
+
|
187
|
+
##
|
188
|
+
# Kick a user from a channel
|
189
|
+
#
|
190
|
+
# *This command requires channel op or higher*
|
191
|
+
def CKU(channel,character)
|
192
|
+
json = {:channel => channel,
|
193
|
+
:character => character }
|
194
|
+
self.send('send_message','CKU',json)
|
195
|
+
end
|
196
|
+
|
197
|
+
##
|
198
|
+
# Op a user in a channel
|
199
|
+
#
|
200
|
+
# *This command requires channel op or higher*
|
201
|
+
def COA(channel,character)
|
202
|
+
json = {:channel => channel,
|
203
|
+
:character => character }
|
204
|
+
self.send('send_message','COA',json)
|
205
|
+
end
|
206
|
+
|
207
|
+
##
|
208
|
+
# Request a list of channel ops
|
209
|
+
def COA(channel)
|
210
|
+
json = {:channel => channel }
|
211
|
+
self.send('send_message','CKU',json)
|
212
|
+
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# Creates a global channel
|
216
|
+
#
|
217
|
+
# *This command is admin only*
|
218
|
+
def CRC(channel)
|
219
|
+
json = {:channel => channel }
|
220
|
+
self.send('send_message','CRC',json)
|
221
|
+
end
|
222
|
+
|
223
|
+
##
|
224
|
+
# Unban a user from a channel
|
225
|
+
#
|
226
|
+
# *This command requires channel op or higher*
|
227
|
+
def CUB(channel,character)
|
228
|
+
json = {:channel => channel,
|
229
|
+
:character => character }
|
230
|
+
self.send('send_message','CUB',json)
|
231
|
+
end
|
232
|
+
|
233
|
+
##
|
234
|
+
# Request that a character be stripped of chatop status
|
235
|
+
#
|
236
|
+
# *This command is admin only*
|
237
|
+
def DOP(character)
|
238
|
+
json = { :character => character }
|
239
|
+
self.send('send_message','DOP',json)
|
240
|
+
end
|
241
|
+
|
242
|
+
##
|
243
|
+
# Do a search for a kink with specific genders
|
244
|
+
def FKS(kink,genders)
|
245
|
+
json = { :kink => kink,
|
246
|
+
:genders => genders }
|
247
|
+
self.send('send_message','FKS',json)
|
248
|
+
end
|
249
|
+
|
101
250
|
##
|
102
251
|
# This command is used to identify with the server.
|
103
252
|
# NOTE: If you send any commands before identifying, you will be
|
104
253
|
# disconnected.
|
105
|
-
|
106
254
|
def IDN(account,
|
107
255
|
character,
|
108
256
|
ticket,
|
@@ -119,6 +267,172 @@ module Libfchat
|
|
119
267
|
self.send('send_message','IDN',json)
|
120
268
|
end
|
121
269
|
|
270
|
+
##
|
271
|
+
# Deal with ignoring characters.
|
272
|
+
#
|
273
|
+
# Available 'actions'
|
274
|
+
# notify: send this when someone on the ignore list sends a message to you
|
275
|
+
# add: Add a character to your ignore list
|
276
|
+
# remove: Remove a character from your ignore list
|
277
|
+
def IGN(action,character)
|
278
|
+
json = { :action => action,
|
279
|
+
:character => character }
|
280
|
+
self.send('send_message','IGN',json)
|
281
|
+
end
|
282
|
+
|
283
|
+
##
|
284
|
+
# Request that a character be IP banned
|
285
|
+
#
|
286
|
+
# *This command is admin only*
|
287
|
+
def IPB(character)
|
288
|
+
json = { :character => character }
|
289
|
+
self.send('send_message','IPB',json)
|
290
|
+
end
|
122
291
|
|
123
|
-
|
124
|
-
|
292
|
+
##
|
293
|
+
# Send a channel join request
|
294
|
+
def JCH(channel)
|
295
|
+
json = { :channel => channel }
|
296
|
+
self.send('send_message','JCH',json)
|
297
|
+
end
|
298
|
+
|
299
|
+
##
|
300
|
+
# Request a character to be kicked
|
301
|
+
#
|
302
|
+
# *This command requires channel op or higher*
|
303
|
+
def KIK(character)
|
304
|
+
json = {:character => character }
|
305
|
+
self.send('send_message','KIK',json)
|
306
|
+
end
|
307
|
+
|
308
|
+
##
|
309
|
+
# Request a character's list of kinks
|
310
|
+
def KIN(character)
|
311
|
+
json = {:character => character }
|
312
|
+
self.send('send_message','KIN',json)
|
313
|
+
end
|
314
|
+
|
315
|
+
##
|
316
|
+
# Leave a channel
|
317
|
+
def LCH(channel)
|
318
|
+
json = {:channel => channel }
|
319
|
+
self.send('send_message','LCH',json)
|
320
|
+
end
|
321
|
+
|
322
|
+
##
|
323
|
+
# Send a message to a channel
|
324
|
+
def MSG(channel,message)
|
325
|
+
json = {:channel => channel,
|
326
|
+
:message => message }
|
327
|
+
self.send('send_message','MSG',json)
|
328
|
+
end
|
329
|
+
|
330
|
+
##
|
331
|
+
# List presence of ops in all rooms
|
332
|
+
def OPP()
|
333
|
+
self.send('send_message','OPP',{})
|
334
|
+
end
|
335
|
+
|
336
|
+
##
|
337
|
+
# Request a list of open private rooms
|
338
|
+
def ORS()
|
339
|
+
self.send('send_message','ORS',{})
|
340
|
+
end
|
341
|
+
|
342
|
+
##
|
343
|
+
# Respond to a ping request
|
344
|
+
def PIN()
|
345
|
+
self.send('send_message','PIN',{})
|
346
|
+
end
|
347
|
+
|
348
|
+
##
|
349
|
+
# Sends a prive message to another user
|
350
|
+
def PRI(recipient,message)
|
351
|
+
json = {:recipient => recipient,
|
352
|
+
:message => message }
|
353
|
+
self.send('send_message','PRI',json)
|
354
|
+
end
|
355
|
+
|
356
|
+
##
|
357
|
+
# Do a profile request
|
358
|
+
def PRO(character)
|
359
|
+
json = {:character => character }
|
360
|
+
self.send('send_message','PRO',json)
|
361
|
+
end
|
362
|
+
|
363
|
+
##
|
364
|
+
# Advertises the first open private channel owned by the client
|
365
|
+
# in the given channel
|
366
|
+
def RAN(channel)
|
367
|
+
json = {:channel => channel }
|
368
|
+
self.send('send_message','RAN',json)
|
369
|
+
end
|
370
|
+
|
371
|
+
##
|
372
|
+
# Roll dice in a channel
|
373
|
+
def RLL(channel,dice)
|
374
|
+
json = {:channel => channel,
|
375
|
+
:dice => dice }
|
376
|
+
self.send('send_message','RLL',json)
|
377
|
+
end
|
378
|
+
|
379
|
+
##
|
380
|
+
# Set a private room's status to closed or open
|
381
|
+
#
|
382
|
+
# *This command requires channel op or higher*
|
383
|
+
def RST(channel,status)
|
384
|
+
json = {:channel => channel,
|
385
|
+
:status => status }
|
386
|
+
self.send('send_message','RST',json)
|
387
|
+
end
|
388
|
+
|
389
|
+
##
|
390
|
+
# Reward a user, for instance, for finding a bug
|
391
|
+
#
|
392
|
+
# *This command is admin only*
|
393
|
+
def RWD(character)
|
394
|
+
json = {:character => character }
|
395
|
+
self.send('send_message','RWD',json)
|
396
|
+
end
|
397
|
+
|
398
|
+
##
|
399
|
+
# Request a new status to be set for your character
|
400
|
+
def STA(status,statusmsg)
|
401
|
+
json = {:status => status,
|
402
|
+
:statusmsg => statusmsg }
|
403
|
+
self.send('send_message','STA',json)
|
404
|
+
end
|
405
|
+
|
406
|
+
##
|
407
|
+
# Admin or chatop command to request a timeout for a user
|
408
|
+
# time must be a minimum of one minute, and maximum of 90 minutes
|
409
|
+
#
|
410
|
+
# *This command requires channel op or higher*
|
411
|
+
def TMO(character,time,reason)
|
412
|
+
json = {:character => character,
|
413
|
+
:time => time,
|
414
|
+
:reason => reason }
|
415
|
+
self.send('send_message','TMO',json)
|
416
|
+
end
|
417
|
+
|
418
|
+
##
|
419
|
+
# User x is typing/stopped typing/entered text for private messages
|
420
|
+
#
|
421
|
+
# Available values for status: clear, paused, typing
|
422
|
+
def TPN(character,status)
|
423
|
+
json = {:character => character,
|
424
|
+
:status => status }
|
425
|
+
self.send('send_message','TPN',json)
|
426
|
+
end
|
427
|
+
|
428
|
+
##
|
429
|
+
# Unban a character
|
430
|
+
#
|
431
|
+
# *This command requires chat op or higher*
|
432
|
+
def UBN(character)
|
433
|
+
json = {:character => character }
|
434
|
+
self.send('send_message','UBN',json)
|
435
|
+
end
|
436
|
+
|
437
|
+
end #End of class
|
438
|
+
end #End of namespace
|
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 = "0.
|
5
|
+
VERSION = "1.0.0" unless defined?(::Libfchat::VERSION)
|
6
6
|
end
|