mitten 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -24
- data/Gemfile +4 -0
- data/LICENSE +5 -4
- data/README.markdown +53 -0
- data/Rakefile +19 -45
- data/VERSION +1 -1
- data/bin/mitten +7 -0
- data/configs/example_environment.yaml +6 -5
- data/example/{sample.rb → echo.rb} +8 -2
- data/lib/mitten.rb +7 -9
- data/lib/{plugin.rb → mitten/plugin.rb} +9 -4
- data/lib/{utils.rb → mitten/utils.rb} +3 -2
- data/lib/mitten/version.rb +3 -0
- data/mitten.gemspec +16 -92
- metadata +58 -151
- data/.document +0 -5
- data/README.rdoc +0 -81
- data/bin/client +0 -10
- data/bin/daemon +0 -8
- data/configs/time_call.yaml +0 -13
- data/configs/twitter_bot.yaml +0 -3
- data/plugins/amazon_search.rb +0 -62
- data/plugins/bmi.rb +0 -48
- data/plugins/codepad.rb +0 -63
- data/plugins/fortune.rb +0 -40
- data/plugins/gasoline.rb +0 -46
- data/plugins/gmail.rb +0 -64
- data/plugins/google_profile.rb +0 -37
- data/plugins/google_transit.rb +0 -56
- data/plugins/google_weather.rb +0 -34
- data/plugins/holoscope.rb +0 -63
- data/plugins/loo_holoscope.rb +0 -51
- data/plugins/mixi_voice.rb +0 -139
- data/plugins/nanapi.rb +0 -31
- data/plugins/newspaper_headlines.rb +0 -48
- data/plugins/openpne_new_diary_check.rb +0 -66
- data/plugins/ramen.rb +0 -33
- data/plugins/rate.rb +0 -31
- data/plugins/screen_time_search.rb +0 -96
- data/plugins/time_call.rb +0 -25
- data/plugins/tweet.rb +0 -32
- data/plugins/twitter_bot.rb +0 -32
- data/plugins/typhoon.rb +0 -37
- data/plugins/uri_shorten.rb +0 -23
- data/spec/mitten_spec.rb +0 -11
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -9
data/plugins/time_call.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
class TimeCall < Mitten::Plugin
|
5
|
-
def initialize(*args)
|
6
|
-
super
|
7
|
-
|
8
|
-
@config_file = @config['config']
|
9
|
-
end
|
10
|
-
|
11
|
-
def before_hook
|
12
|
-
@call_list = load_config
|
13
|
-
end
|
14
|
-
|
15
|
-
def load_config
|
16
|
-
OpenStruct.new(File.open(@config_file) { |f| YAML.load(f) }).time
|
17
|
-
end
|
18
|
-
|
19
|
-
def main
|
20
|
-
now = Time.now.strftime('%H%M').to_i
|
21
|
-
@channels.each do |channel|
|
22
|
-
notice(channel, @call_list[now]) if @call_list[now]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/plugins/tweet.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'nokogiri'
|
3
|
-
|
4
|
-
class Tweet < Mitten::Plugin
|
5
|
-
def initialize(*args)
|
6
|
-
super
|
7
|
-
|
8
|
-
@prefix = @config['prefix']
|
9
|
-
end
|
10
|
-
|
11
|
-
def on_privmsg(prefix, channel, message)
|
12
|
-
if /#{@config['prefix']}/ =~ message
|
13
|
-
user = $1
|
14
|
-
html = Nokogiri::HTML(open("http://twitter.com/#{user}").read)
|
15
|
-
|
16
|
-
tweet = (html/'.entry-content').first
|
17
|
-
if !tweet.nil?
|
18
|
-
tweet = "@#{user}: #{tweet.text}"
|
19
|
-
else
|
20
|
-
tweet = (html/'h1.logged-out').first
|
21
|
-
if tweet.nil?
|
22
|
-
tweet = 'いにゃい/(^o^)\'
|
23
|
-
else
|
24
|
-
tweet = tweet.text
|
25
|
-
end
|
26
|
-
end
|
27
|
-
notice(channel, tweet)
|
28
|
-
end
|
29
|
-
rescue
|
30
|
-
notice(channel, 'こわれたっ/(^o^)\')
|
31
|
-
end
|
32
|
-
end
|
data/plugins/twitter_bot.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
require 'yaml'
|
3
|
-
require 'open-uri'
|
4
|
-
require 'nokogiri'
|
5
|
-
|
6
|
-
class TwitterBot < Mitten::Plugin
|
7
|
-
def initialize(*args)
|
8
|
-
super
|
9
|
-
|
10
|
-
@config_file = @config['config']
|
11
|
-
@bot_list = load_config
|
12
|
-
end
|
13
|
-
|
14
|
-
def load_config
|
15
|
-
OpenStruct.new(File.open(@config_file) { |f| YAML.load(f) }).bot_list
|
16
|
-
end
|
17
|
-
|
18
|
-
def on_privmsg(prefix, channel, message)
|
19
|
-
@bot_list.each_key do |key|
|
20
|
-
notice(channel, get_tweet(@bot_list[key])) if message =~ Regexp.new(/#{key}(|?|\?)/)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def get_tweet(bot)
|
25
|
-
html = Nokogiri::HTML(open("http://twitter.com/#{bot}").read)
|
26
|
-
|
27
|
-
tweet = (html/'.entry-content').first
|
28
|
-
if !tweet.nil?
|
29
|
-
tweet = tweet.text
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/plugins/typhoon.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require "open-uri"
|
2
|
-
require 'nokogiri'
|
3
|
-
|
4
|
-
class Typhoon < Mitten::Plugin
|
5
|
-
def initialize(*args)
|
6
|
-
super
|
7
|
-
|
8
|
-
@uri = 'http://typhoon.yahoo.co.jp/weather/jp/typhoon/typha.html'
|
9
|
-
@prefix = @config['prefix'] || '台風どうなった'
|
10
|
-
end
|
11
|
-
|
12
|
-
def on_privmsg(prefix, channel, message)
|
13
|
-
case message
|
14
|
-
when /^#{@prefix}(.+|)/
|
15
|
-
get_typhoon_info.each { |message| notice(channel, message) }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def get_typhoon_info
|
22
|
-
begin
|
23
|
-
typhoon_info = []
|
24
|
-
doc = Nokogiri::HTML(open(@uri).read, nil, 'EUC-JP')/'tr[@valign="top"]'
|
25
|
-
|
26
|
-
(doc/'td[@widh="60%"]').each do |typhoon|
|
27
|
-
typhoon_name = typhoon.inner_html.scan(/<b>(.+)<\/b>/)
|
28
|
-
description = typhoon.inner_text.scan(/ (.+?)。/)
|
29
|
-
|
30
|
-
typhoon_info << "#{typhoon_name} #{description}".toutf8
|
31
|
-
end
|
32
|
-
typhoon_info << @uri
|
33
|
-
rescue
|
34
|
-
'/(^o^)\ こわれたっ'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/plugins/uri_shorten.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
class URIShorten < Mitten::Plugin
|
4
|
-
def initialize(*args)
|
5
|
-
super
|
6
|
-
|
7
|
-
@prefix = @config['prefix'] || 's'
|
8
|
-
end
|
9
|
-
|
10
|
-
def on_privmsg(prefix, channel, message)
|
11
|
-
case message
|
12
|
-
when /^#{@prefix} (http:\/\/.+?)$/
|
13
|
-
notice(channel, shorten($1))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def shorten(target)
|
20
|
-
uri = URI.escape("http://j.mp/?s=&keyword=&url=#{target}")
|
21
|
-
Nokogiri::HTML(open(uri).read).at('#shortened-url')['value']
|
22
|
-
end
|
23
|
-
end
|
data/spec/mitten_spec.rb
DELETED
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|