discordrb 1.3.11 → 1.3.12
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.
- checksums.yaml +4 -4
- data/lib/discordrb/bot.rb +16 -0
- data/lib/discordrb/data.rb +9 -0
- data/lib/discordrb/events/message.rb +5 -2
- data/lib/discordrb/version.rb +1 -1
- 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: 8344efadd31dd87ad79b62b72a82d6be04de185b
|
4
|
+
data.tar.gz: 9b7794426e79e82d8a86ccc24a394ea7747cb3bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7809cfda57d26b2ef71751162356f35a31b908c392fce6c556466c4bf779df17b22aba0bacd2702f7bf209650a88f3e7fb7232d3505322f5cb78bf81fd099c9d
|
7
|
+
data.tar.gz: 98a4c66c5882c5b651d9a044edeaa0b6f18713200b7332be26c26662e3268ee58253a2cefe802f5bf652ac30e7ed9b4d0a5d62689aeb0996af392d9e6340d557
|
data/lib/discordrb/bot.rb
CHANGED
@@ -28,6 +28,7 @@ module Discordrb
|
|
28
28
|
include Discordrb::Events
|
29
29
|
|
30
30
|
attr_reader :bot_user, :token, :users, :servers
|
31
|
+
attr_accessor :should_parse_self
|
31
32
|
|
32
33
|
def initialize(email, password, debug = false)
|
33
34
|
# Make sure people replace the login details in the example files...
|
@@ -37,6 +38,7 @@ module Discordrb
|
|
37
38
|
end
|
38
39
|
|
39
40
|
@debug = debug
|
41
|
+
@should_parse_self = false
|
40
42
|
|
41
43
|
@email = email
|
42
44
|
@password = password
|
@@ -271,6 +273,12 @@ module Discordrb
|
|
271
273
|
register_event(AwaitEvent, attributes, block)
|
272
274
|
end
|
273
275
|
|
276
|
+
def pm(attributes = {}, &block)
|
277
|
+
register_event(PrivateMessageEvent, attributes, block)
|
278
|
+
end
|
279
|
+
|
280
|
+
alias_method :private_message, :pm
|
281
|
+
|
274
282
|
def remove_handler(handler)
|
275
283
|
clazz = event_class(handler.class)
|
276
284
|
@event_handlers[clazz].delete(handler)
|
@@ -581,6 +589,9 @@ module Discordrb
|
|
581
589
|
create_message(data)
|
582
590
|
|
583
591
|
message = Message.new(data, self)
|
592
|
+
|
593
|
+
return if message.from_bot? && !should_parse_self
|
594
|
+
|
584
595
|
event = MessageEvent.new(message, self)
|
585
596
|
raise_event(event)
|
586
597
|
|
@@ -588,6 +599,11 @@ module Discordrb
|
|
588
599
|
event = MentionEvent.new(message, self)
|
589
600
|
raise_event(event)
|
590
601
|
end
|
602
|
+
|
603
|
+
if message.channel.private?
|
604
|
+
event = PrivateMessageEvent.new(message, self)
|
605
|
+
raise_event(event)
|
606
|
+
end
|
591
607
|
when 'TYPING_START'
|
592
608
|
start_typing(data)
|
593
609
|
|
data/lib/discordrb/data.rb
CHANGED
@@ -76,6 +76,11 @@ module Discordrb
|
|
76
76
|
@bot.add_await(key, MessageEvent, { from: @id }.merge(attributes), &block)
|
77
77
|
end
|
78
78
|
|
79
|
+
# Is the user the bot?
|
80
|
+
def bot?
|
81
|
+
@bot.bot_user.id == @id
|
82
|
+
end
|
83
|
+
|
79
84
|
# Determine if the user has permission to do an action
|
80
85
|
# action is a permission from Permissions::Flags.
|
81
86
|
# channel is the channel in which the action takes place (not applicable for server-wide actions).
|
@@ -282,6 +287,10 @@ module Discordrb
|
|
282
287
|
def await(key, attributes = {}, &block)
|
283
288
|
@bot.add_await(key, MessageEvent, { from: @author.id, in: @channel.id }.merge(attributes), &block)
|
284
289
|
end
|
290
|
+
|
291
|
+
def from_bot?
|
292
|
+
@author.bot?
|
293
|
+
end
|
285
294
|
end
|
286
295
|
|
287
296
|
# A server on Discord
|
@@ -61,8 +61,6 @@ module Discordrb::Events
|
|
61
61
|
a.delete('#') == e.name
|
62
62
|
elsif a.is_a? Fixnum
|
63
63
|
a == e.id
|
64
|
-
elsif a == ':bot'
|
65
|
-
e.from_bot?
|
66
64
|
else
|
67
65
|
a == e
|
68
66
|
end
|
@@ -72,6 +70,8 @@ module Discordrb::Events
|
|
72
70
|
a == e.name
|
73
71
|
elsif a.is_a? Fixnum
|
74
72
|
a == e.id
|
73
|
+
elsif a == :bot
|
74
|
+
e.bot?
|
75
75
|
else
|
76
76
|
a == e
|
77
77
|
end
|
@@ -92,4 +92,7 @@ module Discordrb::Events
|
|
92
92
|
|
93
93
|
class MentionEvent < MessageEvent; end
|
94
94
|
class MentionEventHandler < MessageEventHandler; end
|
95
|
+
|
96
|
+
class PrivateMessageEvent < MessageEvent; end
|
97
|
+
class PrivateMessageEventHandler < MessageEventHandler; end
|
95
98
|
end
|
data/lib/discordrb/version.rb
CHANGED
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.3.
|
4
|
+
version: 1.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- meew0
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faye-websocket
|