discordrb 1.5.1 → 1.5.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 +11 -0
- data/lib/discordrb/bot.rb +3 -2
- data/lib/discordrb/token_cache.rb +2 -2
- data/lib/discordrb/version.rb +1 -1
- data/lib/discordrb/voice/encoder.rb +9 -3
- data/lib/discordrb/voice/voice_bot.rb +7 -2
- 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: 8edaf61a0d0837db5dd14c5c276d222586752ebe
|
4
|
+
data.tar.gz: ffe050f90456b21d9ca960e540c2206b60cf8bd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ff12cfbf0756c5f2d41c807cda2c0c6b27e8835a00b109af02a4bb7f2daf70be5f89774e7bdebf53f1c602749181ae2c1ff6efedf6cb4462d553ad2ab9436dc
|
7
|
+
data.tar.gz: ad825713c559a666b95c352ae0d3ce23ee77aeacf83b22d100d3d51238a631994e69535f544026102c5aebc9774939dd6ccec709b0a3795595be22125ffbc3fe
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.5.2
|
4
|
+
* `bot.voice_connect` can now use a channel ID directly.
|
5
|
+
* A reader `bot.volume` now exists for the corresponding writer.
|
6
|
+
* The attribute `bot.encoder.use_avconv` was added that makes the bot use avconv instead of ffmpeg (for those on Ubuntu 14.x)
|
7
|
+
* The PBKDF2 iteration count for token caching was increased to 300,000 for extra security.
|
8
|
+
|
9
|
+
### Bugfixes
|
10
|
+
* Fix a bug where `play_file` wouldn't properly accept string file paths (#36, thanks @purintai)
|
11
|
+
* Fix a concurrency issue where `VoiceBot` would try to read from nil
|
12
|
+
|
13
|
+
|
3
14
|
## 1.5.1
|
4
15
|
* The connection to voice was made more reliable. I haven't experienced any issues with it myself but I got reports where `recv` worked better than `recvmsg`.
|
5
16
|
|
data/lib/discordrb/bot.rb
CHANGED
@@ -200,14 +200,15 @@ module Discordrb
|
|
200
200
|
|
201
201
|
attr_reader :voice
|
202
202
|
|
203
|
-
def voice_connect(
|
203
|
+
def voice_connect(chan)
|
204
204
|
if @voice
|
205
205
|
debug('Voice bot exists already! Destroying it')
|
206
206
|
@voice.destroy
|
207
207
|
@voice = nil
|
208
208
|
end
|
209
209
|
|
210
|
-
|
210
|
+
chan = channel(chan) if chan.is_a? Integer
|
211
|
+
@voice_channel = chan
|
211
212
|
debug("Got voice channel: #{@voice_channel}")
|
212
213
|
|
213
214
|
data = {
|
@@ -41,7 +41,7 @@ module Discordrb
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def obtain_key(password)
|
44
|
-
@key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(password, @encrypt_salt,
|
44
|
+
@key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(password, @encrypt_salt, 300_000, KEYLEN)
|
45
45
|
end
|
46
46
|
|
47
47
|
def generate_salts
|
@@ -76,7 +76,7 @@ module Discordrb
|
|
76
76
|
|
77
77
|
def hash_password(password)
|
78
78
|
digest = OpenSSL::Digest::SHA256.new
|
79
|
-
OpenSSL::PKCS5.pbkdf2_hmac(password, @verify_salt,
|
79
|
+
OpenSSL::PKCS5.pbkdf2_hmac(password, @verify_salt, 300_000, digest.digest_length, digest)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
data/lib/discordrb/version.rb
CHANGED
@@ -4,7 +4,7 @@ require 'opus-ruby'
|
|
4
4
|
module Discordrb::Voice
|
5
5
|
# Wrapper class around opus-ruby
|
6
6
|
class Encoder
|
7
|
-
attr_accessor :volume
|
7
|
+
attr_accessor :volume, :use_avconv
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@sample_rate = 48_000
|
@@ -23,15 +23,21 @@ module Discordrb::Voice
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def encode_file(file)
|
26
|
-
command = "
|
26
|
+
command = "#{ffmpeg_command} -loglevel 0 -i \"#{file}\" -f s16le -ar 48000 -ac 2 -af volume=#{@volume} pipe:1"
|
27
27
|
IO.popen(command)
|
28
28
|
end
|
29
29
|
|
30
30
|
def encode_io(io)
|
31
31
|
ret_io, writer = IO.pipe
|
32
|
-
command = "
|
32
|
+
command = "#{ffmpeg_command} -loglevel 0 -i - -f s16le -ar 48000 -ac 2 -af volume=#{@volume} pipe:1"
|
33
33
|
spawn(command, in: io, out: writer)
|
34
34
|
ret_io
|
35
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def ffmpeg_command
|
40
|
+
@use_avconv ? 'avconv' : 'ffmpeg'
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
@@ -11,7 +11,7 @@ module Discordrb::Voice
|
|
11
11
|
|
12
12
|
# A voice connection consisting of a UDP socket and a websocket client
|
13
13
|
class VoiceBot
|
14
|
-
attr_reader :stream_time
|
14
|
+
attr_reader :stream_time, :encoder
|
15
15
|
|
16
16
|
def initialize(channel, bot, token, session, endpoint)
|
17
17
|
@bot = bot
|
@@ -29,6 +29,10 @@ module Discordrb::Voice
|
|
29
29
|
@encoder.volume = value
|
30
30
|
end
|
31
31
|
|
32
|
+
def volume
|
33
|
+
@encoder.volume
|
34
|
+
end
|
35
|
+
|
32
36
|
# Pause playback
|
33
37
|
def pause
|
34
38
|
@paused = true
|
@@ -88,6 +92,7 @@ module Discordrb::Voice
|
|
88
92
|
self.speaking = true
|
89
93
|
loop do
|
90
94
|
break unless @playing
|
95
|
+
break unless @io
|
91
96
|
|
92
97
|
if count % 100 == 10
|
93
98
|
# Starting from the tenth packet, perform length adjustment every 100 packets (2 seconds)
|
@@ -97,7 +102,7 @@ module Discordrb::Voice
|
|
97
102
|
# Read some data from the buffer
|
98
103
|
buf = nil
|
99
104
|
begin
|
100
|
-
buf = @io.readpartial(DATA_LENGTH)
|
105
|
+
buf = @io.readpartial(DATA_LENGTH) if @io
|
101
106
|
rescue EOFError
|
102
107
|
@bot.debug('EOF while reading, breaking immediately')
|
103
108
|
break
|
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.5.
|
4
|
+
version: 1.5.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-01-
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faye-websocket
|