discordrb 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of discordrb might be problematic. Click here for more details.

@@ -1,89 +1,89 @@
1
- require 'discordrb/events/generic'
2
- require 'discordrb/data'
3
-
4
- module Discordrb::Events
5
- class VoiceStateUpdateEvent
6
- attr_reader :user
7
- attr_reader :token
8
- attr_reader :suppress
9
- attr_reader :session_id
10
- attr_reader :self_mute
11
- attr_reader :self_deaf
12
- attr_reader :mute
13
- attr_reader :deaf
14
- attr_reader :server
15
- attr_reader :channel
16
-
17
- def initialize(data, bot)
18
- @token = data['token']
19
- @suppress = data['suppress']
20
- @session_id = data['session_id']
21
- @self_mute = data['self_mute']
22
- @self_deaf = data['self_deaf']
23
- @mute = data['mute']
24
- @deaf = data['deaf']
25
- @server = bot.server(data['guild_id'].to_i)
26
- return if !@server
27
- if data['channel_id']
28
- @channel = bot.channel(data['channel_id'].to_i)
29
- end
30
- @user = bot.user(data['user_id'].to_i)
31
- end
32
- end
33
-
34
- class VoiceStateUpdateEventHandler < EventHandler
35
- def matches?(event)
36
- # Check for the proper event type
37
- return false unless event.is_a? VoiceStateUpdateEvent
38
-
39
- return [
40
- matches_all(@attributes[:from], event.user) do |a,e|
41
- if a.is_a? String
42
- a == e.name
43
- elsif a.is_a? Fixnum
44
- a == e.id
45
- else
46
- a == e
47
- end
48
- end,
49
- matches_all(@attributes[:mute], event.mute) do |a,e|
50
- if a.is_a? Boolean
51
- a == e.to_s
52
- else
53
- a == e
54
- end
55
- end,
56
- matches_all(@attributes[:deaf], event.deaf) do |a,e|
57
- if a.is_a? Boolean
58
- a == e.to_s
59
- else
60
- a == e
61
- end
62
- end,
63
- matches_all(@attributes[:self_mute], event.self_mute) do |a,e|
64
- if a.is_a? Boolean
65
- a == e.to_s
66
- else
67
- a == e
68
- end
69
- end,
70
- matches_all(@attributes[:self_deaf], event.self_deaf) do |a,e|
71
- if a.is_a? Boolean
72
- a == e.to_s
73
- else
74
- a == e
75
- end
76
- end,
77
- matches_all(@attributes[:channel], event.channel) do |a,e|
78
- if a.is_a? String
79
- a == e.name
80
- elsif a.is_a? Fixnum
81
- a == e.id
82
- else
83
- a == e
84
- end
85
- end
86
- ].reduce(true, &:&)
87
- end
88
- end
89
- end
1
+ require 'discordrb/events/generic'
2
+ require 'discordrb/data'
3
+
4
+ module Discordrb::Events
5
+ class VoiceStateUpdateEvent
6
+ attr_reader :user
7
+ attr_reader :token
8
+ attr_reader :suppress
9
+ attr_reader :session_id
10
+ attr_reader :self_mute
11
+ attr_reader :self_deaf
12
+ attr_reader :mute
13
+ attr_reader :deaf
14
+ attr_reader :server
15
+ attr_reader :channel
16
+
17
+ def initialize(data, bot)
18
+ @token = data['token']
19
+ @suppress = data['suppress']
20
+ @session_id = data['session_id']
21
+ @self_mute = data['self_mute']
22
+ @self_deaf = data['self_deaf']
23
+ @mute = data['mute']
24
+ @deaf = data['deaf']
25
+ @server = bot.server(data['guild_id'].to_i)
26
+ return if !@server
27
+ if data['channel_id']
28
+ @channel = bot.channel(data['channel_id'].to_i)
29
+ end
30
+ @user = bot.user(data['user_id'].to_i)
31
+ end
32
+ end
33
+
34
+ class VoiceStateUpdateEventHandler < EventHandler
35
+ def matches?(event)
36
+ # Check for the proper event type
37
+ return false unless event.is_a? VoiceStateUpdateEvent
38
+
39
+ return [
40
+ matches_all(@attributes[:from], event.user) do |a,e|
41
+ if a.is_a? String
42
+ a == e.name
43
+ elsif a.is_a? Fixnum
44
+ a == e.id
45
+ else
46
+ a == e
47
+ end
48
+ end,
49
+ matches_all(@attributes[:mute], event.mute) do |a,e|
50
+ if a.is_a? Boolean
51
+ a == e.to_s
52
+ else
53
+ a == e
54
+ end
55
+ end,
56
+ matches_all(@attributes[:deaf], event.deaf) do |a,e|
57
+ if a.is_a? Boolean
58
+ a == e.to_s
59
+ else
60
+ a == e
61
+ end
62
+ end,
63
+ matches_all(@attributes[:self_mute], event.self_mute) do |a,e|
64
+ if a.is_a? Boolean
65
+ a == e.to_s
66
+ else
67
+ a == e
68
+ end
69
+ end,
70
+ matches_all(@attributes[:self_deaf], event.self_deaf) do |a,e|
71
+ if a.is_a? Boolean
72
+ a == e.to_s
73
+ else
74
+ a == e
75
+ end
76
+ end,
77
+ matches_all(@attributes[:channel], event.channel) do |a,e|
78
+ if a.is_a? String
79
+ a == e.name
80
+ elsif a.is_a? Fixnum
81
+ a == e.id
82
+ else
83
+ a == e
84
+ end
85
+ end
86
+ ].reduce(true, &:&)
87
+ end
88
+ end
89
+ end
@@ -1,10 +1,10 @@
1
- module Discordrb
2
- # Raised when authentication data is invalid or incorrect.
3
- class InvalidAuthenticationException < RuntimeError; end
4
-
5
- # Raised when a HTTP status code indicates a failure
6
- class HTTPStatusException < RuntimeError
7
- attr :status
8
- def initialize(status); @status = status; end
9
- end
10
- end
1
+ module Discordrb
2
+ # Raised when authentication data is invalid or incorrect.
3
+ class InvalidAuthenticationException < RuntimeError; end
4
+
5
+ # Raised when a HTTP status code indicates a failure
6
+ class HTTPStatusException < RuntimeError
7
+ attr :status
8
+ def initialize(status); @status = status; end
9
+ end
10
+ end
@@ -0,0 +1,46 @@
1
+ module Discordrb
2
+ class Permissions
3
+ # This hash maps bit positions to logical permissions.
4
+ # I'm not sure what the unlabeled bits are reserved for.
5
+ Flags = {
6
+ # Bit => Permission # Value
7
+ 0 => :create_instant_invite, # 1
8
+ 1 => :kick_members, # 2
9
+ 2 => :ban_members, # 4
10
+ 3 => :manage_roles , # 8
11
+ 4 => :manage_channels, # 16
12
+ 5 => :manage_server, # 32
13
+ #6 # 64
14
+ #7 # 128
15
+ #8 # 256
16
+ #9 # 512
17
+ 10 => :read_messages, # 1024
18
+ 11 => :send_messages, # 2048
19
+ 12 => :send_tts_messages, # 4096
20
+ 13 => :manage_messages, # 8192
21
+ 14 => :embed_links, # 16384
22
+ 15 => :attach_files, # 32768
23
+ 16 => :read_message_history, # 65536
24
+ 17 => :mention_everyone, # 131072
25
+ #18 # 262144
26
+ #19 # 524288
27
+ 20 => :connect, # 1048576
28
+ 21 => :speak, # 2097152
29
+ 22 => :mute_members, # 4194304
30
+ 23 => :deafen_members, # 8388608
31
+ 24 => :move_members, # 16777216
32
+ 25 => :use_voice_activity # 33554432
33
+ }
34
+
35
+ Flags.each_value do |flag|
36
+ attr_reader flag
37
+ end
38
+
39
+ def initialize(bits)
40
+ Flags.each do |position, flag|
41
+ flag_set = ((bits >> position) & 0x1) == 1
42
+ instance_variable_set "@#{flag}", flag_set
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
- module Discordrb
2
- VERSION = "1.2.0"
3
- end
1
+ module Discordrb
2
+ VERSION = "1.3.0"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discordrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - meew0
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-27 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket
@@ -100,6 +100,8 @@ files:
100
100
  - examples/pm.rb
101
101
  - lib/discordrb.rb
102
102
  - lib/discordrb/bot.rb
103
+ - lib/discordrb/commands/command-bot.rb
104
+ - lib/discordrb/commands/parser.rb
103
105
  - lib/discordrb/data.rb
104
106
  - lib/discordrb/endpoints/endpoints.rb
105
107
  - lib/discordrb/events/channel-create.rb
@@ -116,6 +118,7 @@ files:
116
118
  - lib/discordrb/events/typing.rb
117
119
  - lib/discordrb/events/voice-state-update.rb
118
120
  - lib/discordrb/exceptions.rb
121
+ - lib/discordrb/permissions.rb
119
122
  - lib/discordrb/version.rb
120
123
  homepage: https://github.com/meew0/discordrb
121
124
  licenses: