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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d1542d6ad0666eb828fb415023c62059b0d29a7
4
- data.tar.gz: 3f4ba2868eea476ecc4195f0ce025fe8322aea9b
3
+ metadata.gz: 6d4b4617fadd16455acbcdae02520c0d2de8f6d6
4
+ data.tar.gz: 20c792e6f1a164247180c57ee7601f54f89ba381
5
5
  SHA512:
6
- metadata.gz: 667bff54430e689507d9983e62e1288ebea7854edc82d43724f3d0fac9cf37f108ff8c2682ad1bf82341ff02d68149aa7510ad4261e343cf9e4957b418b12481
7
- data.tar.gz: ca0d56615189e67ef450c26ca16f997bd3b37f33e30348832ddbd0ea949b8c077296a0deea7706d3153d1c7a278bc5eb9e6002ac81684fd7a0a5cf7955e59072
6
+ metadata.gz: e0c8e46ea8fd5918d5f48f443b6e651a96fedb3c7c0dfc53250e889d58859e4800844a6b6c71491d357a2af6004bb0d8985e51dcc7a297a852b1df7139ae9d90
7
+ data.tar.gz: 2535da1d543f437fe1be5bd186d9dd724f2eec5e0d573e58ab553bf19065916930c1f094ed78c3e63efda5482771d52977d4404d815ca0317237c114f5ed700f
@@ -31,7 +31,6 @@ module Discordrb::API
31
31
  def request(type, *attributes)
32
32
  # Add a custom user agent
33
33
  attributes.last[:user_agent] = user_agent if attributes.last.is_a? Hash
34
- puts attributes.last[:user_agent]
35
34
  RestClient.send(type, *attributes)
36
35
  end
37
36
 
@@ -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).
@@ -1,4 +1,4 @@
1
1
  # Discordrb and all its functionality, in this case only the version.
2
2
  module Discordrb
3
- VERSION = '1.4.2'
3
+ VERSION = '1.4.3'
4
4
  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.4.2
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-10 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket