synacrb 0.3.0 → 0.3.1
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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/synacrb/common.rb +38 -43
- data/lib/synacrb/version.rb +1 -1
- data/lib/synacrb.rb +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2a86ffcf864c1c52ef8f62231b6fb2d098d217f
|
4
|
+
data.tar.gz: 8d5cb8688ecf2390fa1d7bdee94fbc90fa6a51a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be7827c0d1cc992564e4bed849feb150588b1c1321c097a58b107b694cbce10c39aa662563a057d9f8dfbbe83356bc61772a9f8ab824daa32a10f5b5900b4cf6
|
7
|
+
data.tar.gz: 3bad3e5d8c38897c359dfad211c8416cdc24929d12ded6f0b962bfb05c50b5b8905fc587c29f68b5999322c2c74c7068d96a07fd846e005a97d80b9668a5422b
|
data/Gemfile.lock
CHANGED
data/lib/synacrb/common.rb
CHANGED
@@ -10,19 +10,19 @@ module Synacrb
|
|
10
10
|
|
11
11
|
LIMIT_BULK = 64
|
12
12
|
|
13
|
-
ERR_ALREADY_EXISTS =
|
14
|
-
ERR_LIMIT_REACHED =
|
15
|
-
ERR_LOGIN_BANNED =
|
16
|
-
ERR_LOGIN_BOT =
|
17
|
-
ERR_LOGIN_INVALID =
|
18
|
-
ERR_MAX_CONN_PER_IP =
|
19
|
-
ERR_MISSING_FIELD =
|
20
|
-
ERR_MISSING_PERMISSION =
|
21
|
-
ERR_SELF_PM =
|
22
|
-
ERR_UNKNOWN_BOT =
|
23
|
-
ERR_UNKNOWN_CHANNEL =
|
24
|
-
ERR_UNKNOWN_MESSAGE =
|
25
|
-
ERR_UNKNOWN_USER =
|
13
|
+
ERR_ALREADY_EXISTS = 0
|
14
|
+
ERR_LIMIT_REACHED = 1
|
15
|
+
ERR_LOGIN_BANNED = 2
|
16
|
+
ERR_LOGIN_BOT = 3
|
17
|
+
ERR_LOGIN_INVALID = 4
|
18
|
+
ERR_MAX_CONN_PER_IP = 5
|
19
|
+
ERR_MISSING_FIELD = 6
|
20
|
+
ERR_MISSING_PERMISSION = 7
|
21
|
+
ERR_SELF_PM = 8
|
22
|
+
ERR_UNKNOWN_BOT = 9
|
23
|
+
ERR_UNKNOWN_CHANNEL = 10
|
24
|
+
ERR_UNKNOWN_MESSAGE = 11
|
25
|
+
ERR_UNKNOWN_USER = 12
|
26
26
|
|
27
27
|
PERM_READ = 1
|
28
28
|
PERM_WRITE = 1 << 1
|
@@ -38,33 +38,32 @@ module Synacrb
|
|
38
38
|
User = Struct.new(:admin, :ban, :bot, :id, :modes, :name)
|
39
39
|
|
40
40
|
# CLIENT PACKETS
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
PACKET_USERUPDATE_ID = 15; UserUpdate = Struct.new(:admin, :ban, :channel_mode, :id)
|
41
|
+
PACKET_ERR_ID = 0;
|
42
|
+
PACKET_RATELIMIT_ID = 1;
|
43
|
+
PACKET_CHANNELCREATE_ID = 2; ChannelCreate = Struct.new(:default_mode_bot, :default_mode_user, :name, :recipient)
|
44
|
+
PACKET_CHANNELDELETE_ID = 3; ChannelDelete = Struct.new(:id)
|
45
|
+
PACKET_CHANNELUPDATE_ID = 4; ChannelUpdate = Struct.new(:inner)
|
46
|
+
PACKET_COMMAND_ID = 5; Command = Struct.new(:args, :recipient)
|
47
|
+
PACKET_LOGIN_ID = 6; Login = Struct.new(:bot, :name, :password, :token)
|
48
|
+
PACKET_LOGINUPDATE_ID = 7; LoginUpdate = Struct.new(:name, :password_current, :password_new, :reset_token)
|
49
|
+
PACKET_MESSAGECREATE_ID = 8; MessageCreate = Struct.new(:channel, :text)
|
50
|
+
PACKET_MESSAGEDELETE_ID = 9; MessageDelete = Struct.new(:id)
|
51
|
+
PACKET_MESSAGEDELETEBULK_ID = 10; MessageDeleteBulk = Struct.new(:channel, :ids)
|
52
|
+
PACKET_MESSAGELIST_ID = 11; MessageList = Struct.new(:after, :before, :channel, :limit)
|
53
|
+
PACKET_MESSAGEUPDATE_ID = 12; MessageUpdate = Struct.new(:id, :text)
|
54
|
+
PACKET_TYPING_ID = 13; Typing = Struct.new(:channel)
|
55
|
+
PACKET_USERUPDATE_ID = 14; UserUpdate = Struct.new(:admin, :ban, :channel_mode, :id)
|
57
56
|
|
58
57
|
# SERVER PACKETS
|
59
|
-
PACKET_CHANNELDELETERECEIVE_ID =
|
60
|
-
PACKET_CHANNELRECEIVE_ID =
|
61
|
-
PACKET_COMMANDRECEIVE_ID =
|
62
|
-
PACKET_LOGINSUCCESS_ID =
|
63
|
-
PACKET_MESSAGEDELETERECEIVE_ID =
|
64
|
-
PACKET_MESSAGELISTRECEIVED_ID =
|
65
|
-
PACKET_MESSAGERECEIVE_ID =
|
66
|
-
PACKET_TYPINGRECEIVE_ID =
|
67
|
-
PACKET_USERRECEIVE_ID =
|
58
|
+
PACKET_CHANNELDELETERECEIVE_ID = 15; ChannelDeleteReceive = Struct.new(:inner)
|
59
|
+
PACKET_CHANNELRECEIVE_ID = 16; ChannelReceive = Struct.new(:inner)
|
60
|
+
PACKET_COMMANDRECEIVE_ID = 17; CommandReceive = Struct.new(:args, :author)
|
61
|
+
PACKET_LOGINSUCCESS_ID = 18; LoginSuccess = Struct.new(:created, :id, :token)
|
62
|
+
PACKET_MESSAGEDELETERECEIVE_ID = 19; MessageDeleteReceive = Struct.new(:id)
|
63
|
+
PACKET_MESSAGELISTRECEIVED_ID = 20; MessageListReceived = Struct.new(:id)
|
64
|
+
PACKET_MESSAGERECEIVE_ID = 21; MessageReceive = Struct.new(:inner, :new)
|
65
|
+
PACKET_TYPINGRECEIVE_ID = 22; TypingReceive = Struct.new(:author, :channel)
|
66
|
+
PACKET_USERRECEIVE_ID = 23; UserReceive = Struct.new(:inner)
|
68
67
|
|
69
68
|
def self.encode_u16(input)
|
70
69
|
(input >> 8).chr + (input % 256).chr
|
@@ -75,8 +74,6 @@ module Synacrb
|
|
75
74
|
|
76
75
|
def self.packet_from_id(id)
|
77
76
|
case id
|
78
|
-
when PACKET_CLOSE_ID
|
79
|
-
Close
|
80
77
|
when PACKET_CHANNELCREATE_ID
|
81
78
|
ChannelCreate
|
82
79
|
when PACKET_CHANNELDELETE_ID
|
@@ -124,9 +121,7 @@ module Synacrb
|
|
124
121
|
end
|
125
122
|
end
|
126
123
|
def self.packet_to_id(packet)
|
127
|
-
if packet.instance_of?
|
128
|
-
PACKET_CLOSE_ID
|
129
|
-
elsif packet.instance_of? ChannelCreate
|
124
|
+
if packet.instance_of? ChannelCreate
|
130
125
|
PACKET_CHANNELCREATE_ID
|
131
126
|
elsif packet.instance_of? ChannelDelete
|
132
127
|
PACKET_CHANNELDELETE_ID
|
data/lib/synacrb/version.rb
CHANGED
data/lib/synacrb.rb
CHANGED
@@ -21,8 +21,8 @@ module Synacrb
|
|
21
21
|
|
22
22
|
class Session
|
23
23
|
# Connect to the server
|
24
|
-
def initialize(addr, hash, &callback)
|
25
|
-
tcp = TCPSocket.new addr,
|
24
|
+
def initialize(addr, hash, port = Common::DEFAULT_PORT, &callback)
|
25
|
+
tcp = TCPSocket.new addr, port
|
26
26
|
|
27
27
|
@hash = hash
|
28
28
|
|
@@ -85,7 +85,6 @@ module Synacrb
|
|
85
85
|
|
86
86
|
# Close the connection
|
87
87
|
def close()
|
88
|
-
send(Common::Close)
|
89
88
|
@stream.close
|
90
89
|
end
|
91
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synacrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jD91mZM2
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|