libfchat 1.4 → 1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/libfchat/fchat.rb +14 -15
- data/lib/libfchat/version.rb +1 -1
- metadata +9 -9
data/lib/libfchat/fchat.rb
CHANGED
@@ -9,11 +9,12 @@ module Libfchat
|
|
9
9
|
require 'multi_json'
|
10
10
|
require 'faye/websocket'
|
11
11
|
require 'eventmachine'
|
12
|
+
require 'logger'
|
13
|
+
require 'insensitive_hash/minimal'
|
12
14
|
require 'libfchat/version'
|
13
15
|
require 'libfchat/webapi'
|
14
16
|
|
15
17
|
class Fchat
|
16
|
-
attr_accessor :spam
|
17
18
|
attr_reader :ticket
|
18
19
|
attr_accessor :websocket
|
19
20
|
|
@@ -33,17 +34,19 @@ module Libfchat
|
|
33
34
|
attr_accessor :ops
|
34
35
|
attr_accessor :users
|
35
36
|
attr_accessor :rooms
|
37
|
+
attr_accessor :logger
|
36
38
|
|
37
39
|
##
|
38
40
|
# Initialize the object with the name and version.
|
39
41
|
# Default to just identifying as the library
|
40
42
|
|
41
|
-
def initialize(clientname="libfchat-ruby by Jippen Faddoul ( http://github.com/jippen/libfchat-ruby )",version=Libfchat::VERSION)
|
43
|
+
def initialize(clientname="libfchat-ruby by Jippen Faddoul ( http://github.com/jippen/libfchat-ruby )",version=Libfchat::VERSION, level=Logger::DEBUG)
|
42
44
|
@clientname = clientname
|
43
45
|
@version = version
|
44
|
-
@users =
|
45
|
-
@rooms =
|
46
|
-
@
|
46
|
+
@users = InsensitiveHash.new
|
47
|
+
@rooms = InsensitiveHash.new
|
48
|
+
@logger = Logger.new(STDOUT)
|
49
|
+
@logger.level = level
|
47
50
|
end
|
48
51
|
|
49
52
|
##
|
@@ -69,10 +72,7 @@ module Libfchat
|
|
69
72
|
data = MultiJson.load('{}')
|
70
73
|
end
|
71
74
|
|
72
|
-
#
|
73
|
-
if @spam
|
74
|
-
puts "<< #{msg}"
|
75
|
-
end
|
75
|
+
@logger.debug("<< #{msg}")
|
76
76
|
|
77
77
|
begin
|
78
78
|
self.send("got_#{type}",data)
|
@@ -86,6 +86,7 @@ module Libfchat
|
|
86
86
|
def login(server,account,password,character,timeout=30)
|
87
87
|
webapi = Libfchat::WebAPI.new
|
88
88
|
@ticket = webapi.get_ticket(account,password)
|
89
|
+
@me = character
|
89
90
|
|
90
91
|
EM.run {
|
91
92
|
@websocket = Faye::WebSocket::Client.new(server)
|
@@ -110,13 +111,11 @@ module Libfchat
|
|
110
111
|
def send_message(type, json)
|
111
112
|
jsonstr = ::MultiJson.dump(json)
|
112
113
|
msg = "#{type} #{jsonstr}"
|
113
|
-
if
|
114
|
-
|
115
|
-
json[:ticket] = '[REDACTED]'
|
116
|
-
end
|
117
|
-
filteredjsonstr = ::MultiJson.dump(json)
|
118
|
-
puts ">> #{type} #{filteredjsonstr}"
|
114
|
+
if type == 'IDN'
|
115
|
+
json[:ticket] = '[REDACTED]'
|
119
116
|
end
|
117
|
+
filteredjsonstr = ::MultiJson.dump(json)
|
118
|
+
@logger.debug(">> #{type} #{filteredjsonstr}")
|
120
119
|
@websocket.send(msg)
|
121
120
|
end
|
122
121
|
|
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 = "1.
|
5
|
+
VERSION = "1.5" unless defined?(::Libfchat::VERSION)
|
6
6
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libfchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-25 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: turn
|
16
|
-
requirement: &
|
16
|
+
requirement: &13036760 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.5
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13036760
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: miniunit
|
27
|
-
requirement: &
|
27
|
+
requirement: &13036220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.1
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13036220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: multi_json
|
38
|
-
requirement: &
|
38
|
+
requirement: &13035760 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.3.6
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *13035760
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: faye-websocket
|
49
|
-
requirement: &
|
49
|
+
requirement: &13035300 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 0.4.6
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *13035300
|
58
58
|
description: A library for connecting to F-chat ( http://f-list.net )
|
59
59
|
email: cheetahmorph@gmail.com
|
60
60
|
executables: []
|