meimei 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/meimei.gemspec +1 -1
  4. data/plugins/eta.rb +9 -6
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e63297c5cc55dfe6073e09f54b2d8b4af4fe3b5
4
- data.tar.gz: c45e79b4a396565a6d0fb3c7a5d109dfc9ce5cd0
3
+ metadata.gz: 1a0f3088857a15a27e46e3247ee18469011626cf
4
+ data.tar.gz: 403a278f19f0db750fb4c5db420140011e2fc2bd
5
5
  SHA512:
6
- metadata.gz: 6c735386c36beb044fc25331e209bcfa548b69655372ed126829ce65acc90da9c9d3558bba1193809304486cf8b2b8605615634013929bcee82a7ec029a8a7e5
7
- data.tar.gz: fbf33e4484b121033755ac7fa1144eb80e772e04550b5205050eb8dadc7b398a4274397cfda7961e2fb1d503340ba5d4f2f86d6aee440dab51fdcc2d7e48f75c
6
+ metadata.gz: 65ba2aa536f6ec2636e843583c84163d1258e302e22c9508a316710d649bbbd75a0d27a7a25d23eeeddcce12690ae44f430b3b8dca6408d648a361f1459876de
7
+ data.tar.gz: bb872becb85c745f8a65412d952f1d734cadfa3451a209e59379405336e7afb2e06262429dd58120cd0d0d8105eaccf66e397e4469c10f953284542efac7a8ec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/meimei.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "meimei"
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["r888888888"]
data/plugins/eta.rb CHANGED
@@ -5,9 +5,9 @@ require 'damerau-levenshtein'
5
5
  require 'time_difference'
6
6
 
7
7
  define_plugin("!eta") do |msg|
8
- query = msg
8
+ query = Regexp.compile(Regexp.escape(msg.downcase.gsub(/[^a-z0-9 ]+/, " ")), Regexp::IGNORECASE)
9
9
 
10
- if query.strip == ""
10
+ if msg.strip == ""
11
11
  reply "http://www.mahou.org/Showtime"
12
12
  else
13
13
  Net::HTTP.start("anime.yshi.org", 80) do |http|
@@ -21,10 +21,13 @@ define_plugin("!eta") do |msg|
21
21
  json = JSON.parse(resp.body)
22
22
  best, score = nil, 1_000
23
23
  json.each do |show|
24
- d = DamerauLevenshtein.distance(show["title_name"].downcase, query)
25
- if d < score
26
- best = show
27
- score = d
24
+ title = show["title_name"].downcase.gsub(/[^a-z0-9 ]+/, " ")
25
+ if title =~ query
26
+ d = DamerauLevenshtein.distance(show["title_name"].downcase, msg.downcase)
27
+ if d < score
28
+ best = show
29
+ score = d
30
+ end
28
31
  end
29
32
  end
30
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meimei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - r888888888