meimei 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/meimei.gemspec +1 -1
- data/plugins/eta.rb +9 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a0f3088857a15a27e46e3247ee18469011626cf
|
4
|
+
data.tar.gz: 403a278f19f0db750fb4c5db420140011e2fc2bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ba2aa536f6ec2636e843583c84163d1258e302e22c9508a316710d649bbbd75a0d27a7a25d23eeeddcce12690ae44f430b3b8dca6408d648a361f1459876de
|
7
|
+
data.tar.gz: bb872becb85c745f8a65412d952f1d734cadfa3451a209e59379405336e7afb2e06262429dd58120cd0d0d8105eaccf66e397e4469c10f953284542efac7a8ec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.1
|
data/meimei.gemspec
CHANGED
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
|
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
|
-
|
25
|
-
if
|
26
|
-
|
27
|
-
|
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
|
|