discordrb 1.4.2 → 1.4.3
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/lib/discordrb/api.rb +0 -1
- data/lib/discordrb/bot.rb +24 -0
- 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: 6d4b4617fadd16455acbcdae02520c0d2de8f6d6
|
4
|
+
data.tar.gz: 20c792e6f1a164247180c57ee7601f54f89ba381
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0c8e46ea8fd5918d5f48f443b6e651a96fedb3c7c0dfc53250e889d58859e4800844a6b6c71491d357a2af6004bb0d8985e51dcc7a297a852b1df7139ae9d90
|
7
|
+
data.tar.gz: 2535da1d543f437fe1be5bd186d9dd724f2eec5e0d573e58ab553bf19065916930c1f094ed78c3e63efda5482771d52977d4404d815ca0317237c114f5ed700f
|
data/lib/discordrb/api.rb
CHANGED
data/lib/discordrb/bot.rb
CHANGED
@@ -246,6 +246,30 @@ module Discordrb
|
|
246
246
|
results
|
247
247
|
end
|
248
248
|
|
249
|
+
# Finds a user given its username. This allows fuzzy finding using Levenshtein
|
250
|
+
# distances, see {#find}
|
251
|
+
# @param username [String] The username to look for.
|
252
|
+
# @param threshold [Integer] The threshold for the Levenshtein algorithm. The larger
|
253
|
+
# the threshold is, the more misspellings will be allowed.
|
254
|
+
# @return [Array<User>] The array of users that were found. May be empty if none were found.
|
255
|
+
def find_user(username, threshold = 0)
|
256
|
+
require 'levenshtein'
|
257
|
+
|
258
|
+
results = []
|
259
|
+
@users.values.each do |user|
|
260
|
+
distance = Levenshtein.distance(user.username, username)
|
261
|
+
next if distance > threshold
|
262
|
+
|
263
|
+
# Make a singleton accessor "distance"
|
264
|
+
user.instance_variable_set(:@distance, distance)
|
265
|
+
class << user
|
266
|
+
attr_reader :distance
|
267
|
+
end
|
268
|
+
results << user
|
269
|
+
end
|
270
|
+
results
|
271
|
+
end
|
272
|
+
|
249
273
|
# Sends a text message to a channel given its ID and the message's content.
|
250
274
|
# @param channel_id [Integer] The ID that identifies the channel to send something to.
|
251
275
|
# @param content [String] The text that should be sent as a message. It is limited to 2000 characters (Discord imposed).
|
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.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- meew0
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faye-websocket
|