warchat 0.0.3 → 0.0.4
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/README.rdoc +57 -0
- data/lib/warchat.rb +1 -1
- data/lib/warchat/chat/chat_response.rb +2 -1
- data/lib/warchat/chat/client.rb +6 -2
- data/lib/warchat/chat/message.rb +1 -2
- data/lib/warchat/network/connection.rb +1 -1
- data/lib/warchat/network/session.rb +5 -1
- data/lib/warchat/version.rb +1 -1
- metadata +4 -3
data/README.rdoc
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
= Warchat
|
2
|
+
|
3
|
+
This project aims to create a simple ruby interface for connecting to Blizzard's Mobile Guild Chat.
|
4
|
+
|
5
|
+
= Features
|
6
|
+
|
7
|
+
At the moment there is only a very basic set of features, but the main hurdle of
|
8
|
+
authenticating with the mobile armory server is mostly solved.
|
9
|
+
|
10
|
+
* SRP authentication
|
11
|
+
* Guild Chat
|
12
|
+
* Officer Chat
|
13
|
+
* Whispers
|
14
|
+
* Presence notifications
|
15
|
+
|
16
|
+
= Simple Usage example
|
17
|
+
|
18
|
+
This is a simple chat client that will let you talk in guild chat and receive messages.
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
require 'warchat'
|
22
|
+
|
23
|
+
USERNAME = ''
|
24
|
+
PASSWORD = ''
|
25
|
+
CHARACTER_NAME = ''
|
26
|
+
CHARACTER_REALM = ''
|
27
|
+
|
28
|
+
client = Warchat::Chat::Client.new
|
29
|
+
|
30
|
+
client.on_establish = Proc.new do |response|
|
31
|
+
client.character_name = CHARACTER_NAME
|
32
|
+
client.character_realm = CHARACTER_REALM
|
33
|
+
client.login
|
34
|
+
end
|
35
|
+
|
36
|
+
client.on_message = Proc.new do |message|
|
37
|
+
case message.type
|
38
|
+
when Warchat::Chat::Message::CHAT_MSG_TYPE_GUILD_CHAT
|
39
|
+
puts "[Guild] #{message.character_name}: #{message.body}"
|
40
|
+
when Warchat::Chat::Message::CHAT_MSG_TYPE_GUILD_MOTD
|
41
|
+
puts "MOTD: #{message.body}"
|
42
|
+
when Warchat::Chat::Message::CHAT_MSG_TYPE_OFFICER_CHAT
|
43
|
+
puts "[Officer] #{message.character_name}: #{message.body}"
|
44
|
+
when Warchat::Chat::Message::CHAT_MSG_TYPE_WHISPER
|
45
|
+
puts "[Whisper] #{message.character_name}: #{message.body}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
begin
|
50
|
+
client.start(USERNAME,PASSWORD)
|
51
|
+
loop do
|
52
|
+
msg = gets.chomp
|
53
|
+
client.message msg,Warchat::Chat::Message::CHAT_MSG_TYPE_GUILD_CHAT
|
54
|
+
end
|
55
|
+
rescue Interrupt => e
|
56
|
+
client.close
|
57
|
+
end
|
data/lib/warchat.rb
CHANGED
@@ -4,4 +4,4 @@ require 'andand'
|
|
4
4
|
module Warchat
|
5
5
|
end
|
6
6
|
|
7
|
-
[['*.rb'],['network','*.rb'],['srp','*.rb'],['chat','*.rb']].each do |p| Dir.glob(File.join(File.expand_path('../
|
7
|
+
[['*.rb'],['network','*.rb'],['srp','*.rb'],['chat','*.rb']].each do |p| Dir.glob(File.join(File.expand_path('../warchat',__FILE__),*p)).each &method(:require) end
|
data/lib/warchat/chat/client.rb
CHANGED
@@ -62,17 +62,21 @@ module Warchat
|
|
62
62
|
on_message.andand.call(message)
|
63
63
|
send("on_message_#{message.type}".to_sym).andand.call(message)
|
64
64
|
elsif response.presence?
|
65
|
-
puts
|
66
65
|
on_presence.andand.call(Presence.new(response))
|
67
66
|
else
|
68
67
|
puts "unhandled chat type: #{response.chat_type}"
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
72
|
-
def
|
71
|
+
def close_nonblock
|
73
72
|
request = Warchat::Network::Request.new("/chat-logout",:chatSessionId=>@chat_session_id)
|
74
73
|
session.send_request(request)
|
75
74
|
end
|
75
|
+
|
76
|
+
def close
|
77
|
+
close_nonblock
|
78
|
+
sleep(0.1) until session.is_closed?
|
79
|
+
end
|
76
80
|
|
77
81
|
def keep_alive
|
78
82
|
request = Warchat::Network::Request("/ah-mail")
|
data/lib/warchat/chat/message.rb
CHANGED
@@ -12,7 +12,7 @@ module Warchat
|
|
12
12
|
CHAT_MSG_TYPE_OFFICER_CHAT = "officer_chat"
|
13
13
|
CHAT_MSG_TYPE_WHISPER = "whisper"
|
14
14
|
|
15
|
-
attr_reader :type,:body,:from_type,:character_id
|
15
|
+
attr_reader :type,:body,:from_type,:character_id,:from
|
16
16
|
|
17
17
|
def initialize response
|
18
18
|
@type = response["messageType"]
|
@@ -21,7 +21,6 @@ module Warchat
|
|
21
21
|
if @from
|
22
22
|
@from_type = from["chatIdType"]
|
23
23
|
@character_id = from["characterId"]
|
24
|
-
@character_name = from['characterName']
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
data/lib/warchat/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zachary Gavin
|
@@ -60,6 +60,7 @@ extra_rdoc_files: []
|
|
60
60
|
files:
|
61
61
|
- .gitignore
|
62
62
|
- Gemfile
|
63
|
+
- README.rdoc
|
63
64
|
- Rakefile
|
64
65
|
- lib/warchat.rb
|
65
66
|
- lib/warchat/byte_string.rb
|