campfire-bot 0.1.0 → 1.0.0
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 +1 -1
- data/Gemfile +6 -1
- data/README.textile +15 -5
- data/bin/campfire-bot +52 -6
- data/campfire-bot.gemspec +4 -7
- data/config.example.yml +3 -2
- data/lib/bot.rb +26 -26
- data/lib/version.rb +1 -1
- metadata +22 -96
- data/CHANGELOG.md +0 -10
- data/Gemfile.lock +0 -58
- data/plugins/accountability.rb +0 -45
- data/plugins/austin.rb +0 -29
- data/plugins/basecamp.rb +0 -48
- data/plugins/beer.rb +0 -214
- data/plugins/beijing_tally.rb +0 -30
- data/plugins/boop.rb +0 -127
- data/plugins/bruce.rb +0 -15
- data/plugins/bugzilla.rb +0 -198
- data/plugins/calvin.rb +0 -43
- data/plugins/chuck.rb +0 -23
- data/plugins/dilbert.rb +0 -51
- data/plugins/excuse.rb +0 -478
- data/plugins/fail.rb +0 -16
- data/plugins/figlet.rb +0 -10
- data/plugins/fun.rb +0 -95
- data/plugins/garfield.rb +0 -43
- data/plugins/generic_search.rb +0 -66
- data/plugins/help.rb +0 -13
- data/plugins/infobot.rb +0 -58
- data/plugins/insult.rb +0 -87
- data/plugins/jira.rb +0 -197
- data/plugins/lolcats.rb +0 -17
- data/plugins/our_quotes.rb +0 -195
- data/plugins/quote.rb +0 -31
- data/plugins/schneier.rb +0 -28
- data/plugins/seen.rb +0 -88
- data/plugins/signal_filter.rb +0 -9
- data/plugins/svn.rb +0 -167
- data/plugins/twitter_echo.rb +0 -54
- data/plugins/unfuddle.rb +0 -69
- data/plugins/weather.rb +0 -25
- data/plugins/xkcd.rb +0 -43
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.textile
CHANGED
@@ -8,15 +8,26 @@ h2. Installation
|
|
8
8
|
|
9
9
|
@gem install campfire-bot@
|
10
10
|
|
11
|
+
h3. Download
|
12
|
+
|
13
|
+
Download the source from "github":http://github.com/joshwand/campfire-bot
|
14
|
+
|
15
|
+
|
11
16
|
h3. Configuration
|
12
17
|
|
13
|
-
Create a @config.yml@ in the
|
18
|
+
Create a @config.yml@ in the root of the source directory. Use @config.example.yml@ as an example.
|
14
19
|
|
15
20
|
h2. Usage
|
16
21
|
|
17
|
-
To run the bot, run @campfire-bot@ with the
|
22
|
+
To run the bot, run @campfire-bot@ with the following parameters:
|
23
|
+
|
24
|
+
-c config FILE path to config file
|
25
|
+
-e ENVIRONMENT_NAME environment name to load from config file
|
26
|
+
-p plugin PLUGIN_PATH path to your plugins
|
27
|
+
|
28
|
+
Example:
|
18
29
|
|
19
|
-
|
30
|
+
@campfire-bot -c config.yml -e production -p ./plugins@
|
20
31
|
|
21
32
|
h2. Known issues
|
22
33
|
|
@@ -41,5 +52,4 @@ h3. Contributors
|
|
41
52
|
* Marcel M. Cary - "github":http://github.com/mcary
|
42
53
|
* Hugh Evans - "github":http://github.com/artpop
|
43
54
|
* Sean O'Dowd - "github":http://github.com/seanodowd
|
44
|
-
* Andrew Erickson - "github":http://github.com/aerickson
|
45
|
-
* Chad Boyd - "github":http://github.com/hoverlover
|
55
|
+
* Andrew Erickson - "github":http://github.com/aerickson
|
data/bin/campfire-bot
CHANGED
@@ -1,13 +1,59 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Run this script with the environment as the only argument. eg. ./script/
|
4
|
-
BOT_ENVIRONMENT = ARGV.first
|
5
|
-
BOT_ROOT =
|
3
|
+
# Run this script with the environment as the only argument. eg. ./script/bot development
|
4
|
+
# BOT_ENVIRONMENT = ARGV.first
|
5
|
+
# BOT_ROOT = File.join(File.dirname(__FILE__), '..')
|
6
6
|
|
7
7
|
require 'rubygems'
|
8
|
-
require 'bundler/setup'
|
8
|
+
# require 'bundler/setup'
|
9
|
+
require 'optparse'
|
9
10
|
require 'bot'
|
11
|
+
# require File.join(BOT_ROOT, 'lib', 'bot')
|
12
|
+
|
13
|
+
|
14
|
+
options = {}
|
15
|
+
|
16
|
+
|
17
|
+
begin
|
18
|
+
optparse = OptionParser.new do |opts|
|
19
|
+
opts.banner = "Usage: campfire-bot [options]"
|
20
|
+
|
21
|
+
opts.on("-cCONFIG_FILE", "--config CONFIG_FILE", "path to your config file") do |config|
|
22
|
+
options[:config_file] = config
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("-eENVIRONMENT", "--environment ENVIRONMENT", "the environment name as specified in the config file") do |env|
|
26
|
+
options[:env] = env
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on( "-pPLUGIN_PATH", "--plugin_path PLUGIN_PATH",
|
30
|
+
"path to your plugins folder" ) do |pp|
|
31
|
+
options[:plugin_path] = pp
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on_tail("-h", "--help", "prints this help text") do
|
35
|
+
p opts
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
optparse.parse!
|
41
|
+
|
42
|
+
mandatory = [:config_file, :env, :plugin_path]
|
43
|
+
missing = mandatory.select{ |param| options[param].nil? }
|
44
|
+
if not missing.empty?
|
45
|
+
puts "Missing options: #{missing.join(', ')}"
|
46
|
+
puts optparse
|
47
|
+
exit
|
48
|
+
end
|
49
|
+
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
50
|
+
puts $!.to_s
|
51
|
+
puts optparse
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
bot.create(options[:config_file], options[:env], options[:plugin_path])
|
10
57
|
|
11
|
-
bot = CampfireBot::Bot.instance
|
12
58
|
bot.connect
|
13
|
-
bot.run
|
59
|
+
bot.run
|
data/campfire-bot.gemspec
CHANGED
@@ -5,8 +5,8 @@ require "version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "campfire-bot"
|
7
7
|
s.version = CampfireBot::VERSION
|
8
|
-
s.authors = ["Josh Wand", "
|
9
|
-
s.email = ["
|
8
|
+
s.authors = ["Josh Wand", "Tim Riley"]
|
9
|
+
s.email = ["josh@joshwand.com"]
|
10
10
|
s.homepage = "https://github.com/joshwand/campfire-bot"
|
11
11
|
s.summary = %q{This is a bot for 37 Signals’ Campfire chat service.}
|
12
12
|
s.description = s.summary
|
@@ -14,14 +14,11 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
-
s.require_paths = ["lib"
|
17
|
+
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
s.add_dependency 'twitter-stream', '~> 0.1'
|
20
20
|
s.add_dependency 'tinder', '>= 1.4.3'
|
21
|
-
s.add_dependency '
|
22
|
-
s.add_dependency 'mime-types', '~> 1.16'
|
23
|
-
s.add_dependency 'activesupport', '~> 3.1.3'
|
21
|
+
s.add_dependency 'activesupport', '~> 3.0.3'
|
24
22
|
s.add_dependency 'logging', '~> 1.4.3'
|
25
|
-
s.add_dependency 'eventmachine', '~> 0.12.10'
|
26
23
|
s.add_dependency 'i18n', '~> 0.5.0'
|
27
24
|
end
|
data/config.example.yml
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
development:
|
2
2
|
site: campfire_subdomain_name
|
3
3
|
use_ssl: true
|
4
|
-
log_dir: var
|
5
4
|
rooms:
|
6
5
|
- Main room
|
7
|
-
-
|
6
|
+
- Other room
|
8
7
|
api_key: your_api_key
|
9
8
|
nickname: Bot
|
10
9
|
fullname: Bot Name
|
@@ -29,3 +28,5 @@ production:
|
|
29
28
|
- basecamp
|
30
29
|
svn_urls:
|
31
30
|
- http://your.svn/url/
|
31
|
+
svn_username: your_svn_username
|
32
|
+
svn_password: your_svn_password
|
data/lib/bot.rb
CHANGED
@@ -7,43 +7,47 @@ require 'yaml'
|
|
7
7
|
require 'eventmachine'
|
8
8
|
require 'logging'
|
9
9
|
require 'fileutils'
|
10
|
-
|
10
|
+
|
11
|
+
# Local Libs
|
12
|
+
require "message"
|
13
|
+
require "event"
|
14
|
+
require "plugin"
|
15
|
+
|
11
16
|
require 'tinder'
|
12
17
|
|
13
18
|
module CampfireBot
|
14
|
-
autoload :Plugin, 'plugin'
|
15
|
-
autoload :Event, 'event'
|
16
|
-
autoload :Message, 'message'
|
17
|
-
|
18
19
|
class Bot
|
19
20
|
# this is necessary so the room and campfire objects can be accessed by plugins.
|
20
21
|
include Singleton
|
21
22
|
|
22
23
|
# FIXME - these will be invalid if disconnected. handle this.
|
23
|
-
attr_reader :campfire, :rooms, :config, :log
|
24
|
-
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@timeouts = 0
|
31
|
-
@config = YAML::load(ERB.new(File.read("#{BOT_ROOT}/config.yml")).result)[BOT_ENVIRONMENT]
|
32
|
-
@rooms = {}
|
24
|
+
attr_reader :campfire, :rooms, :config, :log, :environment_name
|
25
|
+
|
26
|
+
def create(config_file, environment_name, plugin_path)
|
27
|
+
@config = YAML::load(File.read(config_file))[environment_name]
|
28
|
+
@plugin_path = plugin_path
|
29
|
+
@environment_name = environment_name
|
30
|
+
|
33
31
|
@root_logger = Logging.logger["CampfireBot"]
|
34
32
|
@log = Logging.logger[self]
|
35
|
-
|
36
|
-
log_dir = @config['log_dir']
|
37
|
-
Dir.mkdir(log_dir) unless Dir.exists? log_dir
|
38
|
-
|
33
|
+
|
39
34
|
# TODO much of this should be configurable per environment
|
40
|
-
|
35
|
+
|
36
|
+
@root_logger.add_appenders Logging.appenders.rolling_file("#{@environment_name}.log",
|
41
37
|
:layout => Logging.layouts.pattern(:pattern => "%d | %-6l | %-12c | %m\n"),
|
42
38
|
:age => 'daily',
|
43
39
|
:keep => 7)
|
44
40
|
@root_logger.level = @config['log_level'] rescue :info
|
41
|
+
|
42
|
+
@timeouts = 0
|
43
|
+
|
44
|
+
@rooms = {}
|
45
|
+
|
45
46
|
end
|
46
47
|
|
48
|
+
# def initialize
|
49
|
+
# end
|
50
|
+
|
47
51
|
def connect
|
48
52
|
load_plugins unless !@config['enable_plugins']
|
49
53
|
begin
|
@@ -60,8 +64,7 @@ module CampfireBot
|
|
60
64
|
def run(interval = 5)
|
61
65
|
catch(:stop_listening) do
|
62
66
|
trap('INT') { throw :stop_listening }
|
63
|
-
|
64
|
-
|
67
|
+
|
65
68
|
# since room#listen blocks, stick it in its own thread
|
66
69
|
@rooms.each_pair do |room_name, room|
|
67
70
|
Thread.new do
|
@@ -119,9 +122,6 @@ module CampfireBot
|
|
119
122
|
end
|
120
123
|
end
|
121
124
|
end
|
122
|
-
|
123
|
-
# Leave the room so users won't be under the false impression that the bot is still running.
|
124
|
-
@rooms.each_value.map(&:leave)
|
125
125
|
end
|
126
126
|
|
127
127
|
private
|
@@ -143,7 +143,7 @@ module CampfireBot
|
|
143
143
|
|
144
144
|
def load_plugins
|
145
145
|
@config['enable_plugins'].each do |plugin_name|
|
146
|
-
|
146
|
+
load "#{@plugin_path}/#{plugin_name}.rb"
|
147
147
|
end
|
148
148
|
|
149
149
|
# And instantiate them
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: campfire-bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
|
-
- 0
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Josh Wand
|
13
|
-
-
|
14
|
+
- Tim Riley
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
19
|
+
date: 2012-02-16 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: twitter-stream
|
@@ -26,6 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
29
30
|
segments:
|
30
31
|
- 0
|
31
32
|
- 1
|
@@ -40,6 +41,7 @@ dependencies:
|
|
40
41
|
requirements:
|
41
42
|
- - ">="
|
42
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 1
|
43
45
|
segments:
|
44
46
|
- 1
|
45
47
|
- 4
|
@@ -48,98 +50,56 @@ dependencies:
|
|
48
50
|
type: :runtime
|
49
51
|
version_requirements: *id002
|
50
52
|
- !ruby/object:Gem::Dependency
|
51
|
-
name:
|
53
|
+
name: activesupport
|
52
54
|
prerelease: false
|
53
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
56
|
none: false
|
55
57
|
requirements:
|
56
58
|
- - ~>
|
57
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 1
|
58
61
|
segments:
|
62
|
+
- 3
|
59
63
|
- 0
|
60
|
-
- 8
|
61
64
|
- 3
|
62
|
-
version: 0.
|
65
|
+
version: 3.0.3
|
63
66
|
type: :runtime
|
64
67
|
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: mime-types
|
67
|
-
prerelease: false
|
68
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
|
-
requirements:
|
71
|
-
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
segments:
|
74
|
-
- 1
|
75
|
-
- 16
|
76
|
-
version: "1.16"
|
77
|
-
type: :runtime
|
78
|
-
version_requirements: *id004
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: activesupport
|
81
|
-
prerelease: false
|
82
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
segments:
|
88
|
-
- 3
|
89
|
-
- 1
|
90
|
-
- 3
|
91
|
-
version: 3.1.3
|
92
|
-
type: :runtime
|
93
|
-
version_requirements: *id005
|
94
68
|
- !ruby/object:Gem::Dependency
|
95
69
|
name: logging
|
96
70
|
prerelease: false
|
97
|
-
requirement: &
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
98
72
|
none: false
|
99
73
|
requirements:
|
100
74
|
- - ~>
|
101
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 1
|
102
77
|
segments:
|
103
78
|
- 1
|
104
79
|
- 4
|
105
80
|
- 3
|
106
81
|
version: 1.4.3
|
107
82
|
type: :runtime
|
108
|
-
version_requirements: *
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: eventmachine
|
111
|
-
prerelease: false
|
112
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ~>
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
segments:
|
118
|
-
- 0
|
119
|
-
- 12
|
120
|
-
- 10
|
121
|
-
version: 0.12.10
|
122
|
-
type: :runtime
|
123
|
-
version_requirements: *id007
|
83
|
+
version_requirements: *id004
|
124
84
|
- !ruby/object:Gem::Dependency
|
125
85
|
name: i18n
|
126
86
|
prerelease: false
|
127
|
-
requirement: &
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
128
88
|
none: false
|
129
89
|
requirements:
|
130
90
|
- - ~>
|
131
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 11
|
132
93
|
segments:
|
133
94
|
- 0
|
134
95
|
- 5
|
135
96
|
- 0
|
136
97
|
version: 0.5.0
|
137
98
|
type: :runtime
|
138
|
-
version_requirements: *
|
99
|
+
version_requirements: *id005
|
139
100
|
description: "This is a bot for 37 Signals\xE2\x80\x99 Campfire chat service."
|
140
101
|
email:
|
141
|
-
-
|
142
|
-
- hoverlover@gmail.com
|
102
|
+
- josh@joshwand.com
|
143
103
|
executables:
|
144
104
|
- campfire-bot
|
145
105
|
extensions: []
|
@@ -149,9 +109,7 @@ extra_rdoc_files: []
|
|
149
109
|
files:
|
150
110
|
- .autotest
|
151
111
|
- .gitignore
|
152
|
-
- CHANGELOG.md
|
153
112
|
- Gemfile
|
154
|
-
- Gemfile.lock
|
155
113
|
- README.textile
|
156
114
|
- TODO
|
157
115
|
- bin/campfire-bot
|
@@ -163,38 +121,6 @@ files:
|
|
163
121
|
- lib/message.rb
|
164
122
|
- lib/plugin.rb
|
165
123
|
- lib/version.rb
|
166
|
-
- plugins/accountability.rb
|
167
|
-
- plugins/austin.rb
|
168
|
-
- plugins/basecamp.rb
|
169
|
-
- plugins/beer.rb
|
170
|
-
- plugins/beijing_tally.rb
|
171
|
-
- plugins/boop.rb
|
172
|
-
- plugins/bruce.rb
|
173
|
-
- plugins/bugzilla.rb
|
174
|
-
- plugins/calvin.rb
|
175
|
-
- plugins/chuck.rb
|
176
|
-
- plugins/dilbert.rb
|
177
|
-
- plugins/excuse.rb
|
178
|
-
- plugins/fail.rb
|
179
|
-
- plugins/figlet.rb
|
180
|
-
- plugins/fun.rb
|
181
|
-
- plugins/garfield.rb
|
182
|
-
- plugins/generic_search.rb
|
183
|
-
- plugins/help.rb
|
184
|
-
- plugins/infobot.rb
|
185
|
-
- plugins/insult.rb
|
186
|
-
- plugins/jira.rb
|
187
|
-
- plugins/lolcats.rb
|
188
|
-
- plugins/our_quotes.rb
|
189
|
-
- plugins/quote.rb
|
190
|
-
- plugins/schneier.rb
|
191
|
-
- plugins/seen.rb
|
192
|
-
- plugins/signal_filter.rb
|
193
|
-
- plugins/svn.rb
|
194
|
-
- plugins/twitter_echo.rb
|
195
|
-
- plugins/unfuddle.rb
|
196
|
-
- plugins/weather.rb
|
197
|
-
- plugins/xkcd.rb
|
198
124
|
- spec/beer_spec.rb
|
199
125
|
- spec/bugzilla_spec.rb
|
200
126
|
- spec/command_spec.rb
|
@@ -263,7 +189,6 @@ files:
|
|
263
189
|
- vendor/escape/rdoc/index.html
|
264
190
|
- vendor/escape/rdoc/rdoc-style.css
|
265
191
|
- vendor/escape/test/test-escape.rb
|
266
|
-
has_rdoc: true
|
267
192
|
homepage: https://github.com/joshwand/campfire-bot
|
268
193
|
licenses: []
|
269
194
|
|
@@ -272,12 +197,12 @@ rdoc_options: []
|
|
272
197
|
|
273
198
|
require_paths:
|
274
199
|
- lib
|
275
|
-
- plugins
|
276
200
|
required_ruby_version: !ruby/object:Gem::Requirement
|
277
201
|
none: false
|
278
202
|
requirements:
|
279
203
|
- - ">="
|
280
204
|
- !ruby/object:Gem::Version
|
205
|
+
hash: 3
|
281
206
|
segments:
|
282
207
|
- 0
|
283
208
|
version: "0"
|
@@ -286,13 +211,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
211
|
requirements:
|
287
212
|
- - ">="
|
288
213
|
- !ruby/object:Gem::Version
|
214
|
+
hash: 3
|
289
215
|
segments:
|
290
216
|
- 0
|
291
217
|
version: "0"
|
292
218
|
requirements: []
|
293
219
|
|
294
220
|
rubyforge_project:
|
295
|
-
rubygems_version: 1.
|
221
|
+
rubygems_version: 1.8.16
|
296
222
|
signing_key:
|
297
223
|
specification_version: 3
|
298
224
|
summary: "This is a bot for 37 Signals\xE2\x80\x99 Campfire chat service."
|