mitten 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- 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/.gitignore
CHANGED
@@ -1,25 +1,6 @@
|
|
1
|
+
*.gem
|
2
|
+
.bundle
|
3
|
+
Gemfile.lock
|
4
|
+
pkg/*
|
1
5
|
/configs/environment.yaml
|
2
|
-
|
3
|
-
/amazonrc
|
4
|
-
|
5
|
-
## MAC OS
|
6
|
-
.DS_Store
|
7
|
-
|
8
|
-
## TEXTMATE
|
9
|
-
*.tmproj
|
10
|
-
tmtags
|
11
|
-
|
12
|
-
## EMACS
|
13
|
-
*~
|
14
|
-
\#*
|
15
|
-
.\#*
|
16
|
-
|
17
|
-
## VIM
|
18
|
-
*.swp
|
19
|
-
|
20
|
-
## PROJECT::GENERAL
|
21
|
-
coverage
|
22
|
-
rdoc
|
23
|
-
pkg
|
24
|
-
|
25
|
-
## PROJECT::SPECIFIC
|
6
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MAHALO License (based on MIT License) by Wataru, MIYAGUNI
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2011 Tomohiro, TAIRA
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -9,8 +9,9 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
10
10
|
furnished to do so, subject to the following conditions:
|
11
11
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
12
|
+
1. The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
2. Shall be grateful for something (including, but not limited this software).
|
14
15
|
|
15
16
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
17
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
data/README.markdown
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
Mitten [![Still Maintained](http://stillmaintained.com/Tomohiro/mitten.png)](http://stillmaintained.com/Tomohiro/mitten)
|
2
|
+
================================================================================
|
3
|
+
|
4
|
+
|
5
|
+
Overview
|
6
|
+
-------------------------------------------------------------------------------
|
7
|
+
|
8
|
+
### What's this?
|
9
|
+
|
10
|
+
Mitten is A Ruby IRC Bot Pluggable Framework.
|
11
|
+
|
12
|
+
|
13
|
+
Installation
|
14
|
+
-------------------------------------------------------------------------------
|
15
|
+
|
16
|
+
### RubyGems
|
17
|
+
|
18
|
+
$ sudo gem install mitten
|
19
|
+
|
20
|
+
### GitHub
|
21
|
+
|
22
|
+
$ git clone http://github.com/Tomohiro/mitten.git
|
23
|
+
|
24
|
+
|
25
|
+
How to use
|
26
|
+
-------------------------------------------------------------------------------
|
27
|
+
|
28
|
+
TODO
|
29
|
+
|
30
|
+
|
31
|
+
Note on Patches/Pull Requests
|
32
|
+
-------------------------------------------------------------------------------
|
33
|
+
|
34
|
+
- Fork the project.
|
35
|
+
- Make your feature addition or bug fix.
|
36
|
+
- Add tests for it. This is important so I don't break it in a
|
37
|
+
future version unintentionally.
|
38
|
+
- Commit, do not mess with rakefile, version, or history.
|
39
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
40
|
+
- Send me a pull request. Bonus points for topic branches.
|
41
|
+
|
42
|
+
|
43
|
+
Author
|
44
|
+
-------------------------------------------------------------------------------
|
45
|
+
|
46
|
+
Tomohiro, TAIRA [@Tomohiro](http://twitter.com/Tomohiro)
|
47
|
+
|
48
|
+
|
49
|
+
LICENSE
|
50
|
+
-------------------------------------------------------------------------------
|
51
|
+
|
52
|
+
This project is dual licensed under the MAHALO license or GPL Version 2 licenses.
|
53
|
+
See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,50 +1,24 @@
|
|
1
|
-
require '
|
2
|
-
require 'rake'
|
1
|
+
require 'rake/clean'
|
3
2
|
|
4
|
-
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = 'mitten'
|
8
|
-
gem.summary = 'IRC Bot Framework'
|
9
|
-
gem.description = 'Mitten is A Ruby IRC Bot Pluggable Framework'
|
10
|
-
gem.email = 'tomohiro.t@gmail.com'
|
11
|
-
gem.homepage = 'http://rubygems.org/gems/mitten'
|
12
|
-
gem.authors = ['Tomohiro, TAIRA']
|
13
|
-
gem.add_dependency 'net-irc', '>= 0.0.9'
|
14
|
-
gem.add_dependency 'daemons', '>= 1.0.10'
|
15
|
-
gem.add_dependency 'json_pure', '>= 1.2.0'
|
16
|
-
gem.add_development_dependency 'rspec', '>= 1.2.9'
|
17
|
-
gem.add_development_dependency 'rake', '>= 0.8.7'
|
18
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
-
end
|
20
|
-
Jeweler::GemcutterTasks.new
|
21
|
-
rescue LoadError
|
22
|
-
puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
|
23
|
-
end
|
24
|
-
|
25
|
-
require 'spec/rake/spectask'
|
26
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
27
|
-
spec.libs << 'lib' << 'spec'
|
28
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
29
|
-
end
|
3
|
+
#CLEAN.include('config/test.yml', 'tmp', 'log', '/tmp/rig_issues.*')
|
30
4
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
5
|
+
namespace :mitten do
|
6
|
+
namespace :development do
|
7
|
+
desc 'Setup development environments'
|
8
|
+
task :setup do
|
9
|
+
sh 'rvm use 1.9.3'
|
10
|
+
sh 'rvm gemset create mitten'
|
11
|
+
sh 'rvm gemset use mitten'
|
12
|
+
sh 'gem install bundler'
|
13
|
+
sh 'gem list'
|
14
|
+
sh 'bundle install --system'
|
15
|
+
sh 'bundle show'
|
16
|
+
end
|
17
|
+
end
|
35
18
|
end
|
36
19
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
require 'rake/rdoctask'
|
42
|
-
Rake::RDocTask.new do |rdoc|
|
43
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
-
|
45
|
-
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "mitten #{version}"
|
47
|
-
rdoc.rdoc_files.include('README*')
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
rdoc.options = ['-c', 'utf-8', '-N']
|
20
|
+
begin
|
21
|
+
require 'bundler/gem_tasks'
|
22
|
+
rescue LoadError
|
23
|
+
abort 'NOTE: Run `$ rake mitten:development:setup`'
|
50
24
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/bin/mitten
ADDED
@@ -10,19 +10,20 @@ production:
|
|
10
10
|
plugin_dir: example # normal => plugins
|
11
11
|
charset:
|
12
12
|
default: utf-8
|
13
|
-
|
13
|
+
|
14
14
|
development:
|
15
|
-
host:
|
15
|
+
host: my.irc.server.example.com
|
16
16
|
port: 6667
|
17
17
|
user: Mitten
|
18
18
|
nick: Mitten
|
19
19
|
real: Mitten is IRC Bot Framework
|
20
20
|
pass:
|
21
21
|
channel: '#Mitten'
|
22
|
-
plugin_dir:
|
22
|
+
plugin_dir: plugins
|
23
23
|
charset:
|
24
24
|
default: utf-8
|
25
|
-
|
25
|
+
|
26
26
|
plugins:
|
27
|
-
|
27
|
+
Echo:
|
28
28
|
channel: '#Mitten'
|
29
|
+
sleep: 10
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Echo < Mitten::Plugin
|
4
|
+
|
2
5
|
def initialize(*args)
|
3
6
|
super
|
4
7
|
end
|
@@ -8,6 +11,9 @@ class Sample < Mitten::Plugin
|
|
8
11
|
end
|
9
12
|
|
10
13
|
def main
|
11
|
-
@channels.each
|
14
|
+
@channels.each do |channel|
|
15
|
+
notice(channel, Time.now.to_s)
|
16
|
+
end
|
12
17
|
end
|
18
|
+
|
13
19
|
end
|
data/lib/mitten.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
$KCODE = 'u'
|
1
|
+
# encoding:utf-8
|
4
2
|
|
5
3
|
require 'ostruct'
|
6
4
|
require 'yaml'
|
@@ -10,8 +8,9 @@ require 'pathname'
|
|
10
8
|
require 'rubygems'
|
11
9
|
require 'net/irc'
|
12
10
|
|
13
|
-
require '
|
14
|
-
require '
|
11
|
+
require 'mitten/version'
|
12
|
+
require 'mitten/utils'
|
13
|
+
require 'mitten/plugin'
|
15
14
|
|
16
15
|
module Mitten
|
17
16
|
DEFAULT_CONFIG_FILE_PATH = 'configs/environment.yaml'
|
@@ -102,21 +101,20 @@ module Mitten
|
|
102
101
|
Pathname.glob("#{plugin_dir}/*.rb") do |file|
|
103
102
|
plugin = {}
|
104
103
|
m = Module.new
|
105
|
-
m.module_eval(file.read, file)
|
104
|
+
m.module_eval(file.read, file.to_s)
|
106
105
|
m.constants.each do |name|
|
107
|
-
break unless plugin_configs.has_key? name
|
106
|
+
break unless plugin_configs.has_key? name.to_s
|
108
107
|
const = m.const_get(name)
|
109
108
|
if const.is_a? Class
|
110
109
|
plugin[name] = {
|
111
110
|
:class => const,
|
112
111
|
:file => file,
|
113
|
-
:configs => plugin_configs[name]
|
112
|
+
:configs => plugin_configs[name.to_s]
|
114
113
|
}
|
115
114
|
end
|
116
115
|
end
|
117
116
|
class_tables.update(plugin)
|
118
117
|
end
|
119
|
-
|
120
118
|
plugins = instantiation(class_tables)
|
121
119
|
instance_categorize(plugins)
|
122
120
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'net/irc'
|
1
|
+
# encoding:utf-8
|
3
2
|
|
4
3
|
module Mitten
|
5
4
|
DEFAULT_SLEEP = 360
|
@@ -12,10 +11,14 @@ module Mitten
|
|
12
11
|
@config = config || {}
|
13
12
|
@server = server
|
14
13
|
@socket = socket
|
15
|
-
@channels = @config['channels'] || @config['channel'] || @server.channel
|
14
|
+
@channels = @config['channels'] || (@config['channel'] || [@server.channel])
|
16
15
|
@sleep = @config['sleep'] || DEFAULT_SLEEP
|
17
16
|
end
|
18
17
|
|
18
|
+
def before_hook
|
19
|
+
# Do something
|
20
|
+
end
|
21
|
+
|
19
22
|
def post(command, *args)
|
20
23
|
@socket << Message.new(nil, command, args.map { |s| s.gsub(/\r|\n/, " ") })
|
21
24
|
end
|
@@ -39,12 +42,14 @@ module Mitten
|
|
39
42
|
def notify
|
40
43
|
begin
|
41
44
|
loop do
|
42
|
-
|
45
|
+
p @sleep
|
43
46
|
sleep @sleep
|
47
|
+
main
|
44
48
|
end
|
45
49
|
rescue Exception => e
|
46
50
|
post(NOTICE, @server.channel, "#{e.class} #{e.to_s}") if @server.channel
|
47
51
|
end
|
48
52
|
end
|
53
|
+
|
49
54
|
end
|
50
55
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# encoding:utf-8
|
2
|
+
|
2
3
|
require 'open-uri'
|
3
4
|
require 'json'
|
4
5
|
|
@@ -9,7 +10,7 @@ module URI
|
|
9
10
|
def self.short(uri)
|
10
11
|
return uri if SHORT_URI_API_LOGIN == nil
|
11
12
|
begin
|
12
|
-
query = "http://api.
|
13
|
+
query = "http://api.bit.ly/v3/shorten?version=2.0.1&longUrl=#{uri.gsub('&', '%26')}&login=#{SHORT_URI_API_LOGIN}&apiKey=#{SHORT_URI_API_TOKEN}"
|
13
14
|
result = JSON.parse(open(query).read)
|
14
15
|
|
15
16
|
result.first[1].first[1]['shortUrl']
|
data/mitten.gemspec
CHANGED
@@ -1,99 +1,23 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'mitten/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = 'mitten'
|
7
|
+
s.version = Mitten::VERSION
|
8
|
+
s.authors = ['Tomohiro, TAIRA']
|
9
|
+
s.email = ['tomohiro.t@gmail.com']
|
10
|
+
s.homepage = 'http://github.com/Tomohiro/mittenn'
|
11
|
+
s.summary = %q{Mitten}
|
13
12
|
s.description = %q{Mitten is A Ruby IRC Bot Pluggable Framework}
|
14
|
-
s.email = %q{tomohiro.t@gmail.com}
|
15
|
-
s.executables = ["daemon", "client"]
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
"LICENSE",
|
18
|
-
"README.rdoc"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".document",
|
22
|
-
".gitignore",
|
23
|
-
"LICENSE",
|
24
|
-
"README.rdoc",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"bin/client",
|
28
|
-
"bin/daemon",
|
29
|
-
"configs/example_environment.yaml",
|
30
|
-
"configs/time_call.yaml",
|
31
|
-
"configs/twitter_bot.yaml",
|
32
|
-
"example/sample.rb",
|
33
|
-
"lib/mitten.rb",
|
34
|
-
"lib/plugin.rb",
|
35
|
-
"lib/utils.rb",
|
36
|
-
"mitten.gemspec",
|
37
|
-
"plugins/amazon_search.rb",
|
38
|
-
"plugins/bmi.rb",
|
39
|
-
"plugins/codepad.rb",
|
40
|
-
"plugins/fortune.rb",
|
41
|
-
"plugins/gasoline.rb",
|
42
|
-
"plugins/gmail.rb",
|
43
|
-
"plugins/google_profile.rb",
|
44
|
-
"plugins/google_transit.rb",
|
45
|
-
"plugins/google_weather.rb",
|
46
|
-
"plugins/holoscope.rb",
|
47
|
-
"plugins/loo_holoscope.rb",
|
48
|
-
"plugins/mixi_voice.rb",
|
49
|
-
"plugins/nanapi.rb",
|
50
|
-
"plugins/newspaper_headlines.rb",
|
51
|
-
"plugins/openpne_new_diary_check.rb",
|
52
|
-
"plugins/ramen.rb",
|
53
|
-
"plugins/rate.rb",
|
54
|
-
"plugins/screen_time_search.rb",
|
55
|
-
"plugins/time_call.rb",
|
56
|
-
"plugins/tweet.rb",
|
57
|
-
"plugins/twitter_bot.rb",
|
58
|
-
"plugins/typhoon.rb",
|
59
|
-
"plugins/uri_shorten.rb",
|
60
|
-
"spec/mitten_spec.rb",
|
61
|
-
"spec/spec.opts",
|
62
|
-
"spec/spec_helper.rb"
|
63
|
-
]
|
64
|
-
s.homepage = %q{http://rubygems.org/gems/mitten}
|
65
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
66
|
-
s.require_paths = ["lib"]
|
67
|
-
s.rubygems_version = %q{1.3.6}
|
68
|
-
s.summary = %q{IRC Bot Framework}
|
69
|
-
s.test_files = [
|
70
|
-
"spec/spec_helper.rb",
|
71
|
-
"spec/mitten_spec.rb"
|
72
|
-
]
|
73
13
|
|
74
|
-
|
75
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
76
|
-
s.specification_version = 3
|
14
|
+
s.rubyforge_project = 'mitten'
|
77
15
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
83
|
-
s.add_development_dependency(%q<rake>, [">= 0.8.7"])
|
84
|
-
else
|
85
|
-
s.add_dependency(%q<net-irc>, [">= 0.0.9"])
|
86
|
-
s.add_dependency(%q<daemons>, [">= 1.0.10"])
|
87
|
-
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
88
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
89
|
-
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
90
|
-
end
|
91
|
-
else
|
92
|
-
s.add_dependency(%q<net-irc>, [">= 0.0.9"])
|
93
|
-
s.add_dependency(%q<daemons>, [">= 1.0.10"])
|
94
|
-
s.add_dependency(%q<json_pure>, [">= 1.2.0"])
|
95
|
-
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
96
|
-
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
97
|
-
end
|
98
|
-
end
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
99
20
|
|
21
|
+
s.add_development_dependency 'rake'
|
22
|
+
s.add_runtime_dependency 'net-irc'
|
23
|
+
end
|