campfire-bot 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/plugins/twitter_echo.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'hpricot'
|
2
|
-
require 'open-uri'
|
3
|
-
require 'ostruct'
|
4
|
-
require 'time'
|
5
|
-
require 'htmlentities'
|
6
|
-
|
7
|
-
# The workings of this plugin are based on http://github.com/paulca/twitter2campfire
|
8
|
-
# Thanks to Paul Campbell and Contrast! <http://www.contrast.ie/>
|
9
|
-
|
10
|
-
class TwitterEcho < CampfireBot::Plugin
|
11
|
-
|
12
|
-
at_interval 2.minutes, :echo_tweets
|
13
|
-
|
14
|
-
def initialize
|
15
|
-
@feed = bot.config['twitter_feed']
|
16
|
-
@hide_replies = bot.config.key?('twitter_hide_replies') ? bot.config['twitter_hide_replies'] : false
|
17
|
-
@latest = Time.now
|
18
|
-
end
|
19
|
-
|
20
|
-
def echo_tweets(msg = nil)
|
21
|
-
recent_tweets.reverse.each do |tweet|
|
22
|
-
msg.speak("#{coder.decode(tweet.from)}: #{coder.decode(tweet.text)} #{tweet.link}") unless (tweet.text =~ /^@/ && @hide_replies)
|
23
|
-
end
|
24
|
-
@latest = latest_tweet.date # next time, only print tweets newer than this
|
25
|
-
@doc = nil # reset the feed so that next time we can actually any new tweets
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
def raw_feed
|
31
|
-
@doc ||= Hpricot(open(@feed))
|
32
|
-
end
|
33
|
-
|
34
|
-
def all_tweets
|
35
|
-
(raw_feed/'entry').map { |e| OpenStruct.new(
|
36
|
-
:from => (e/'name').inner_html,
|
37
|
-
:text => (e/'title').inner_html,
|
38
|
-
:link => (e/'link').first['href'],
|
39
|
-
:date => Time.parse((e/'published').inner_html)
|
40
|
-
)}
|
41
|
-
end
|
42
|
-
|
43
|
-
def latest_tweet
|
44
|
-
all_tweets.first
|
45
|
-
end
|
46
|
-
|
47
|
-
def recent_tweets
|
48
|
-
all_tweets.reject { |e| e.date.to_i <= @latest.to_i }
|
49
|
-
end
|
50
|
-
|
51
|
-
def coder
|
52
|
-
HTMLEntities.new
|
53
|
-
end
|
54
|
-
end
|
data/plugins/unfuddle.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
# Unfuddle RSS echo plugin. Uses the following config.yml settings:
|
2
|
-
#
|
3
|
-
# unfuddle:
|
4
|
-
# domain: you.unfuddle.com
|
5
|
-
# rss_path: "/account/activity.rss?aak=aaaaaaaaaaaaabbbbbbbbccccccccddddddeeee0000"
|
6
|
-
# port: 443
|
7
|
-
# msg_filters:
|
8
|
-
# - reassigned
|
9
|
-
# - closed
|
10
|
-
# - commented
|
11
|
-
# - resolved
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'simple-rss'
|
15
|
-
require 'net/https'
|
16
|
-
|
17
|
-
class Unfuddle < CampfireBot::Plugin
|
18
|
-
at_interval 2.minutes, :fetch_rss
|
19
|
-
on_command 'unfuddle', :fetch_rss
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
@last_item = 12.hours.ago
|
23
|
-
@http = Net::HTTP.new(bot.config['unfuddle']['domain'], bot.config['unfuddle']['port'])
|
24
|
-
|
25
|
-
if bot.config['unfuddle']['port'] == 443
|
26
|
-
@http.use_ssl = true
|
27
|
-
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def fetch_rss(msg)
|
32
|
-
feed = SimpleRSS.parse(@http.get(bot.config['unfuddle']['rss_path']).body)
|
33
|
-
|
34
|
-
feed.items.each do |item|
|
35
|
-
msg.speak "#{item.title} #{item.link}" if published?(item) && !filtered?(item.title)
|
36
|
-
end
|
37
|
-
|
38
|
-
@last_item = feed.items.first.pubDate
|
39
|
-
rescue => e
|
40
|
-
msg.speak e
|
41
|
-
end
|
42
|
-
|
43
|
-
def published?(item)
|
44
|
-
item.pubDate > @last_item
|
45
|
-
end
|
46
|
-
|
47
|
-
def filtered?(title)
|
48
|
-
bot.config['unfuddle']['msg_filters'].each do |msg_filter|
|
49
|
-
return true if send("#{msg_filter}?", title)
|
50
|
-
end
|
51
|
-
return false
|
52
|
-
end
|
53
|
-
|
54
|
-
def closed?(title)
|
55
|
-
(title =~ /Closed Ticket:/) != nil
|
56
|
-
end
|
57
|
-
|
58
|
-
def reassigned?(title)
|
59
|
-
(title =~ /Reassigned Ticket:/) != nil
|
60
|
-
end
|
61
|
-
|
62
|
-
def commented?(title)
|
63
|
-
(title =~ /Created Ticket Comment:/) != nil
|
64
|
-
end
|
65
|
-
|
66
|
-
def resolved?(title)
|
67
|
-
(title =~ /Resolved Ticket:/) != nil
|
68
|
-
end
|
69
|
-
end
|
data/plugins/weather.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'yahoo-weather'
|
2
|
-
|
3
|
-
class Weather < CampfireBot::Plugin
|
4
|
-
on_command 'weather', :weather
|
5
|
-
|
6
|
-
def weather(msg)
|
7
|
-
cities = {
|
8
|
-
'adelaide' => '1099805',
|
9
|
-
'brisbane' => '1100661',
|
10
|
-
'canberra' => '1100968',
|
11
|
-
'darwin' => '1101597',
|
12
|
-
'hobart' => '1102670',
|
13
|
-
'melbourne' => '1103816',
|
14
|
-
'perth' => '1098081',
|
15
|
-
'sydney' => '1105779'
|
16
|
-
}
|
17
|
-
|
18
|
-
city_id = cities[(msg[:message]).downcase] # select city, or
|
19
|
-
city_id ||= cities['canberra'] # use default if no matches
|
20
|
-
|
21
|
-
data = YahooWeather::Client.new.lookup_by_woeid(city_id, 'c')
|
22
|
-
|
23
|
-
msg.speak("#{data.title} - #{data.condition.text}, #{data.condition.temp} deg C (high #{data.forecasts.first.high}, low #{data.forecasts.first.low})")
|
24
|
-
end
|
25
|
-
end
|
data/plugins/xkcd.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
require 'hpricot'
|
3
|
-
require 'tempfile'
|
4
|
-
|
5
|
-
class Xkcd < CampfireBot::Plugin
|
6
|
-
BASE_URL = 'http://xkcd.com/'
|
7
|
-
|
8
|
-
on_command 'xkcd', :xkcd
|
9
|
-
|
10
|
-
def xkcd(msg)
|
11
|
-
# Get the comic info
|
12
|
-
comic = case msg[:message].split(/\s+/)[0]
|
13
|
-
when 'latest'
|
14
|
-
fetch_latest
|
15
|
-
when 'random'
|
16
|
-
fetch_random
|
17
|
-
when /d+/
|
18
|
-
fetch_comic(msg[:message].split(/\s+/)[0])
|
19
|
-
else
|
20
|
-
fetch_random
|
21
|
-
end
|
22
|
-
|
23
|
-
msg.speak comic['src']
|
24
|
-
msg.speak comic['title']
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def fetch_latest
|
30
|
-
fetch_comic
|
31
|
-
end
|
32
|
-
|
33
|
-
def fetch_random
|
34
|
-
# Fetch the latest page and then find the link to the previous comic.
|
35
|
-
# This will give us a number to work with (that of the penultimate strip).
|
36
|
-
fetch_comic(rand((Hpricot(open(BASE_URL))/'//*[@accesskey="p"]').first['href'].gsub(/\D/, '').to_i + 1))
|
37
|
-
end
|
38
|
-
|
39
|
-
def fetch_comic(id = nil)
|
40
|
-
# Rely on the comic being the last image on the page with a title attribute
|
41
|
-
(Hpricot(open("#{BASE_URL}#{id.to_s + '/' if id}"))/'img[@title]').last
|
42
|
-
end
|
43
|
-
end
|