discordrb 1.1.3 → 1.2.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.

Potentially problematic release.


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

@@ -1,9 +1,9 @@
1
- require 'discordrb/events/generic'
2
-
3
- module Discordrb::Events
4
- class ReadyEvent; end
5
- class ReadyEventHandler < TrueEventHandler; end
6
-
7
- class DisconnectEvent; end
8
- class DisconnectEventHandler < TrueEventHandler; end
9
- end
1
+ require 'discordrb/events/generic'
2
+
3
+ module Discordrb::Events
4
+ class ReadyEvent; end
5
+ class ReadyEventHandler < TrueEventHandler; end
6
+
7
+ class DisconnectEvent; end
8
+ class DisconnectEventHandler < TrueEventHandler; end
9
+ end
@@ -1,59 +1,59 @@
1
- require 'discordrb/events/generic'
2
-
3
- module Discordrb::Events
4
- class MessageEvent
5
- attr_reader :message
6
-
7
- delegate :author, :channel, :content, :timestamp, to: :message
8
-
9
- def initialize(message, bot)
10
- @bot = bot
11
- @message = message
12
- end
13
-
14
- def send_message(content); @message.channel.send_message(content); end
15
-
16
- alias_method :user, :author
17
- alias_method :text, :content
18
- alias_method :send, :send_message
19
- alias_method :respond, :send_message
20
- end
21
-
22
- class MessageEventHandler < EventHandler
23
- def matches?(event)
24
- # Check for the proper event type
25
- return false unless event.is_a? MessageEvent
26
-
27
- return [
28
- matches_all(@attributes[:starting_with], event.content) { |a,e| e.start_with? a },
29
- matches_all(@attributes[:ending_with], event.content) { |a,e| e.end_with? a },
30
- matches_all(@attributes[:containing], event.content) { |a,e| e.include? a },
31
- matches_all(@attributes[:in], event.channel) do |a,e|
32
- if a.is_a? String
33
- # Make sure to remove the "#" from channel names in case it was specified
34
- a.gsub('#', '') == e.name
35
- elsif a.is_a? Fixnum
36
- a == e.id
37
- else
38
- a == e
39
- end
40
- end,
41
- matches_all(@attributes[:from], event.author) do |a,e|
42
- if a.is_a? String
43
- a == e.name
44
- elsif a.is_a? Fixnum
45
- a == e.id
46
- else
47
- a == e
48
- end
49
- end,
50
- matches_all(@attributes[:with_text], event.content) { |a,e| e == a },
51
- matches_all(@attributes[:after], event.timestamp) { |a,e| a > e },
52
- matches_all(@attributes[:before], event.timestamp) { |a,e| a < e }
53
- ].reduce(true, &:&)
54
- end
55
- end
56
-
57
- class MentionEvent < MessageEvent; end
58
- class MentionEventHandler < MessageEventHandler; end
59
- end
1
+ require 'discordrb/events/generic'
2
+
3
+ module Discordrb::Events
4
+ class MessageEvent
5
+ attr_reader :message
6
+
7
+ delegate :author, :channel, :content, :timestamp, to: :message
8
+
9
+ def initialize(message, bot)
10
+ @bot = bot
11
+ @message = message
12
+ end
13
+
14
+ def send_message(content); @message.channel.send_message(content); end
15
+
16
+ alias_method :user, :author
17
+ alias_method :text, :content
18
+ alias_method :send, :send_message
19
+ alias_method :respond, :send_message
20
+ end
21
+
22
+ class MessageEventHandler < EventHandler
23
+ def matches?(event)
24
+ # Check for the proper event type
25
+ return false unless event.is_a? MessageEvent
26
+
27
+ return [
28
+ matches_all(@attributes[:starting_with], event.content) { |a,e| e.start_with? a },
29
+ matches_all(@attributes[:ending_with], event.content) { |a,e| e.end_with? a },
30
+ matches_all(@attributes[:containing], event.content) { |a,e| e.include? a },
31
+ matches_all(@attributes[:in], event.channel) do |a,e|
32
+ if a.is_a? String
33
+ # Make sure to remove the "#" from channel names in case it was specified
34
+ a.gsub('#', '') == e.name
35
+ elsif a.is_a? Fixnum
36
+ a == e.id
37
+ else
38
+ a == e
39
+ end
40
+ end,
41
+ matches_all(@attributes[:from], event.author) do |a,e|
42
+ if a.is_a? String
43
+ a == e.name
44
+ elsif a.is_a? Fixnum
45
+ a == e.id
46
+ else
47
+ a == e
48
+ end
49
+ end,
50
+ matches_all(@attributes[:with_text], event.content) { |a,e| e == a },
51
+ matches_all(@attributes[:after], event.timestamp) { |a,e| a > e },
52
+ matches_all(@attributes[:before], event.timestamp) { |a,e| a < e }
53
+ ].reduce(true, &:&)
54
+ end
55
+ end
56
+
57
+ class MentionEvent < MessageEvent; end
58
+ class MentionEventHandler < MessageEventHandler; end
59
+ end
@@ -1,40 +1,40 @@
1
- require 'discordrb/events/generic'
2
- require 'discordrb/data'
3
-
4
- module Discordrb::Events
5
- class PresenceEvent
6
- attr_reader :server, :user, :status
7
-
8
- def initialize(data, bot)
9
- @user = Discordrb::User.new(data['user'], bot)
10
- @status = data['status'].to_sym
11
- @server = bot.server(data['guild_id'])
12
- end
13
- end
14
-
15
- class PresenceEventHandler < EventHandler
16
- def matches?(event)
17
- # Check for the proper event type
18
- return false unless event.is_a? PresenceEvent
19
-
20
- return [
21
- matches_all(@attributes[:from], event.user) do |a,e|
22
- if a.is_a? String
23
- a == e.name
24
- elsif a.is_a? Fixnum
25
- a == e.id
26
- else
27
- a == e
28
- end
29
- end,
30
- matches_all(@attributes[:status], event.status) do |a,e|
31
- if a.is_a? String
32
- a == e.to_s
33
- else
34
- a == e
35
- end
36
- end
37
- ].reduce(true, &:&)
38
- end
39
- end
40
- end
1
+ require 'discordrb/events/generic'
2
+ require 'discordrb/data'
3
+
4
+ module Discordrb::Events
5
+ class PresenceEvent
6
+ attr_reader :server, :user, :status
7
+
8
+ def initialize(data, bot)
9
+ @user = Discordrb::User.new(data['user'], bot)
10
+ @status = data['status'].to_sym
11
+ @server = bot.server(data['guild_id'])
12
+ end
13
+ end
14
+
15
+ class PresenceEventHandler < EventHandler
16
+ def matches?(event)
17
+ # Check for the proper event type
18
+ return false unless event.is_a? PresenceEvent
19
+
20
+ return [
21
+ matches_all(@attributes[:from], event.user) do |a,e|
22
+ if a.is_a? String
23
+ a == e.name
24
+ elsif a.is_a? Fixnum
25
+ a == e.id
26
+ else
27
+ a == e
28
+ end
29
+ end,
30
+ matches_all(@attributes[:status], event.status) do |a,e|
31
+ if a.is_a? String
32
+ a == e.to_s
33
+ else
34
+ a == e
35
+ end
36
+ end
37
+ ].reduce(true, &:&)
38
+ end
39
+ end
40
+ end
@@ -1,45 +1,45 @@
1
- require 'discordrb/events/generic'
2
-
3
- module Discordrb::Events
4
- class TypingEvent
5
- attr_reader :channel, :user, :timestamp
6
-
7
- def initialize(data, bot)
8
- @user_id = data['user_id']
9
- @user = bot.user(@user_id)
10
- @channel_id = data['channel_id']
11
- @channel = bot.channel(@channel_id)
12
- @timestamp = Time.at(data['timestamp'].to_i)
13
- end
14
- end
15
-
16
- class TypingEventHandler < EventHandler
17
- def matches?(event)
18
- # Check for the proper event type
19
- return false unless event.is_a? TypingEvent
20
-
21
- return [
22
- matches_all(@attributes[:in], event.channel) do |a,e|
23
- if a.is_a? String
24
- a.gsub('#', '') == e.name
25
- elsif a.is_a? Fixnum
26
- a == e.id
27
- else
28
- a == e
29
- end
30
- end,
31
- matches_all(@attributes[:from], event.user) do |a,e|
32
- if a.is_a? String
33
- a == e.name
34
- elsif a.is_a? Fixnum
35
- a == e.id
36
- else
37
- a == e
38
- end
39
- end,
40
- matches_all(@attributes[:after], event.timestamp) { |a,e| a > e },
41
- matches_all(@attributes[:before], event.timestamp) { |a,e| a < e }
42
- ].reduce(true, &:&)
43
- end
44
- end
45
- end
1
+ require 'discordrb/events/generic'
2
+
3
+ module Discordrb::Events
4
+ class TypingEvent
5
+ attr_reader :channel, :user, :timestamp
6
+
7
+ def initialize(data, bot)
8
+ @user_id = data['user_id']
9
+ @user = bot.user(@user_id)
10
+ @channel_id = data['channel_id']
11
+ @channel = bot.channel(@channel_id)
12
+ @timestamp = Time.at(data['timestamp'].to_i)
13
+ end
14
+ end
15
+
16
+ class TypingEventHandler < EventHandler
17
+ def matches?(event)
18
+ # Check for the proper event type
19
+ return false unless event.is_a? TypingEvent
20
+
21
+ return [
22
+ matches_all(@attributes[:in], event.channel) do |a,e|
23
+ if a.is_a? String
24
+ a.gsub('#', '') == e.name
25
+ elsif a.is_a? Fixnum
26
+ a == e.id
27
+ else
28
+ a == e
29
+ end
30
+ end,
31
+ matches_all(@attributes[:from], event.user) do |a,e|
32
+ if a.is_a? String
33
+ a == e.name
34
+ elsif a.is_a? Fixnum
35
+ a == e.id
36
+ else
37
+ a == e
38
+ end
39
+ end,
40
+ matches_all(@attributes[:after], event.timestamp) { |a,e| a > e },
41
+ matches_all(@attributes[:before], event.timestamp) { |a,e| a < e }
42
+ ].reduce(true, &:&)
43
+ end
44
+ end
45
+ end
@@ -0,0 +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,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
@@ -1,3 +1,3 @@
1
- module Discordrb
2
- VERSION = "1.1.3"
3
- end
1
+ module Discordrb
2
+ VERSION = "1.2.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.1.3
4
+ version: 1.2.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-13 00:00:00.000000000 Z
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket
@@ -102,11 +102,19 @@ files:
102
102
  - lib/discordrb/bot.rb
103
103
  - lib/discordrb/data.rb
104
104
  - lib/discordrb/endpoints/endpoints.rb
105
+ - lib/discordrb/events/channel-create.rb
106
+ - lib/discordrb/events/channel-delete.rb
107
+ - lib/discordrb/events/channel-update.rb
105
108
  - lib/discordrb/events/generic.rb
109
+ - lib/discordrb/events/guild-member-update.rb
110
+ - lib/discordrb/events/guild-role-create.rb
111
+ - lib/discordrb/events/guild-role-delete.rb
112
+ - lib/discordrb/events/guild-role-update.rb
106
113
  - lib/discordrb/events/lifetime.rb
107
114
  - lib/discordrb/events/message.rb
108
115
  - lib/discordrb/events/presence.rb
109
116
  - lib/discordrb/events/typing.rb
117
+ - lib/discordrb/events/voice-state-update.rb
110
118
  - lib/discordrb/exceptions.rb
111
119
  - lib/discordrb/version.rb
112
120
  homepage: https://github.com/meew0/discordrb