discordrb 1.7.1 → 1.7.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/discordrb/events/await.rb +1 -1
- data/lib/discordrb/events/bans.rb +1 -1
- data/lib/discordrb/events/channel_create.rb +1 -1
- data/lib/discordrb/events/channel_delete.rb +1 -1
- data/lib/discordrb/events/channel_update.rb +1 -1
- data/lib/discordrb/events/generic.rb +5 -0
- data/lib/discordrb/events/guild_role_create.rb +1 -1
- data/lib/discordrb/events/guild_role_delete.rb +1 -1
- data/lib/discordrb/events/guild_role_update.rb +1 -1
- data/lib/discordrb/events/guilds.rb +1 -1
- data/lib/discordrb/events/lifetime.rb +2 -2
- data/lib/discordrb/events/members.rb +1 -1
- data/lib/discordrb/events/message.rb +2 -2
- data/lib/discordrb/events/presence.rb +2 -2
- data/lib/discordrb/events/typing.rb +1 -1
- data/lib/discordrb/events/voice_state_update.rb +1 -1
- data/lib/discordrb/version.rb +1 -1
- data/lib/discordrb/voice/encoder.rb +12 -2
- data/lib/discordrb/voice/voice_bot.rb +13 -0
- 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: f91839616b4ad8e792ebfbd149f2ecfcdc50e614
|
4
|
+
data.tar.gz: 45afd38f057ffb4d9366eac1bf404bfca064363e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf7c6250b3fc4bb927d76d7696d9f980559c1018e15a063306bba71d5c172dbd4c00ea01e26d85732fc2d056a1315ecaf672fc6e141d69d669b316d72c61efd6
|
7
|
+
data.tar.gz: 786ff878add75d25bdd5f49169f0ecd21515da2371e826dde0b5356d19bdcd293aab6bb842fb3b74109e03a72ee36f518b28fed85deca435e9b8b9bf5a3bb314
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.7.2
|
4
|
+
* The `bot` object can now be read from all events, not just from command ones.
|
5
|
+
* You can now set the `filter_volume` on VoiceBot, which corresponds to the old way of doing volume handling, in case the new way is too slow for you.
|
6
|
+
|
3
7
|
## 1.7.1
|
4
8
|
* A `clear!` method was added to EventContainer that removes all events from it, so you can overwrite modules by defining them again. (It's unnecessary for CommandContainers because commands can never be duplicate.)
|
5
9
|
|
@@ -3,7 +3,7 @@ require 'discordrb/data'
|
|
3
3
|
|
4
4
|
module Discordrb::Events
|
5
5
|
# Raised when a channel is updated (e.g. topic changes)
|
6
|
-
class ChannelUpdateEvent
|
6
|
+
class ChannelUpdateEvent < Event
|
7
7
|
attr_reader :type, :topic, :position, :name, :is_private, :channel, :server
|
8
8
|
|
9
9
|
def initialize(data, bot)
|
@@ -2,13 +2,13 @@ require 'discordrb/events/generic'
|
|
2
2
|
|
3
3
|
module Discordrb::Events
|
4
4
|
# @see Discordrb::EventContainer#ready
|
5
|
-
class ReadyEvent; end
|
5
|
+
class ReadyEvent < Event; end
|
6
6
|
|
7
7
|
# Event handler for {ReadyEvent}
|
8
8
|
class ReadyEventHandler < TrueEventHandler; end
|
9
9
|
|
10
10
|
# @see Discordrb::EventContainer#disconnected
|
11
|
-
class DisconnectEvent; end
|
11
|
+
class DisconnectEvent < Event; end
|
12
12
|
|
13
13
|
# Event handler for {DisconnectEvent}
|
14
14
|
class DisconnectEventHandler < TrueEventHandler; end
|
@@ -2,7 +2,7 @@ require 'discordrb/events/generic'
|
|
2
2
|
|
3
3
|
module Discordrb::Events
|
4
4
|
# Event raised when a text message is sent to a channel
|
5
|
-
class MessageEvent
|
5
|
+
class MessageEvent < Event
|
6
6
|
attr_reader :message, :saved_message
|
7
7
|
|
8
8
|
delegate :author, :channel, :content, :timestamp, to: :message
|
@@ -123,7 +123,7 @@ module Discordrb::Events
|
|
123
123
|
class PrivateMessageEventHandler < MessageEventHandler; end
|
124
124
|
|
125
125
|
# A subset of MessageEvent that only contains a message ID and a channel
|
126
|
-
class MessageIDEvent
|
126
|
+
class MessageIDEvent < Event
|
127
127
|
# @return [Integer] the ID associated with this event
|
128
128
|
attr_reader :id
|
129
129
|
|
@@ -3,7 +3,7 @@ require 'discordrb/data'
|
|
3
3
|
|
4
4
|
module Discordrb::Events
|
5
5
|
# Event raised when a user's presence state updates (idle or online)
|
6
|
-
class PresenceEvent
|
6
|
+
class PresenceEvent < Event
|
7
7
|
attr_reader :server, :user, :status
|
8
8
|
|
9
9
|
def initialize(data, bot)
|
@@ -41,7 +41,7 @@ module Discordrb::Events
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# Event raised when a user starts or stops playing a game
|
44
|
-
class PlayingEvent
|
44
|
+
class PlayingEvent < Event
|
45
45
|
attr_reader :server, :user, :game
|
46
46
|
|
47
47
|
def initialize(data, bot)
|
@@ -3,7 +3,7 @@ require 'discordrb/data'
|
|
3
3
|
|
4
4
|
module Discordrb::Events
|
5
5
|
# Event raised when a user's voice state updates
|
6
|
-
class VoiceStateUpdateEvent
|
6
|
+
class VoiceStateUpdateEvent < Event
|
7
7
|
attr_reader :user, :token, :suppress, :session_id, :self_mute, :self_deaf, :mute, :deaf, :server, :channel
|
8
8
|
|
9
9
|
def initialize(data, bot)
|
data/lib/discordrb/version.rb
CHANGED
@@ -16,11 +16,16 @@ module Discordrb::Voice
|
|
16
16
|
# @return [true, false] whether avconv should be used instead of ffmpeg.
|
17
17
|
attr_accessor :use_avconv
|
18
18
|
|
19
|
+
# @see VoiceBot#filter_volume=
|
20
|
+
# @return [Integer] the volume used as a filter to ffmpeg/avconv.
|
21
|
+
attr_accessor :filter_volume
|
22
|
+
|
19
23
|
# Create a new encoder
|
20
24
|
def initialize
|
21
25
|
@sample_rate = 48_000
|
22
26
|
@frame_size = 960
|
23
27
|
@channels = 2
|
28
|
+
@filter_volume = 1
|
24
29
|
|
25
30
|
if OPUS_AVAILABLE
|
26
31
|
@opus = Opus::Encoder.new(@sample_rate, @frame_size, @channels)
|
@@ -73,7 +78,7 @@ module Discordrb::Voice
|
|
73
78
|
# @param file [String] The path or URL to encode.
|
74
79
|
# @return [IO] the audio, encoded as s16le PCM
|
75
80
|
def encode_file(file)
|
76
|
-
command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" -f s16le -ar 48000 -ac 2 pipe:1"
|
81
|
+
command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
|
77
82
|
IO.popen(command)
|
78
83
|
end
|
79
84
|
|
@@ -83,7 +88,7 @@ module Discordrb::Voice
|
|
83
88
|
# @return [IO] the audio, encoded as s16le PCM
|
84
89
|
def encode_io(io)
|
85
90
|
ret_io, writer = IO.pipe
|
86
|
-
command = "#{ffmpeg_command} -loglevel 0 -i - -f s16le -ar 48000 -ac 2 pipe:1"
|
91
|
+
command = "#{ffmpeg_command} -loglevel 0 -i - -f s16le -ar 48000 -ac 2 #{filter_volume_argument} pipe:1"
|
87
92
|
spawn(command, in: io, out: writer)
|
88
93
|
ret_io
|
89
94
|
end
|
@@ -93,5 +98,10 @@ module Discordrb::Voice
|
|
93
98
|
def ffmpeg_command
|
94
99
|
@use_avconv ? 'avconv' : 'ffmpeg'
|
95
100
|
end
|
101
|
+
|
102
|
+
def filter_volume_argument
|
103
|
+
return '' if @filter_volume == 1
|
104
|
+
@use_avconv ? "-vol #{(@filter_volume * 256).ceil}" : "-af volume=#{@filter_volume}"
|
105
|
+
end
|
96
106
|
end
|
97
107
|
end
|
@@ -92,6 +92,19 @@ module Discordrb::Voice
|
|
92
92
|
@udp.encrypted?
|
93
93
|
end
|
94
94
|
|
95
|
+
# Set the filter volume. This volume is applied as a filter for decoded audio data. It has the advantage that using
|
96
|
+
# it is much faster than regular volume, but it can only be changed before starting to play something.
|
97
|
+
# @param value [Integer] The value to set the volume to. For possible values, see {#volume}
|
98
|
+
def filter_volume=(value)
|
99
|
+
@encoder.filter_volume = value
|
100
|
+
end
|
101
|
+
|
102
|
+
# @see #filter_volume=
|
103
|
+
# @return [Integer] the volume used as a filter for ffmpeg/avconv.
|
104
|
+
def filter_volume
|
105
|
+
@encoder.filter_volume
|
106
|
+
end
|
107
|
+
|
95
108
|
# Pause playback. This is not instant; it may take up to 20 ms for this change to take effect. (This is usually
|
96
109
|
# negligible.)
|
97
110
|
def pause
|
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.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- meew0
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faye-websocket
|