meimei 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +8 -0
- data/VERSION +1 -1
- data/meimei.gemspec +7 -2
- data/plugins/domo.rb +13 -0
- data/plugins/eta.rb +2 -0
- data/plugins/g.rb +6 -7
- data/plugins/gc.rb +33 -8
- data/plugins/reload.rb +1 -0
- data/plugins/weather.rb +31 -30
- data/plugins/yeeart.rb +10 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc878b66e5e93460cc7cd57452731f5ba8316744
|
4
|
+
data.tar.gz: c537ed11cf862d8ddfedc7e5d627c07f063aaad9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 146ff41a9820a2477e6b75fe4885d443ba7ad0b70fb565d91031fc63df23cacafc05cf0a5ba4b2b5aef9aa297f4897e6551be43e763f465aa5fb89f646939692
|
7
|
+
data.tar.gz: 3725e2c4a3624596dbd97099c510a604d59987b6f52fb5c1ea3419a59e5aa4f6db2e011e18a9309d11eabd8dc6ea4b63e3559291e26f91cebc5096a4479d1b89
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,6 +9,7 @@ GEM
|
|
9
9
|
tzinfo (~> 1.1)
|
10
10
|
addressable (2.3.8)
|
11
11
|
builder (3.2.2)
|
12
|
+
coderay (1.1.0)
|
12
13
|
damerau-levenshtein (1.1.0)
|
13
14
|
bundler (~> 1.7)
|
14
15
|
json (~> 1.8)
|
@@ -41,6 +42,7 @@ GEM
|
|
41
42
|
rdoc
|
42
43
|
json (1.8.2)
|
43
44
|
jwt (1.5.0)
|
45
|
+
method_source (0.8.2)
|
44
46
|
mini_portile (0.6.2)
|
45
47
|
minitest (5.7.0)
|
46
48
|
multi_json (1.11.0)
|
@@ -54,12 +56,17 @@ GEM
|
|
54
56
|
multi_json (~> 1.3)
|
55
57
|
multi_xml (~> 0.5)
|
56
58
|
rack (~> 1.2)
|
59
|
+
pry (0.10.1)
|
60
|
+
coderay (~> 1.1.0)
|
61
|
+
method_source (~> 0.8.1)
|
62
|
+
slop (~> 3.4)
|
57
63
|
rack (1.6.1)
|
58
64
|
rake (10.4.2)
|
59
65
|
rake-compiler (0.9.5)
|
60
66
|
rake
|
61
67
|
rdoc (4.2.0)
|
62
68
|
json (~> 1.4)
|
69
|
+
slop (3.6.0)
|
63
70
|
thread_safe (0.3.5)
|
64
71
|
time_difference (0.4.2)
|
65
72
|
activesupport
|
@@ -74,6 +81,7 @@ DEPENDENCIES
|
|
74
81
|
jeweler
|
75
82
|
json
|
76
83
|
nokogiri
|
84
|
+
pry
|
77
85
|
rake
|
78
86
|
rdoc
|
79
87
|
time_difference
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/meimei.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "meimei"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["r888888888"]
|
12
|
-
s.date = "2015-
|
12
|
+
s.date = "2015-09-21"
|
13
13
|
s.description = "If all you need is a simple infobot and don't need a full RFC1459 implementation."
|
14
14
|
s.email = "r888888888@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"plugins/courage.rb",
|
41
41
|
"plugins/dan.rb",
|
42
42
|
"plugins/dg.rb",
|
43
|
+
"plugins/domo.rb",
|
43
44
|
"plugins/dwiki.rb",
|
44
45
|
"plugins/eta.rb",
|
45
46
|
"plugins/g.rb",
|
@@ -67,6 +68,7 @@ Gem::Specification.new do |s|
|
|
67
68
|
"plugins/uptime.rb",
|
68
69
|
"plugins/wawawa.rb",
|
69
70
|
"plugins/weather.rb",
|
71
|
+
"plugins/yeeart.rb",
|
70
72
|
"test/helper.rb",
|
71
73
|
"test/test_meimei.rb"
|
72
74
|
]
|
@@ -87,6 +89,7 @@ Gem::Specification.new do |s|
|
|
87
89
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
88
90
|
s.add_runtime_dependency(%q<damerau-levenshtein>, [">= 0"])
|
89
91
|
s.add_runtime_dependency(%q<time_difference>, [">= 0"])
|
92
|
+
s.add_runtime_dependency(%q<pry>, [">= 0"])
|
90
93
|
else
|
91
94
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
92
95
|
s.add_dependency(%q<rake>, [">= 0"])
|
@@ -95,6 +98,7 @@ Gem::Specification.new do |s|
|
|
95
98
|
s.add_dependency(%q<json>, [">= 0"])
|
96
99
|
s.add_dependency(%q<damerau-levenshtein>, [">= 0"])
|
97
100
|
s.add_dependency(%q<time_difference>, [">= 0"])
|
101
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
98
102
|
end
|
99
103
|
else
|
100
104
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -104,6 +108,7 @@ Gem::Specification.new do |s|
|
|
104
108
|
s.add_dependency(%q<json>, [">= 0"])
|
105
109
|
s.add_dependency(%q<damerau-levenshtein>, [">= 0"])
|
106
110
|
s.add_dependency(%q<time_difference>, [">= 0"])
|
111
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
107
112
|
end
|
108
113
|
end
|
109
114
|
|
data/plugins/domo.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
define_plugin("domo") do |msg|
|
2
|
+
next unless msg =~ /\bdou?mo\b/i and msg =~ /\bdesu\b/i
|
3
|
+
|
4
|
+
if msg =~ /hajimemashite/i
|
5
|
+
reply "DOMO. HAJIMEMASHITE. MEIMEI DESU.", false
|
6
|
+
elsif msg =~ /meimei-san[.!]?\s+(.+?)\s+desu/i
|
7
|
+
reply "DOMO #{$1.upcase.strip}-SAN. MEIMEI DESU.", false
|
8
|
+
elsif msg =~ /dou?mo[.!]?\s+(.+?)\s+desu/i
|
9
|
+
reply "DOMO #{$1.upcase.strip}-SAN. MEIMEI DESU.", false
|
10
|
+
elsif msg =~ /meimei-san/i
|
11
|
+
reply "DOMO #{@current_from.upcase}-SAN. MEIMEI DESU.", false
|
12
|
+
end
|
13
|
+
end
|
data/plugins/eta.rb
CHANGED
data/plugins/g.rb
CHANGED
@@ -9,16 +9,15 @@ require "cgi"
|
|
9
9
|
|
10
10
|
define_plugin("!g") do |msg|
|
11
11
|
query = msg
|
12
|
+
api_key = "AIzaSyBbqMEONSx_cqrBhk0GXNbzZw_E3bNgNwQ"
|
12
13
|
|
13
|
-
if query
|
14
|
+
if query =~ /\S/
|
14
15
|
begin
|
15
|
-
Net::HTTP.start("
|
16
|
-
resp = http.get("/
|
16
|
+
Net::HTTP.start("www.googleapis.com", 443, :use_ssl => true) do |http|
|
17
|
+
resp = http.get("/customsearch/v1?cx=003806434433967703265:eltrj5arw88&key=#{api_key}&q=" + URI.escape(query, /./))
|
17
18
|
json = JSON.parse(resp.body)
|
18
|
-
|
19
|
-
|
20
|
-
reply answer
|
21
|
-
end
|
19
|
+
answer = json["items"][0]
|
20
|
+
reply "#{answer['title']} -> #{answer['link']}"
|
22
21
|
end
|
23
22
|
rescue Timeout
|
24
23
|
reply "timeout"
|
data/plugins/gc.rb
CHANGED
@@ -6,26 +6,51 @@ require "uri"
|
|
6
6
|
require "json"
|
7
7
|
require "timeout"
|
8
8
|
require "cgi"
|
9
|
+
require "nokogiri"
|
10
|
+
require "pry"
|
9
11
|
|
10
12
|
define_plugin("!gc") do |msg|
|
11
13
|
app = "meimei"
|
12
14
|
app_id = "WQJUTR-EXQT7VL45T"
|
13
|
-
|
15
|
+
assumption = nil
|
16
|
+
|
17
|
+
if msg =~ /\bassume (\S+)/
|
18
|
+
assumption = $1
|
19
|
+
msg = msg.sub(/\bassume \S+/, "").strip
|
20
|
+
end
|
21
|
+
|
22
|
+
url = URI.parse("http://api.wolframalpha.com/v2/query?input=#{CGI.escape(msg)}&appid=#{app_id}&format=plaintext&excludepodid=Input&assumption=#{assumption}")
|
14
23
|
|
15
24
|
begin
|
16
25
|
Net::HTTP.start(url.host, url.port) do |http|
|
17
26
|
resp = http.get(url.request_uri).body
|
27
|
+
doc = Nokogiri::XML(resp)
|
28
|
+
answers = []
|
29
|
+
|
30
|
+
doc.css("pod[error='false'] plaintext").each do |plaintext|
|
31
|
+
answers << plaintext.inner_html.strip
|
32
|
+
end
|
18
33
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
reply "#{msg} -> #{answer}"
|
34
|
+
answers.reject! {|x| x.empty?}
|
35
|
+
|
36
|
+
if answers.any?
|
37
|
+
answer_text = answers.first.slice(0, 450)
|
38
|
+
reply "#{msg} -> #{answer_text}"
|
25
39
|
else
|
26
|
-
reply "
|
40
|
+
reply "I don't know"
|
27
41
|
end
|
28
42
|
end
|
43
|
+
|
44
|
+
if answers.empty?
|
45
|
+
if assumption.nil? && doc.css("assumption").any?
|
46
|
+
descs = doc.css("assumption value").map {|x| "#{msg} assume #{x.attr('input')}"}
|
47
|
+
reply "try also: " + descs.join(", ").slice(0, 450)
|
48
|
+
elsif doc.css("didyoumean").any?
|
49
|
+
descs = doc.css("didyoumean").map {|x| x.inner_html.strip}
|
50
|
+
reply "did you mean: " + descs.join(", ").slice(0, 450)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
29
54
|
rescue Timeout
|
30
55
|
reply "timeout"
|
31
56
|
rescue Exception => e
|
data/plugins/reload.rb
CHANGED
data/plugins/weather.rb
CHANGED
@@ -1,39 +1,40 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
if query.any?
|
5
|
-
begin
|
6
|
-
Net::HTTP.start("www.google.com", 80) do |http|
|
7
|
-
resp = http.get("/search?num=1&q=weather+for+" + URI.escape(query, /[^a-zA-Z0-9]/))
|
8
|
-
if resp.body =~ /<table class="ts std">.+?<b>Weather<\/b> for <b>(.+?)<\/b>/m
|
9
|
-
|
10
|
-
result = "Weather for " + $1 + ": "
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
11
3
|
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
define_plugin("!w") do |msg|
|
5
|
+
api_key = "37f18195cbd147d0"
|
6
|
+
query = msg
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
begin
|
9
|
+
Net::HTTP.start("api.wunderground.com", 80) do |http|
|
10
|
+
param = nil
|
19
11
|
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
if msg =~ /^\d+$/
|
13
|
+
param = "#{msg}"
|
14
|
+
elsif msg =~ /,/
|
15
|
+
city, country = msg.split(/,/)
|
16
|
+
param = "#{country.strip}/#{city.strip}".gsub(" ", "_")
|
17
|
+
else
|
18
|
+
param = msg.gsub(" ", "_")
|
19
|
+
end
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
21
|
+
resp = http.get("/api/#{api_key}/conditions/q/#{param}.json")
|
22
|
+
json = JSON.parse(resp.body)
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
if json["current_observation"].nil?
|
25
|
+
reply "Unknown location. Usage: !w [us zip code | city, state | city, country]"
|
26
|
+
else
|
27
|
+
location = json["current_observation"]["display_location"]["full"]
|
28
|
+
temperature = json["current_observation"]["temperature_string"]
|
29
|
+
weather = json["current_observation"]["weather"]
|
30
|
+
humidty = json["current_observation"]["relative_humidity"]
|
31
|
+
response = "#{location}: #{temperature} - #{weather} - #{humidty} Humidity"
|
32
|
+
reply response
|
32
33
|
end
|
33
|
-
rescue Timeout
|
34
|
-
reply "timeout"
|
35
|
-
rescue Exception => e
|
36
|
-
reply e.to_s
|
37
34
|
end
|
35
|
+
rescue Timeout
|
36
|
+
reply "timeout"
|
37
|
+
rescue Exception => e
|
38
|
+
reply e.to_s
|
38
39
|
end
|
39
40
|
end
|
data/plugins/yeeart.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
define_plugin("yeeart") do |msg|
|
2
|
+
next unless msg =~ /\b(y+)(ee+)(a+)(r+)(t+)\b/i
|
3
|
+
ys = [$1.size, 50].min
|
4
|
+
es = [$2.size, 300].min
|
5
|
+
as = [$3.size, 50].min
|
6
|
+
rs = [$4.size, 50].min
|
7
|
+
ts = [$5.size, 50].min
|
8
|
+
resp = ("Y" * (ys + 1)) + ("E" * (es + 1)) + ("A" * (as + 1)) + ("R" * (rs + 1)) + ("T" * (ts + 1)) + "!"
|
9
|
+
reply resp
|
10
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meimei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- r888888888
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeweler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
description: If all you need is a simple infobot and don't need a full RFC1459 implementation.
|
112
126
|
email: r888888888@gmail.com
|
113
127
|
executables: []
|
@@ -139,6 +153,7 @@ files:
|
|
139
153
|
- plugins/courage.rb
|
140
154
|
- plugins/dan.rb
|
141
155
|
- plugins/dg.rb
|
156
|
+
- plugins/domo.rb
|
142
157
|
- plugins/dwiki.rb
|
143
158
|
- plugins/eta.rb
|
144
159
|
- plugins/g.rb
|
@@ -166,6 +181,7 @@ files:
|
|
166
181
|
- plugins/uptime.rb
|
167
182
|
- plugins/wawawa.rb
|
168
183
|
- plugins/weather.rb
|
184
|
+
- plugins/yeeart.rb
|
169
185
|
- test/helper.rb
|
170
186
|
- test/test_meimei.rb
|
171
187
|
homepage: http://github.com/r888888888/meimei
|