safubot 0.0.1 → 0.0.2
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/.yardoc/checksums +9 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +52 -1
- data/doc/Safubot/Bot.html +1287 -652
- data/doc/Safubot/Evented.html +409 -276
- data/doc/Safubot/KnownUser.html +476 -254
- data/doc/Safubot/Log.html +184 -192
- data/doc/Safubot/Query.html +131 -164
- data/doc/Safubot/Request.html +158 -147
- data/doc/Safubot/Response.html +92 -135
- data/doc/Safubot/Test.html +166 -187
- data/doc/Safubot/Twitter/Bot.html +1005 -455
- data/doc/Safubot/Twitter/DirectMessage.html +417 -238
- data/doc/Safubot/Twitter/Tweet.html +725 -398
- data/doc/Safubot/Twitter.html +69 -116
- data/doc/Safubot/XMPP/Bot.html +625 -303
- data/doc/Safubot/XMPP/Message.html +372 -217
- data/doc/Safubot/XMPP.html +69 -116
- data/doc/Safubot.html +155 -126
- data/doc/_index.html +294 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.README.html +140 -0
- data/doc/file_list.html +49 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +129 -101
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +167 -0
- data/doc/js/jquery.js +3 -5
- data/doc/method_list.html +638 -0
- data/doc/top-level-namespace.html +103 -0
- data/lib/safubot/bot.rb +22 -20
- data/lib/safubot/known_user.rb +2 -0
- data/lib/safubot/twitter.rb +30 -26
- data/lib/safubot/version.rb +1 -1
- data/lib/safubot/xmpp.rb +20 -14
- data/safubot.gemspec +1 -0
- metadata +50 -71
- data/doc/Gemfile.html +0 -119
- data/doc/Object.html +0 -171
- data/doc/Rakefile.html +0 -117
- data/doc/created.rid +0 -14
- data/doc/foo_rb.html +0 -115
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/js/darkfish.js +0 -153
- data/doc/js/navigation.js +0 -142
- data/doc/js/search.js +0 -94
- data/doc/js/search_index.js +0 -1
- data/doc/js/searcher.js +0 -228
- data/doc/lib/safubot/bot_rb.html +0 -115
- data/doc/lib/safubot/evented_rb.html +0 -115
- data/doc/lib/safubot/known_user_rb.html +0 -115
- data/doc/lib/safubot/log_rb.html +0 -115
- data/doc/lib/safubot/safubot_rb.html +0 -115
- data/doc/lib/safubot/spec/bot_spec_rb.html +0 -115
- data/doc/lib/safubot/spec/twitter_spec_rb.html +0 -137
- data/doc/lib/safubot/test_helper_rb.html +0 -115
- data/doc/lib/safubot/twitter_rb.html +0 -115
- data/doc/lib/safubot/version_rb.html +0 -115
- data/doc/lib/safubot/xmpp_rb.html +0 -115
- data/doc/lib/safubot_rb.html +0 -115
- data/doc/rdoc.css +0 -543
- data/doc/table_of_contents.html +0 -224
data/.yardoc/checksums
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
lib/safubot.rb da2c6f1fa7e7a17064469e0a5409f5dc2a6ec7ab
|
|
2
|
+
lib/safubot/bot.rb a191fb9b972ebf19e4badc110658b64bb02f92ff
|
|
3
|
+
lib/safubot/log.rb 132a7d9090c8c405b409fa12868244eb8de7b15a
|
|
4
|
+
lib/safubot/xmpp.rb 50b683fbfcaef60d07102dd893df0a277c110f89
|
|
5
|
+
lib/safubot/evented.rb 87b6fba0d6e65e5abf09e7606e1fd502713da2e7
|
|
6
|
+
lib/safubot/version.rb 67c555f319499e0bcc596a73152df9f0797da190
|
|
7
|
+
lib/safubot/twitter.rb 4574d47793303bc087f14b7c4bc7b5f0e7c938c7
|
|
8
|
+
lib/safubot/known_user.rb 06960025ae9bf08570ab743f64a7b22ac1687542
|
|
9
|
+
lib/safubot/test_helper.rb 870fe48e4efd009690b8cd8f29203491610ca8bb
|
|
Binary file
|
data/.yardoc/proxy_types
ADDED
|
Binary file
|
data/README.md
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
# safubot - an evented chatbot framework for Ruby
|
|
2
2
|
|
|
3
|
+
## <a name="overview">Overview</a>
|
|
4
|
+
Safubot is a chatbot framework for Twitter and XMPP which aims to abstract away the idiosyncracies of the underlying APIs, allowing you to focus on writing request-processing logic. Of course, if you want to use service-specific features (such as responding to timeline tweets) it lets you do that too!
|
|
5
|
+
|
|
3
6
|
## <a name="installation">Installation</a>
|
|
7
|
+
gem install safubot
|
|
8
|
+
|
|
9
|
+
## <a name="requirements">Requirements</a>
|
|
10
|
+
Safubot uses [MongoDB](http://www.mongodb.org) for storage. It's [easy to install](http://www.mongodb.org/display/DOCS/Quickstart+Unix) and pretty awesome!
|
|
4
11
|
|
|
5
12
|
## <a name="documentation">Documentation</a>
|
|
13
|
+
[http://rdoc.info/gems/safubot](http://rdoc.info/gems/safubot)
|
|
6
14
|
|
|
7
|
-
## <a name="example">
|
|
15
|
+
## <a name="example">Sample Usage</a>
|
|
8
16
|
require 'safubot'
|
|
9
17
|
|
|
10
18
|
class NiftyBot < Safubot::Bot
|
|
11
19
|
def initialize
|
|
20
|
+
# Check the MongoMapper docs (http://www.mongomapper.com/documentation/) if you want
|
|
21
|
+
# to do something more sophisticated than an authless localhost connection.
|
|
12
22
|
super(:database => "niftybot")
|
|
13
23
|
|
|
24
|
+
# To access the underlying delegation targets:
|
|
25
|
+
# Safubot::Twitter::Bot bot.twitter
|
|
26
|
+
# ::Twitter::Client bot.twitter.client
|
|
27
|
+
# ::TweetStream::Client bot.twitter.stream
|
|
14
28
|
enable_twitter({
|
|
15
29
|
:username => "niftybot",
|
|
16
30
|
:consumer_key => CONSUMER_KEY,
|
|
@@ -19,11 +33,19 @@
|
|
|
19
33
|
:oauth_token_secret => OAUTH_TOKEN_SECRET
|
|
20
34
|
})
|
|
21
35
|
|
|
36
|
+
# Similarly, for XMPP:
|
|
37
|
+
# Safubot::XMPP::Bot bot.xmpp
|
|
38
|
+
# ::Blather::Client bot.xmpp.client
|
|
22
39
|
enable_xmpp({
|
|
23
40
|
:jid => "niftybot@jabber.org/niftyhost",
|
|
24
41
|
:password => JABBER_PASSWORD
|
|
25
42
|
})
|
|
26
43
|
|
|
44
|
+
# A Request can be sourced from a:
|
|
45
|
+
# * Twitter mention
|
|
46
|
+
# * Twitter DM
|
|
47
|
+
# * XMPP chat message
|
|
48
|
+
# The "respond" method will reply using the appropriate medium.
|
|
27
49
|
on(:request) do |req|
|
|
28
50
|
if req.text.match /nifty/i
|
|
29
51
|
respond req, "Yep, I'm a nifty bot! :3"
|
|
@@ -32,6 +54,8 @@
|
|
|
32
54
|
end
|
|
33
55
|
end
|
|
34
56
|
|
|
57
|
+
# Any unhandled errors encountered during request processing
|
|
58
|
+
# will come through here.
|
|
35
59
|
on(:request_error) do |req, e|
|
|
36
60
|
respond req, "#{e}"
|
|
37
61
|
end
|
|
@@ -41,3 +65,30 @@
|
|
|
41
65
|
# You can run this from inside another EventMachine loop if
|
|
42
66
|
# you don't want it to block indefinitely.
|
|
43
67
|
NiftyBot.new.run
|
|
68
|
+
|
|
69
|
+
## <a name="example">Specific Examples</a>
|
|
70
|
+
|
|
71
|
+
### Find the last processed request from a user
|
|
72
|
+
|
|
73
|
+
on(:request) do |req|
|
|
74
|
+
req.user.requests.where(:processed => true).sort(:created_at.desc).first
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
### Update our twitter account
|
|
78
|
+
|
|
79
|
+
@twitter.client.update("Hello there, wonderful, scary world of Twitter! I am so *not* a spambot.")
|
|
80
|
+
|
|
81
|
+
### Reply to a non-request timeline tweet
|
|
82
|
+
|
|
83
|
+
@twitter.on(:timeline) do |tweet|
|
|
84
|
+
if tweet.raw['user']['screen_name'] == "unnali"
|
|
85
|
+
@twitter.reply tweet, "Is HaeSeun OSS yet? :O"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
### Start an unprompted conversation with an XMPP user.
|
|
90
|
+
|
|
91
|
+
@xmpp.on(:ready) do
|
|
92
|
+
@xmpp.tell('^_^@jabber.org', "You'd best be maintaining safubot!")
|
|
93
|
+
end
|
|
94
|
+
|