safubot 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/doc/Safubot/Bot.html
CHANGED
@@ -1,827 +1,1462 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<meta content="text/html; charset=
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: Safubot::Bot
|
8
|
+
|
9
|
+
— Documentation by YARD 0.7.3
|
10
|
+
|
11
|
+
</title>
|
6
12
|
|
7
|
-
<
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
14
|
|
9
|
-
<link type="text/css" media="screen"
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
10
16
|
|
11
|
-
<script type="text/javascript">
|
12
|
-
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '..';
|
19
|
+
if (relpath != '') relpath += '/';
|
13
20
|
</script>
|
14
21
|
|
15
|
-
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
16
|
-
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
|
17
|
-
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
|
18
|
-
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
19
|
-
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
20
|
-
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
21
|
-
|
22
|
-
|
23
|
-
<body id="top" class="class">
|
24
|
-
<nav id="metadata">
|
25
|
-
<nav id="home-section" class="section">
|
26
|
-
<h3 class="section-header">
|
27
|
-
<a href="../index.html">Home</a>
|
28
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
29
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
30
|
-
</h3>
|
31
|
-
</nav>
|
32
|
-
|
33
|
-
|
34
|
-
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
-
<form action="#" method="get" accept-charset="utf-8">
|
36
|
-
<h3 class="section-header">
|
37
|
-
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
-
</h3>
|
40
|
-
</form>
|
41
|
-
|
42
|
-
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
-
</nav>
|
44
|
-
|
45
|
-
|
46
|
-
<div id="file-metadata">
|
47
|
-
<nav id="file-list-section" class="section">
|
48
|
-
<h3 class="section-header">Defined In</h3>
|
49
|
-
<ul>
|
50
|
-
<li>lib/safubot/bot.rb
|
51
|
-
<li>lib/safubot/test_helper.rb
|
52
|
-
</ul>
|
53
|
-
</nav>
|
22
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
54
23
|
|
55
|
-
|
56
|
-
</div>
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
57
25
|
|
58
|
-
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
59
32
|
|
60
|
-
<
|
61
|
-
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
62
35
|
|
63
|
-
|
36
|
+
<a href="../_index.html">Index (B)</a> »
|
37
|
+
<span class='title'><span class='object_link'><a href="../Safubot.html" title="Safubot (module)">Safubot</a></span></span>
|
38
|
+
»
|
39
|
+
<span class="title">Bot</span>
|
64
40
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
<nav id="includes-section" class="section">
|
69
|
-
<h3 class="section-header">Included Modules</h3>
|
41
|
+
|
42
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
+
</div>
|
70
44
|
|
71
|
-
|
45
|
+
<div id="search">
|
72
46
|
|
47
|
+
<a id="class_list_link" href="#">Class List</a>
|
73
48
|
|
74
|
-
<
|
49
|
+
<a id="method_list_link" href="#">Method List</a>
|
75
50
|
|
51
|
+
<a id="file_list_link" href="#">File List</a>
|
76
52
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
<!-- Method Quickref -->
|
81
|
-
<nav id="method-list-section" class="section">
|
82
|
-
<h3 class="section-header">Methods</h3>
|
83
|
-
|
84
|
-
<ul class="link-list">
|
53
|
+
</div>
|
54
|
+
<div class="clear"></div>
|
55
|
+
</div>
|
85
56
|
|
86
|
-
<
|
57
|
+
<iframe id="search_frame"></iframe>
|
87
58
|
|
88
|
-
<
|
89
|
-
|
90
|
-
|
59
|
+
<div id="content"><h1>Class: Safubot::Bot
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
<dt class="r1">Inherits:</dt>
|
68
|
+
<dd class="r1">
|
69
|
+
<span class="inheritName">Object</span>
|
70
|
+
|
71
|
+
<ul class="fullTree">
|
72
|
+
<li>Object</li>
|
73
|
+
|
74
|
+
<li class="next">Safubot::Bot</li>
|
75
|
+
|
76
|
+
</ul>
|
77
|
+
<a href="#" class="inheritanceTree">show all</a>
|
78
|
+
|
79
|
+
</dd>
|
91
80
|
|
92
|
-
|
81
|
+
|
82
|
+
|
93
83
|
|
94
|
-
|
84
|
+
|
95
85
|
|
96
|
-
|
86
|
+
<dt class="r2">Includes:</dt>
|
87
|
+
<dd class="r2"><span class='object_link'><a href="Evented.html" title="Safubot::Evented (module)">Evented</a></span></dd>
|
88
|
+
|
97
89
|
|
98
|
-
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<dt class="r1 last">Defined in:</dt>
|
94
|
+
<dd class="r1 last">lib/safubot/bot.rb<span class="defines">,<br />
|
95
|
+
lib/safubot/test_helper.rb</span>
|
96
|
+
</dd>
|
97
|
+
|
98
|
+
</dl>
|
99
|
+
<div class="clear"></div>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
108
|
+
<ul class="summary">
|
99
109
|
|
100
|
-
|
110
|
+
<li class="public ">
|
111
|
+
<span class="summary_signature">
|
101
112
|
|
102
|
-
|
113
|
+
<a href="#opts-instance_method" title="#opts (instance method)">- (Object) <strong>opts</strong> </a>
|
103
114
|
|
104
|
-
|
115
|
+
|
105
116
|
|
106
|
-
|
117
|
+
</span>
|
118
|
+
|
119
|
+
|
120
|
+
<span class="note title readonly">readonly</span>
|
107
121
|
|
108
|
-
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<span class="summary_desc"><div class='inline'><p>
|
130
|
+
Returns the value of attribute opts.
|
131
|
+
</p>
|
132
|
+
</div></span>
|
133
|
+
|
134
|
+
</li>
|
135
|
+
|
109
136
|
|
110
|
-
|
137
|
+
<li class="public ">
|
138
|
+
<span class="summary_signature">
|
111
139
|
|
112
|
-
|
140
|
+
<a href="#twitter-instance_method" title="#twitter (instance method)">- (Object) <strong>twitter</strong> </a>
|
113
141
|
|
114
|
-
|
142
|
+
|
115
143
|
|
116
|
-
|
144
|
+
</span>
|
145
|
+
|
146
|
+
|
147
|
+
<span class="note title readonly">readonly</span>
|
117
148
|
|
118
|
-
|
119
|
-
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
120
154
|
|
121
|
-
|
155
|
+
|
156
|
+
<span class="summary_desc"><div class='inline'><p>
|
157
|
+
Returns the value of attribute twitter.
|
158
|
+
</p>
|
159
|
+
</div></span>
|
160
|
+
|
161
|
+
</li>
|
122
162
|
|
123
|
-
|
124
|
-
|
125
|
-
<
|
163
|
+
|
164
|
+
<li class="public ">
|
165
|
+
<span class="summary_signature">
|
166
|
+
|
167
|
+
<a href="#xmpp-instance_method" title="#xmpp (instance method)">- (Object) <strong>xmpp</strong> </a>
|
168
|
+
|
126
169
|
|
127
|
-
|
170
|
+
|
171
|
+
</span>
|
172
|
+
|
173
|
+
|
174
|
+
<span class="note title readonly">readonly</span>
|
175
|
+
|
128
176
|
|
129
|
-
<li class="file"><a href="../Gemfile.html">Gemfile</a>
|
130
177
|
|
131
|
-
<li class="file"><a href="../Rakefile.html">Rakefile</a>
|
132
178
|
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
<span class="summary_desc"><div class='inline'><p>
|
184
|
+
Returns the value of attribute xmpp.
|
185
|
+
</p>
|
186
|
+
</div></span>
|
187
|
+
|
188
|
+
</li>
|
189
|
+
|
190
|
+
|
133
191
|
</ul>
|
134
|
-
</nav>
|
135
192
|
|
136
|
-
<nav id="classindex-section" class="section project-section">
|
137
|
-
<h3 class="section-header">Class and Module Index</h3>
|
138
193
|
|
139
|
-
|
194
|
+
|
140
195
|
|
141
|
-
<li><a href="../Safubot.html">Safubot</a>
|
142
196
|
|
143
|
-
<li><a href="../Safubot/Bot.html">Safubot::Bot</a>
|
144
197
|
|
145
|
-
|
198
|
+
|
146
199
|
|
147
|
-
<
|
200
|
+
<h2>
|
201
|
+
Instance Method Summary
|
202
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
203
|
+
</h2>
|
204
|
+
|
205
|
+
<ul class="summary">
|
206
|
+
|
207
|
+
<li class="public ">
|
208
|
+
<span class="summary_signature">
|
209
|
+
|
210
|
+
<a href="#answer-instance_method" title="#answer (instance method)">- (Object) <strong>answer</strong>(text, user = nil) </a>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
</span>
|
148
215
|
|
149
|
-
<li><a href="../Safubot/Log.html">Safubot::Log</a>
|
150
216
|
|
151
|
-
<li><a href="../Safubot/Query.html">Safubot::Query</a>
|
152
217
|
|
153
|
-
<li><a href="../Safubot/Request.html">Safubot::Request</a>
|
154
218
|
|
155
|
-
<li><a href="../Safubot/Response.html">Safubot::Response</a>
|
156
219
|
|
157
|
-
<li><a href="../Safubot/Test.html">Safubot::Test</a>
|
158
220
|
|
159
|
-
|
221
|
+
|
160
222
|
|
161
|
-
<
|
223
|
+
<span class="summary_desc"><div class='inline'><p>
|
224
|
+
A generic “respond immediately” interface.
|
225
|
+
</p>
|
226
|
+
</div></span>
|
162
227
|
|
163
|
-
|
228
|
+
</li>
|
229
|
+
|
230
|
+
|
231
|
+
<li class="public ">
|
232
|
+
<span class="summary_signature">
|
233
|
+
|
234
|
+
<a href="#concurrently-instance_method" title="#concurrently (instance method)">- (Object) <strong>concurrently</strong>(req, &blk) </a>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
</span>
|
164
239
|
|
165
|
-
<li><a href="../Safubot/Twitter/Tweet.html">Safubot::Twitter::Tweet</a>
|
166
240
|
|
167
|
-
<li><a href="../Safubot/XMPP.html">Safubot::XMPP</a>
|
168
241
|
|
169
|
-
<li><a href="../Safubot/XMPP/Bot.html">Safubot::XMPP::Bot</a>
|
170
242
|
|
171
|
-
<li><a href="../Safubot/XMPP/Message.html">Safubot::XMPP::Message</a>
|
172
243
|
|
173
|
-
<li><a href="../Object.html">Object</a>
|
174
244
|
|
175
|
-
</ul>
|
176
|
-
</nav>
|
177
|
-
|
178
|
-
</div>
|
179
|
-
</nav>
|
180
245
|
|
181
|
-
|
182
|
-
|
246
|
+
|
247
|
+
<span class="summary_desc"><div class='inline'><p>
|
248
|
+
Wraps EM::defer with error handling and response pushing for the given
|
249
|
+
request.
|
250
|
+
</p>
|
251
|
+
</div></span>
|
252
|
+
|
253
|
+
</li>
|
183
254
|
|
184
|
-
|
255
|
+
|
256
|
+
<li class="public ">
|
257
|
+
<span class="summary_signature">
|
258
|
+
|
259
|
+
<a href="#cycle-instance_method" title="#cycle (instance method)">- (Object) <strong>cycle</strong> </a>
|
185
260
|
|
186
|
-
<p>Here’s where we define the main <a href="../Safubot.html">Safubot</a>
|
187
|
-
instance.</p>
|
188
|
-
|
189
|
-
</div><!-- description -->
|
190
261
|
|
262
|
+
|
263
|
+
</span>
|
264
|
+
|
265
|
+
|
266
|
+
|
191
267
|
|
192
268
|
|
193
269
|
|
194
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
195
|
-
|
196
270
|
|
197
|
-
|
271
|
+
|
272
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
273
|
+
|
274
|
+
</li>
|
198
275
|
|
276
|
+
|
277
|
+
<li class="public ">
|
278
|
+
<span class="summary_signature">
|
279
|
+
|
280
|
+
<a href="#dispatch-instance_method" title="#dispatch (instance method)">- (Object) <strong>dispatch</strong>(resp) </a>
|
199
281
|
|
200
282
|
|
201
283
|
|
202
|
-
|
203
|
-
|
204
|
-
|
284
|
+
</span>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
205
291
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
class="attribute-access-type">[R]</span>
|
211
|
-
</div>
|
292
|
+
|
293
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
294
|
+
|
295
|
+
</li>
|
212
296
|
|
213
|
-
<div class="method-description">
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
</div>
|
218
|
-
</div>
|
219
297
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
298
|
+
<li class="public ">
|
299
|
+
<span class="summary_signature">
|
300
|
+
|
301
|
+
<a href="#enable_twitter-instance_method" title="#enable_twitter (instance method)">- (Object) <strong>enable_twitter</strong>(opts = {}) </a>
|
302
|
+
|
225
303
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
304
|
+
|
305
|
+
</span>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
315
|
+
|
316
|
+
</li>
|
238
317
|
|
239
|
-
<div class="method-description">
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
</div>
|
244
|
-
</div>
|
245
318
|
|
246
|
-
|
319
|
+
<li class="public ">
|
320
|
+
<span class="summary_signature">
|
247
321
|
|
248
|
-
|
249
|
-
<!-- Methods -->
|
322
|
+
<a href="#enable_xmpp-instance_method" title="#enable_xmpp (instance method)">- (Object) <strong>enable_xmpp</strong>(options = {}) </a>
|
250
323
|
|
251
|
-
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
252
|
-
<h3 class="section-header">Public Class Methods</h3>
|
253
324
|
|
254
325
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
326
|
+
</span>
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
263
333
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
334
|
+
|
335
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
336
|
+
|
337
|
+
</li>
|
268
338
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
<span class="ruby-constant">MongoMapper</span>.<span class="ruby-identifier">database</span> = <span class="ruby-ivar">@opts</span>[<span class="ruby-value">:database</span>]
|
276
|
-
<span class="ruby-constant">MongoMapper</span>.<span class="ruby-identifier">connection</span> = <span class="ruby-constant">Mongo</span><span class="ruby-operator">::</span><span class="ruby-constant">Connection</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'localhost'</span>, <span class="ruby-value">27017</span>, <span class="ruby-value">:pool_size</span> =<span class="ruby-operator">></span> <span class="ruby-value">5</span>)
|
277
|
-
<span class="ruby-ivar">@handlers</span> = {}
|
278
|
-
<span class="ruby-keyword">end</span></pre>
|
279
|
-
</div><!-- new-source -->
|
280
|
-
|
281
|
-
</div>
|
339
|
+
|
340
|
+
<li class="public ">
|
341
|
+
<span class="summary_signature">
|
342
|
+
|
343
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Bot) <strong>initialize</strong>(options = {}) </a>
|
344
|
+
|
282
345
|
|
283
|
-
|
346
|
+
|
347
|
+
</span>
|
348
|
+
|
349
|
+
<span class="note title constructor">constructor</span>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
284
356
|
|
285
|
-
|
286
|
-
|
357
|
+
|
358
|
+
<span class="summary_desc"><div class='inline'><p>
|
359
|
+
A new instance of Bot.
|
360
|
+
</p>
|
361
|
+
</div></span>
|
362
|
+
|
363
|
+
</li>
|
287
364
|
|
365
|
+
|
366
|
+
<li class="public ">
|
367
|
+
<span class="summary_signature">
|
368
|
+
|
369
|
+
<a href="#process-instance_method" title="#process (instance method)">- (Object) <strong>process</strong> </a>
|
288
370
|
|
289
|
-
</section><!-- public-class-method-details -->
|
290
|
-
|
291
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
292
|
-
<h3 class="section-header">Public Instance Methods</h3>
|
293
371
|
|
294
372
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
373
|
+
</span>
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
303
380
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
381
|
+
|
382
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
383
|
+
|
384
|
+
</li>
|
308
385
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
<span class="ruby-identifier">query</span> = <span class="ruby-constant">Query</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:user</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">user</span>, <span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">text</span>)
|
316
|
-
<span class="ruby-identifier">req</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">make_request</span>
|
317
|
-
<span class="ruby-identifier">process_request</span>(<span class="ruby-identifier">req</span>)
|
318
|
-
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">responses</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">text</span>
|
319
|
-
<span class="ruby-keyword">end</span></pre>
|
320
|
-
</div><!-- answer-source -->
|
321
|
-
|
322
|
-
</div>
|
386
|
+
|
387
|
+
<li class="public ">
|
388
|
+
<span class="summary_signature">
|
389
|
+
|
390
|
+
<a href="#process_request-instance_method" title="#process_request (instance method)">- (Object) <strong>process_request</strong>(req) </a>
|
391
|
+
|
323
392
|
|
324
|
-
|
393
|
+
|
394
|
+
</span>
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
325
401
|
|
326
|
-
|
327
|
-
|
402
|
+
|
403
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
404
|
+
|
405
|
+
</li>
|
328
406
|
|
407
|
+
|
408
|
+
<li class="public ">
|
409
|
+
<span class="summary_signature">
|
410
|
+
|
411
|
+
<a href="#pull-instance_method" title="#pull (instance method)">- (Object) <strong>pull</strong> </a>
|
329
412
|
|
330
|
-
<div id="method-i-concurrently" class="method-detail ">
|
331
|
-
|
332
|
-
<div class="method-heading">
|
333
|
-
<span class="method-name">concurrently</span><span
|
334
|
-
class="method-args">(req, &blk)</span>
|
335
|
-
<span class="method-click-advice">click to toggle source</span>
|
336
|
-
</div>
|
337
|
-
|
338
|
-
|
339
|
-
<div class="method-description">
|
340
|
-
|
341
|
-
<p>Wraps EM::defer with error handling and response pushing for the given
|
342
|
-
request. @param req The <a href="Request.html">Request</a> being processed.
|
343
|
-
@param blk The operation to be performed in a separate thread.</p>
|
344
|
-
|
345
413
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
<span class="ruby-identifier">request_error</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">e</span>)
|
355
|
-
<span class="ruby-keyword">end</span>
|
356
|
-
|
357
|
-
<span class="ruby-identifier">push</span>
|
358
|
-
<span class="ruby-keyword">end</span>
|
359
|
-
<span class="ruby-keyword">end</span></pre>
|
360
|
-
</div><!-- concurrently-source -->
|
361
|
-
|
362
|
-
</div>
|
414
|
+
|
415
|
+
</span>
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
363
422
|
|
364
|
-
|
423
|
+
|
424
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
425
|
+
|
426
|
+
</li>
|
365
427
|
|
366
|
-
|
367
|
-
|
428
|
+
|
429
|
+
<li class="public ">
|
430
|
+
<span class="summary_signature">
|
431
|
+
|
432
|
+
<a href="#push-instance_method" title="#push (instance method)">- (Object) <strong>push</strong> </a>
|
433
|
+
|
368
434
|
|
369
435
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
436
|
+
</span>
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
378
443
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
444
|
+
|
445
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
446
|
+
|
447
|
+
</li>
|
383
448
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
</div><!-- cycle-source -->
|
391
|
-
|
392
|
-
</div>
|
449
|
+
|
450
|
+
<li class="public ">
|
451
|
+
<span class="summary_signature">
|
452
|
+
|
453
|
+
<a href="#request_error-instance_method" title="#request_error (instance method)">- (Object) <strong>request_error</strong>(req, e) </a>
|
454
|
+
|
393
455
|
|
394
|
-
|
456
|
+
|
457
|
+
</span>
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
395
464
|
|
396
|
-
|
397
|
-
|
465
|
+
|
466
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
467
|
+
|
468
|
+
</li>
|
398
469
|
|
470
|
+
|
471
|
+
<li class="public ">
|
472
|
+
<span class="summary_signature">
|
473
|
+
|
474
|
+
<a href="#respond-instance_method" title="#respond (instance method)">- (Object) <strong>respond</strong>(req, text) </a>
|
399
475
|
|
400
|
-
<div id="method-i-dispatch" class="method-detail ">
|
401
|
-
|
402
|
-
<div class="method-heading">
|
403
|
-
<span class="method-name">dispatch</span><span
|
404
|
-
class="method-args">(resp)</span>
|
405
|
-
<span class="method-click-advice">click to toggle source</span>
|
406
|
-
</div>
|
407
|
-
|
408
|
-
|
409
|
-
<div class="method-description">
|
410
|
-
|
411
|
-
|
412
|
-
|
413
476
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
<span class="ruby-ivar">@twitter</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">resp</span>)
|
423
|
-
<span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@xmpp</span> <span class="ruby-operator">&&</span> [<span class="ruby-constant">XMPP</span><span class="ruby-operator">::</span><span class="ruby-constant">Message</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">source</span>.<span class="ruby-identifier">class</span>)
|
424
|
-
<span class="ruby-ivar">@xmpp</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">resp</span>)
|
425
|
-
<span class="ruby-keyword">else</span>
|
426
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-node">"Don't know how to send response to a #{source.class}!"</span>
|
427
|
-
<span class="ruby-keyword">end</span>
|
428
|
-
|
429
|
-
<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">dispatched</span> = <span class="ruby-keyword">true</span>
|
430
|
-
<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">save</span>
|
431
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
432
|
-
<span class="ruby-constant">Log</span>.<span class="ruby-identifier">write</span> <span class="ruby-node">"Error dispatching #{source.class} '#{resp.text}': #{e}"</span>
|
433
|
-
<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">errors</span>[<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>] = <span class="ruby-identifier">e</span>
|
434
|
-
<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">save</span>
|
435
|
-
<span class="ruby-identifier">emit</span>(<span class="ruby-value">:dispatch_error</span>, <span class="ruby-identifier">resp</span>, <span class="ruby-identifier">e</span>)
|
436
|
-
<span class="ruby-keyword">end</span>
|
437
|
-
<span class="ruby-keyword">end</span></pre>
|
438
|
-
</div><!-- dispatch-source -->
|
439
|
-
|
440
|
-
</div>
|
477
|
+
|
478
|
+
</span>
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
|
441
485
|
|
442
|
-
|
486
|
+
|
487
|
+
<span class="summary_desc"><div class='inline'><p>
|
488
|
+
Adds a response to the queue.
|
489
|
+
</p>
|
490
|
+
</div></span>
|
491
|
+
|
492
|
+
</li>
|
443
493
|
|
444
|
-
|
445
|
-
|
494
|
+
|
495
|
+
<li class="public ">
|
496
|
+
<span class="summary_signature">
|
497
|
+
|
498
|
+
<a href="#respond_now-instance_method" title="#respond_now (instance method)">- (Object) <strong>respond_now</strong>(req, text) </a>
|
499
|
+
|
446
500
|
|
447
501
|
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
502
|
+
</span>
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
456
509
|
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
510
|
+
|
511
|
+
<span class="summary_desc"><div class='inline'><p>
|
512
|
+
Respond + push.
|
513
|
+
</p>
|
514
|
+
</div></span>
|
515
|
+
|
516
|
+
</li>
|
461
517
|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
<span class="ruby-identifier">process</span>; <span class="ruby-identifier">push</span>
|
469
|
-
<span class="ruby-keyword">end</span>
|
470
|
-
<span class="ruby-keyword">end</span></pre>
|
471
|
-
</div><!-- enable_twitter-source -->
|
472
|
-
|
473
|
-
</div>
|
518
|
+
|
519
|
+
<li class="public ">
|
520
|
+
<span class="summary_signature">
|
521
|
+
|
522
|
+
<a href="#run-instance_method" title="#run (instance method)">- (Object) <strong>run</strong> </a>
|
523
|
+
|
474
524
|
|
475
|
-
|
525
|
+
|
526
|
+
</span>
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
|
476
533
|
|
477
|
-
|
478
|
-
|
534
|
+
|
535
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
536
|
+
|
537
|
+
</li>
|
479
538
|
|
539
|
+
|
540
|
+
<li class="public ">
|
541
|
+
<span class="summary_signature">
|
542
|
+
|
543
|
+
<a href="#stop-instance_method" title="#stop (instance method)">- (Object) <strong>stop</strong> </a>
|
480
544
|
|
481
|
-
<div id="method-i-enable_xmpp" class="method-detail ">
|
482
|
-
|
483
|
-
<div class="method-heading">
|
484
|
-
<span class="method-name">enable_xmpp</span><span
|
485
|
-
class="method-args">(options={})</span>
|
486
|
-
<span class="method-click-advice">click to toggle source</span>
|
487
|
-
</div>
|
488
|
-
|
489
545
|
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
546
|
+
|
547
|
+
</span>
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
494
554
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
<span class="ruby-identifier">defaults</span> = { <span class="ruby-value">:jid</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">:password</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">nil</span> }
|
500
|
-
<span class="ruby-ivar">@xmpp</span> = <span class="ruby-constant">XMPP</span><span class="ruby-operator">::</span><span class="ruby-constant">Bot</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">options</span>))
|
501
|
-
<span class="ruby-ivar">@xmpp</span>.<span class="ruby-identifier">on</span>(<span class="ruby-value">:request</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">req</span><span class="ruby-operator">|</span>
|
502
|
-
<span class="ruby-identifier">process</span>; <span class="ruby-identifier">push</span>
|
503
|
-
<span class="ruby-keyword">end</span>
|
504
|
-
<span class="ruby-keyword">end</span></pre>
|
505
|
-
</div><!-- enable_xmpp-source -->
|
506
|
-
|
507
|
-
</div>
|
555
|
+
|
556
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
557
|
+
|
558
|
+
</li>
|
508
559
|
|
509
|
-
|
560
|
+
|
561
|
+
</ul>
|
562
|
+
|
510
563
|
|
511
|
-
|
512
|
-
</div><!-- enable_xmpp-method -->
|
513
564
|
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="Evented.html" title="Safubot::Evented (module)">Evented</a></span></h3>
|
573
|
+
<p class="inherited"><span class='object_link'><a href="Evented.html#bind-instance_method" title="Safubot::Evented#bind (method)">#bind</a></span>, <span class='object_link'><a href="Evented.html#emit-instance_method" title="Safubot::Evented#emit (method)">#emit</a></span>, <span class='object_link'><a href="Evented.html#on-instance_method" title="Safubot::Evented#on (method)">#on</a></span>, <span class='object_link'><a href="Evented.html#once-instance_method" title="Safubot::Evented#once (method)">#once</a></span>, <span class='object_link'><a href="Evented.html#unbind-instance_method" title="Safubot::Evented#unbind (method)">#unbind</a></span></p>
|
574
|
+
<div id="constructor_details" class="method_details_list">
|
575
|
+
<h2>Constructor Details</h2>
|
576
|
+
|
577
|
+
<div class="method_details first">
|
578
|
+
<p class="signature first" id="initialize-instance_method">
|
579
|
+
|
580
|
+
- (<tt><span class='object_link'><a href="" title="Safubot::Bot (class)">Bot</a></span></tt>) <strong>initialize</strong>(options = {})
|
581
|
+
|
523
582
|
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
583
|
+
|
584
|
+
</p><div class="docstring">
|
585
|
+
<div class="discussion">
|
586
|
+
<p>
|
587
|
+
A new instance of Bot
|
588
|
+
</p>
|
528
589
|
|
529
|
-
|
530
|
-
<div class="method-source-code" id="process-source">
|
531
|
-
<pre><span class="ruby-comment"># File lib/safubot/bot.rb, line 84</span>
|
532
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">process</span>
|
533
|
-
<span class="ruby-constant">Request</span>.<span class="ruby-identifier">where</span>(<span class="ruby-value">:processed</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">false</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">req</span><span class="ruby-operator">|</span>
|
534
|
-
<span class="ruby-identifier">concurrently</span>(<span class="ruby-identifier">req</span>) { <span class="ruby-identifier">process_request</span>(<span class="ruby-identifier">req</span>) }
|
535
|
-
<span class="ruby-keyword">end</span>
|
536
|
-
<span class="ruby-keyword">end</span></pre>
|
537
|
-
</div><!-- process-source -->
|
538
|
-
|
539
|
-
</div>
|
540
590
|
|
541
|
-
|
591
|
+
</div>
|
592
|
+
</div>
|
593
|
+
<div class="tags">
|
594
|
+
|
542
595
|
|
543
|
-
|
544
|
-
|
596
|
+
</div><table class="source_code">
|
597
|
+
<tr>
|
598
|
+
<td>
|
599
|
+
<pre class="lines">
|
600
|
+
|
601
|
+
|
602
|
+
169
|
603
|
+
170
|
604
|
+
171
|
605
|
+
172
|
606
|
+
173
|
607
|
+
174
|
608
|
+
175</pre>
|
609
|
+
</td>
|
610
|
+
<td>
|
611
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 169</span>
|
612
|
+
|
613
|
+
<span class='kw'>def</span> <span class='id initialize'>initialize</span><span class='lparen'>(</span><span class='id options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
614
|
+
<span class='id defaults'>defaults</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='symbol'>:database</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>safubot</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
615
|
+
<span class='ivar'>@opts</span> <span class='op'>=</span> <span class='id defaults'>defaults</span><span class='period'>.</span><span class='id merge'>merge</span><span class='lparen'>(</span><span class='id options'>options</span><span class='rparen'>)</span>
|
616
|
+
<span class='const'>MongoMapper</span><span class='period'>.</span><span class='id database'>database</span> <span class='op'>=</span> <span class='ivar'>@opts</span><span class='lbracket'>[</span><span class='symbol'>:database</span><span class='rbracket'>]</span>
|
617
|
+
<span class='const'>MongoMapper</span><span class='period'>.</span><span class='id connection'>connection</span> <span class='op'>=</span> <span class='const'>Mongo</span><span class='op'>::</span><span class='const'>Connection</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>localhost</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='int'>27017</span><span class='comma'>,</span> <span class='symbol'>:pool_size</span> <span class='op'>=></span> <span class='int'>5</span><span class='rparen'>)</span>
|
618
|
+
<span class='ivar'>@handlers</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
619
|
+
<span class='kw'>end</span></pre>
|
620
|
+
</td>
|
621
|
+
</tr>
|
622
|
+
</table>
|
623
|
+
</div>
|
624
|
+
|
625
|
+
</div>
|
545
626
|
|
627
|
+
<div id="instance_attr_details" class="attr_details">
|
628
|
+
<h2>Instance Attribute Details</h2>
|
546
629
|
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
<div class="method-description">
|
557
|
-
|
558
|
-
|
559
|
-
|
630
|
+
|
631
|
+
<span id=""></span>
|
632
|
+
<span id="opts-instance_method"></span>
|
633
|
+
<div class="method_details first">
|
634
|
+
<p class="signature first" id="opts-instance_method">
|
635
|
+
|
636
|
+
- (<tt>Object</tt>) <strong>opts</strong> <span class="extras">(readonly)</span>
|
637
|
+
|
560
638
|
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
<
|
565
|
-
|
566
|
-
|
567
|
-
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
568
|
-
<span class="ruby-identifier">request_error</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">e</span>)
|
569
|
-
<span class="ruby-keyword">ensure</span>
|
570
|
-
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">processed</span> = <span class="ruby-keyword">true</span>
|
571
|
-
<span class="ruby-identifier">req</span>.<span class="ruby-identifier">save</span>
|
572
|
-
<span class="ruby-keyword">end</span>
|
573
|
-
<span class="ruby-keyword">end</span></pre>
|
574
|
-
</div><!-- process_request-source -->
|
575
|
-
|
576
|
-
</div>
|
639
|
+
|
640
|
+
</p><div class="docstring">
|
641
|
+
<div class="discussion">
|
642
|
+
<p>
|
643
|
+
Returns the value of attribute opts
|
644
|
+
</p>
|
577
645
|
|
578
|
-
|
579
646
|
|
580
|
-
|
581
|
-
|
647
|
+
</div>
|
648
|
+
</div>
|
649
|
+
<div class="tags">
|
650
|
+
|
582
651
|
|
652
|
+
</div><table class="source_code">
|
653
|
+
<tr>
|
654
|
+
<td>
|
655
|
+
<pre class="lines">
|
656
|
+
|
657
|
+
|
658
|
+
38
|
659
|
+
39
|
660
|
+
40</pre>
|
661
|
+
</td>
|
662
|
+
<td>
|
663
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 38</span>
|
664
|
+
|
665
|
+
<span class='kw'>def</span> <span class='id opts'>opts</span>
|
666
|
+
<span class='ivar'>@opts</span>
|
667
|
+
<span class='kw'>end</span></pre>
|
668
|
+
</td>
|
669
|
+
</tr>
|
670
|
+
</table>
|
671
|
+
</div>
|
583
672
|
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
<div class="method-description">
|
594
|
-
|
595
|
-
|
596
|
-
|
673
|
+
|
674
|
+
<span id=""></span>
|
675
|
+
<span id="twitter-instance_method"></span>
|
676
|
+
<div class="method_details ">
|
677
|
+
<p class="signature " id="twitter-instance_method">
|
678
|
+
|
679
|
+
- (<tt>Object</tt>) <strong>twitter</strong> <span class="extras">(readonly)</span>
|
680
|
+
|
597
681
|
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
<
|
602
|
-
|
603
|
-
|
604
|
-
</div><!-- pull-source -->
|
605
|
-
|
606
|
-
</div>
|
682
|
+
|
683
|
+
</p><div class="docstring">
|
684
|
+
<div class="discussion">
|
685
|
+
<p>
|
686
|
+
Returns the value of attribute twitter
|
687
|
+
</p>
|
607
688
|
|
608
|
-
|
609
689
|
|
610
|
-
|
611
|
-
|
690
|
+
</div>
|
691
|
+
</div>
|
692
|
+
<div class="tags">
|
693
|
+
|
612
694
|
|
695
|
+
</div><table class="source_code">
|
696
|
+
<tr>
|
697
|
+
<td>
|
698
|
+
<pre class="lines">
|
699
|
+
|
700
|
+
|
701
|
+
38
|
702
|
+
39
|
703
|
+
40</pre>
|
704
|
+
</td>
|
705
|
+
<td>
|
706
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 38</span>
|
707
|
+
|
708
|
+
<span class='kw'>def</span> <span class='id twitter'>twitter</span>
|
709
|
+
<span class='ivar'>@twitter</span>
|
710
|
+
<span class='kw'>end</span></pre>
|
711
|
+
</td>
|
712
|
+
</tr>
|
713
|
+
</table>
|
714
|
+
</div>
|
613
715
|
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
<div class="method-description">
|
624
|
-
|
625
|
-
|
626
|
-
|
716
|
+
|
717
|
+
<span id=""></span>
|
718
|
+
<span id="xmpp-instance_method"></span>
|
719
|
+
<div class="method_details ">
|
720
|
+
<p class="signature " id="xmpp-instance_method">
|
721
|
+
|
722
|
+
- (<tt>Object</tt>) <strong>xmpp</strong> <span class="extras">(readonly)</span>
|
723
|
+
|
627
724
|
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
<
|
632
|
-
|
633
|
-
|
634
|
-
</div><!-- push-source -->
|
635
|
-
|
636
|
-
</div>
|
725
|
+
|
726
|
+
</p><div class="docstring">
|
727
|
+
<div class="discussion">
|
728
|
+
<p>
|
729
|
+
Returns the value of attribute xmpp
|
730
|
+
</p>
|
637
731
|
|
638
|
-
|
639
732
|
|
640
|
-
|
641
|
-
|
733
|
+
</div>
|
734
|
+
</div>
|
735
|
+
<div class="tags">
|
736
|
+
|
642
737
|
|
738
|
+
</div><table class="source_code">
|
739
|
+
<tr>
|
740
|
+
<td>
|
741
|
+
<pre class="lines">
|
742
|
+
|
743
|
+
|
744
|
+
38
|
745
|
+
39
|
746
|
+
40</pre>
|
747
|
+
</td>
|
748
|
+
<td>
|
749
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 38</span>
|
750
|
+
|
751
|
+
<span class='kw'>def</span> <span class='id xmpp'>xmpp</span>
|
752
|
+
<span class='ivar'>@xmpp</span>
|
753
|
+
<span class='kw'>end</span></pre>
|
754
|
+
</td>
|
755
|
+
</tr>
|
756
|
+
</table>
|
757
|
+
</div>
|
643
758
|
|
644
|
-
|
645
|
-
|
646
|
-
<div class="method-heading">
|
647
|
-
<span class="method-name">request_error</span><span
|
648
|
-
class="method-args">(req, e)</span>
|
649
|
-
<span class="method-click-advice">click to toggle source</span>
|
650
|
-
</div>
|
651
|
-
|
759
|
+
</div>
|
652
760
|
|
653
|
-
<div class="method-description">
|
654
|
-
|
655
|
-
|
656
|
-
|
657
761
|
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
<
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
762
|
+
<div id="instance_method_details" class="method_details_list">
|
763
|
+
<h2>Instance Method Details</h2>
|
764
|
+
|
765
|
+
|
766
|
+
<div class="method_details first">
|
767
|
+
<p class="signature first" id="answer-instance_method">
|
768
|
+
|
769
|
+
- (<tt>Object</tt>) <strong>answer</strong>(text, user = nil)
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
</p><div class="docstring">
|
774
|
+
<div class="discussion">
|
775
|
+
<p>
|
776
|
+
A generic “respond immediately” interface.
|
777
|
+
</p>
|
670
778
|
|
671
|
-
|
672
779
|
|
673
|
-
|
674
|
-
|
780
|
+
</div>
|
781
|
+
</div>
|
782
|
+
<div class="tags">
|
783
|
+
|
675
784
|
|
785
|
+
</div><table class="source_code">
|
786
|
+
<tr>
|
787
|
+
<td>
|
788
|
+
<pre class="lines">
|
789
|
+
|
790
|
+
|
791
|
+
54
|
792
|
+
55
|
793
|
+
56
|
794
|
+
57
|
795
|
+
58
|
796
|
+
59
|
797
|
+
60</pre>
|
798
|
+
</td>
|
799
|
+
<td>
|
800
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/test_helper.rb', line 54</span>
|
801
|
+
|
802
|
+
<span class='kw'>def</span> <span class='id answer'>answer</span><span class='lparen'>(</span><span class='id text'>text</span><span class='comma'>,</span> <span class='id user'>user</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
803
|
+
<span class='id user'>user</span> <span class='op'>||=</span> <span class='const'>KnownUser</span><span class='period'>.</span><span class='id by_name'>by_name</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>testing</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
804
|
+
<span class='id query'>query</span> <span class='op'>=</span> <span class='const'>Query</span><span class='period'>.</span><span class='id create'>create</span><span class='lparen'>(</span><span class='symbol'>:user</span> <span class='op'>=></span> <span class='id user'>user</span><span class='comma'>,</span> <span class='symbol'>:text</span> <span class='op'>=></span> <span class='id text'>text</span><span class='rparen'>)</span>
|
805
|
+
<span class='id req'>req</span> <span class='op'>=</span> <span class='id query'>query</span><span class='period'>.</span><span class='id make_request'>make_request</span>
|
806
|
+
<span class='id process_request'>process_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span>
|
807
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id responses'>responses</span><span class='period'>.</span><span class='id first'>first</span><span class='period'>.</span><span class='id text'>text</span>
|
808
|
+
<span class='kw'>end</span></pre>
|
809
|
+
</td>
|
810
|
+
</tr>
|
811
|
+
</table>
|
812
|
+
</div>
|
676
813
|
|
677
|
-
<div
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
<span class="method-click-advice">click to toggle source</span>
|
683
|
-
</div>
|
684
|
-
|
814
|
+
<div class="method_details ">
|
815
|
+
<p class="signature " id="concurrently-instance_method">
|
816
|
+
|
817
|
+
- (<tt>Object</tt>) <strong>concurrently</strong>(req, &blk)
|
818
|
+
|
685
819
|
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
820
|
+
|
821
|
+
</p><div class="docstring">
|
822
|
+
<div class="discussion">
|
823
|
+
<p>
|
824
|
+
Wraps EM::defer with error handling and response pushing for the given
|
825
|
+
request.
|
826
|
+
</p>
|
691
827
|
|
692
|
-
|
693
|
-
<div class="method-source-code" id="respond-source">
|
694
|
-
<pre><span class="ruby-comment"># File lib/safubot/bot.rb, line 93</span>
|
695
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">respond</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">text</span>)
|
696
|
-
<span class="ruby-constant">Log</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">"#{req.user.name}: #{req.text}\nsafubot: #{text}"</span>)
|
697
|
-
<span class="ruby-constant">Response</span>.<span class="ruby-identifier">create</span>(<span class="ruby-value">:request</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">req</span>, <span class="ruby-value">:text</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">text</span>)
|
698
|
-
<span class="ruby-keyword">end</span></pre>
|
699
|
-
</div><!-- respond-source -->
|
700
|
-
|
701
|
-
</div>
|
702
828
|
|
703
|
-
|
829
|
+
</div>
|
830
|
+
</div>
|
831
|
+
<div class="tags">
|
832
|
+
<h3>Parameters:</h3>
|
833
|
+
<ul class="param">
|
834
|
+
|
835
|
+
<li>
|
836
|
+
|
837
|
+
<span class='name'>req</span>
|
838
|
+
|
839
|
+
|
840
|
+
<span class='type'></span>
|
841
|
+
|
842
|
+
|
843
|
+
|
844
|
+
—
|
845
|
+
<div class='inline'><p>
|
846
|
+
The Request being processed.
|
847
|
+
</p>
|
848
|
+
</div>
|
849
|
+
|
850
|
+
</li>
|
851
|
+
|
852
|
+
<li>
|
853
|
+
|
854
|
+
<span class='name'>blk</span>
|
855
|
+
|
856
|
+
|
857
|
+
<span class='type'></span>
|
858
|
+
|
859
|
+
|
860
|
+
|
861
|
+
—
|
862
|
+
<div class='inline'><p>
|
863
|
+
The operation to be performed in a separate thread.
|
864
|
+
</p>
|
865
|
+
</div>
|
866
|
+
|
867
|
+
</li>
|
868
|
+
|
869
|
+
</ul>
|
870
|
+
|
871
|
+
|
872
|
+
</div><table class="source_code">
|
873
|
+
<tr>
|
874
|
+
<td>
|
875
|
+
<pre class="lines">
|
876
|
+
|
877
|
+
|
878
|
+
119
|
879
|
+
120
|
880
|
+
121
|
881
|
+
122
|
882
|
+
123
|
883
|
+
124
|
884
|
+
125
|
885
|
+
126
|
886
|
+
127
|
887
|
+
128
|
888
|
+
129</pre>
|
889
|
+
</td>
|
890
|
+
<td>
|
891
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 119</span>
|
892
|
+
|
893
|
+
<span class='kw'>def</span> <span class='id concurrently'>concurrently</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='op'>&</span><span class='id blk'>blk</span><span class='rparen'>)</span>
|
894
|
+
<span class='const'>EventMachine</span><span class='op'>::</span><span class='id defer'>defer</span> <span class='kw'>do</span>
|
895
|
+
<span class='kw'>begin</span>
|
896
|
+
<span class='id blk'>blk</span><span class='period'>.</span><span class='id call'>call</span>
|
897
|
+
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
|
898
|
+
<span class='id request_error'>request_error</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
899
|
+
<span class='kw'>end</span>
|
900
|
+
|
901
|
+
<span class='id push'>push</span>
|
902
|
+
<span class='kw'>end</span>
|
903
|
+
<span class='kw'>end</span></pre>
|
904
|
+
</td>
|
905
|
+
</tr>
|
906
|
+
</table>
|
907
|
+
</div>
|
908
|
+
|
909
|
+
<div class="method_details ">
|
910
|
+
<p class="signature " id="cycle-instance_method">
|
911
|
+
|
912
|
+
- (<tt>Object</tt>) <strong>cycle</strong>
|
913
|
+
|
704
914
|
|
705
|
-
|
706
|
-
|
915
|
+
|
916
|
+
</p><table class="source_code">
|
917
|
+
<tr>
|
918
|
+
<td>
|
919
|
+
<pre class="lines">
|
920
|
+
|
921
|
+
|
922
|
+
112
|
923
|
+
113
|
924
|
+
114</pre>
|
925
|
+
</td>
|
926
|
+
<td>
|
927
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 112</span>
|
928
|
+
|
929
|
+
<span class='kw'>def</span> <span class='id cycle'>cycle</span>
|
930
|
+
<span class='id pull'>pull</span><span class='semicolon'>;</span> <span class='id process'>process</span><span class='semicolon'>;</span> <span class='id push'>push</span>
|
931
|
+
<span class='kw'>end</span></pre>
|
932
|
+
</td>
|
933
|
+
</tr>
|
934
|
+
</table>
|
935
|
+
</div>
|
936
|
+
|
937
|
+
<div class="method_details ">
|
938
|
+
<p class="signature " id="dispatch-instance_method">
|
939
|
+
|
940
|
+
- (<tt>Object</tt>) <strong>dispatch</strong>(resp)
|
941
|
+
|
707
942
|
|
943
|
+
|
944
|
+
</p><table class="source_code">
|
945
|
+
<tr>
|
946
|
+
<td>
|
947
|
+
<pre class="lines">
|
948
|
+
|
949
|
+
|
950
|
+
58
|
951
|
+
59
|
952
|
+
60
|
953
|
+
61
|
954
|
+
62
|
955
|
+
63
|
956
|
+
64
|
957
|
+
65
|
958
|
+
66
|
959
|
+
67
|
960
|
+
68
|
961
|
+
69
|
962
|
+
70
|
963
|
+
71
|
964
|
+
72
|
965
|
+
73
|
966
|
+
74
|
967
|
+
75
|
968
|
+
76
|
969
|
+
77
|
970
|
+
78
|
971
|
+
79
|
972
|
+
80
|
973
|
+
81
|
974
|
+
82</pre>
|
975
|
+
</td>
|
976
|
+
<td>
|
977
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 58</span>
|
978
|
+
|
979
|
+
<span class='kw'>def</span> <span class='id dispatch'>dispatch</span><span class='lparen'>(</span><span class='id resp'>resp</span><span class='rparen'>)</span>
|
980
|
+
<span class='comment'># Performs appropriate dispatch operation for response type.
|
981
|
+
</span> <span class='kw'>begin</span>
|
982
|
+
<span class='id source'>source</span> <span class='op'>=</span> <span class='id resp'>resp</span><span class='period'>.</span><span class='id request'>request</span><span class='period'>.</span><span class='id source'>source</span>
|
983
|
+
<span class='kw'>if</span> <span class='const'>Safubot</span><span class='op'>::</span><span class='id mode'>mode</span> <span class='op'>!=</span> <span class='symbol'>:production</span>
|
984
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id info'>info</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'> Response to </span><span class='embexpr_beg'>#{</span><span class='id source'>source</span><span class='period'>.</span><span class='id username'>username</span><span class='rbrace'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
985
|
+
<span class='kw'>else</span>
|
986
|
+
<span class='kw'>if</span> <span class='ivar'>@twitter</span> <span class='op'>&&</span> <span class='lbracket'>[</span><span class='const'>Twitter</span><span class='op'>::</span><span class='const'>Tweet</span><span class='comma'>,</span> <span class='const'>Twitter</span><span class='op'>::</span><span class='const'>DirectMessage</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rparen'>)</span>
|
987
|
+
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id resp'>resp</span><span class='rparen'>)</span>
|
988
|
+
<span class='kw'>elsif</span> <span class='ivar'>@xmpp</span> <span class='op'>&&</span> <span class='lbracket'>[</span><span class='const'>XMPP</span><span class='op'>::</span><span class='const'>Message</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id include?'>include?</span><span class='lparen'>(</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rparen'>)</span>
|
989
|
+
<span class='ivar'>@xmpp</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id resp'>resp</span><span class='rparen'>)</span>
|
990
|
+
<span class='kw'>else</span>
|
991
|
+
<span class='id raise'>raise</span> <span class='const'>NotImplementedError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Don't know how to send response to a </span><span class='embexpr_beg'>#{</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>"</span></span>
|
992
|
+
<span class='kw'>end</span>
|
993
|
+
<span class='kw'>end</span>
|
994
|
+
|
995
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id dispatched'>dispatched</span> <span class='op'>=</span> <span class='kw'>true</span>
|
996
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id save'>save</span>
|
997
|
+
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
|
998
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Error dispatching </span><span class='embexpr_beg'>#{</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'> '</span><span class='embexpr_beg'>#{</span><span class='id resp'>resp</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>': </span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
999
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id errors'>errors</span><span class='lbracket'>[</span><span class='const'>Time</span><span class='period'>.</span><span class='id now'>now</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id e'>e</span>
|
1000
|
+
<span class='id resp'>resp</span><span class='period'>.</span><span class='id save'>save</span>
|
1001
|
+
<span class='id emit'>emit</span><span class='lparen'>(</span><span class='symbol'>:dispatch_error</span><span class='comma'>,</span> <span class='id resp'>resp</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1002
|
+
<span class='kw'>end</span>
|
1003
|
+
<span class='kw'>end</span></pre>
|
1004
|
+
</td>
|
1005
|
+
</tr>
|
1006
|
+
</table>
|
1007
|
+
</div>
|
708
1008
|
|
709
|
-
<div
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
<span class="method-click-advice">click to toggle source</span>
|
715
|
-
</div>
|
716
|
-
|
1009
|
+
<div class="method_details ">
|
1010
|
+
<p class="signature " id="enable_twitter-instance_method">
|
1011
|
+
|
1012
|
+
- (<tt>Object</tt>) <strong>enable_twitter</strong>(opts = {})
|
1013
|
+
|
717
1014
|
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
1015
|
+
|
1016
|
+
</p><table class="source_code">
|
1017
|
+
<tr>
|
1018
|
+
<td>
|
1019
|
+
<pre class="lines">
|
1020
|
+
|
1021
|
+
|
1022
|
+
154
|
1023
|
+
155
|
1024
|
+
156
|
1025
|
+
157
|
1026
|
+
158
|
1027
|
+
159</pre>
|
1028
|
+
</td>
|
1029
|
+
<td>
|
1030
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 154</span>
|
1031
|
+
|
1032
|
+
<span class='kw'>def</span> <span class='id enable_twitter'>enable_twitter</span><span class='lparen'>(</span><span class='id opts'>opts</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1033
|
+
<span class='ivar'>@twitter</span> <span class='op'>=</span> <span class='const'>Twitter</span><span class='op'>::</span><span class='const'>Bot</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='id opts'>opts</span><span class='rparen'>)</span>
|
1034
|
+
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id on'>on</span><span class='lparen'>(</span><span class='symbol'>:request</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id req'>req</span><span class='op'>|</span>
|
1035
|
+
<span class='id process'>process</span><span class='semicolon'>;</span> <span class='id push'>push</span>
|
1036
|
+
<span class='kw'>end</span>
|
1037
|
+
<span class='kw'>end</span></pre>
|
1038
|
+
</td>
|
1039
|
+
</tr>
|
1040
|
+
</table>
|
1041
|
+
</div>
|
1042
|
+
|
1043
|
+
<div class="method_details ">
|
1044
|
+
<p class="signature " id="enable_xmpp-instance_method">
|
1045
|
+
|
1046
|
+
- (<tt>Object</tt>) <strong>enable_xmpp</strong>(options = {})
|
1047
|
+
|
722
1048
|
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
<
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
1049
|
+
|
1050
|
+
</p><table class="source_code">
|
1051
|
+
<tr>
|
1052
|
+
<td>
|
1053
|
+
<pre class="lines">
|
1054
|
+
|
1055
|
+
|
1056
|
+
161
|
1057
|
+
162
|
1058
|
+
163
|
1059
|
+
164
|
1060
|
+
165
|
1061
|
+
166
|
1062
|
+
167</pre>
|
1063
|
+
</td>
|
1064
|
+
<td>
|
1065
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 161</span>
|
1066
|
+
|
1067
|
+
<span class='kw'>def</span> <span class='id enable_xmpp'>enable_xmpp</span><span class='lparen'>(</span><span class='id options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1068
|
+
<span class='id defaults'>defaults</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='symbol'>:jid</span> <span class='op'>=></span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:password</span> <span class='op'>=></span> <span class='kw'>nil</span> <span class='rbrace'>}</span>
|
1069
|
+
<span class='ivar'>@xmpp</span> <span class='op'>=</span> <span class='const'>XMPP</span><span class='op'>::</span><span class='const'>Bot</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='id defaults'>defaults</span><span class='period'>.</span><span class='id merge'>merge</span><span class='lparen'>(</span><span class='id options'>options</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1070
|
+
<span class='ivar'>@xmpp</span><span class='period'>.</span><span class='id on'>on</span><span class='lparen'>(</span><span class='symbol'>:request</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id req'>req</span><span class='op'>|</span>
|
1071
|
+
<span class='id process'>process</span><span class='semicolon'>;</span> <span class='id push'>push</span>
|
1072
|
+
<span class='kw'>end</span>
|
1073
|
+
<span class='kw'>end</span></pre>
|
1074
|
+
</td>
|
1075
|
+
</tr>
|
1076
|
+
</table>
|
1077
|
+
</div>
|
1078
|
+
|
1079
|
+
<div class="method_details ">
|
1080
|
+
<p class="signature " id="process-instance_method">
|
1081
|
+
|
1082
|
+
- (<tt>Object</tt>) <strong>process</strong>
|
1083
|
+
|
733
1084
|
|
734
|
-
|
1085
|
+
|
1086
|
+
</p><table class="source_code">
|
1087
|
+
<tr>
|
1088
|
+
<td>
|
1089
|
+
<pre class="lines">
|
1090
|
+
|
1091
|
+
|
1092
|
+
88
|
1093
|
+
89
|
1094
|
+
90
|
1095
|
+
91
|
1096
|
+
92</pre>
|
1097
|
+
</td>
|
1098
|
+
<td>
|
1099
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 88</span>
|
1100
|
+
|
1101
|
+
<span class='kw'>def</span> <span class='id process'>process</span>
|
1102
|
+
<span class='const'>Request</span><span class='period'>.</span><span class='id where'>where</span><span class='lparen'>(</span><span class='symbol'>:processed</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id req'>req</span><span class='op'>|</span>
|
1103
|
+
<span class='id concurrently'>concurrently</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='id process_request'>process_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
1104
|
+
<span class='kw'>end</span>
|
1105
|
+
<span class='kw'>end</span></pre>
|
1106
|
+
</td>
|
1107
|
+
</tr>
|
1108
|
+
</table>
|
1109
|
+
</div>
|
1110
|
+
|
1111
|
+
<div class="method_details ">
|
1112
|
+
<p class="signature " id="process_request-instance_method">
|
1113
|
+
|
1114
|
+
- (<tt>Object</tt>) <strong>process_request</strong>(req)
|
1115
|
+
|
735
1116
|
|
736
|
-
|
737
|
-
|
1117
|
+
|
1118
|
+
</p><table class="source_code">
|
1119
|
+
<tr>
|
1120
|
+
<td>
|
1121
|
+
<pre class="lines">
|
1122
|
+
|
1123
|
+
|
1124
|
+
47
|
1125
|
+
48
|
1126
|
+
49
|
1127
|
+
50
|
1128
|
+
51
|
1129
|
+
52
|
1130
|
+
53
|
1131
|
+
54
|
1132
|
+
55
|
1133
|
+
56</pre>
|
1134
|
+
</td>
|
1135
|
+
<td>
|
1136
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 47</span>
|
1137
|
+
|
1138
|
+
<span class='kw'>def</span> <span class='id process_request'>process_request</span><span class='lparen'>(</span><span class='id req'>req</span><span class='rparen'>)</span>
|
1139
|
+
<span class='kw'>begin</span>
|
1140
|
+
<span class='id emit'>emit</span><span class='lparen'>(</span><span class='symbol'>:request</span><span class='comma'>,</span> <span class='id req'>req</span><span class='rparen'>)</span>
|
1141
|
+
<span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=></span> <span class='id e'>e</span>
|
1142
|
+
<span class='id request_error'>request_error</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1143
|
+
<span class='kw'>ensure</span>
|
1144
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id processed'>processed</span> <span class='op'>=</span> <span class='kw'>true</span>
|
1145
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id save'>save</span>
|
1146
|
+
<span class='kw'>end</span>
|
1147
|
+
<span class='kw'>end</span></pre>
|
1148
|
+
</td>
|
1149
|
+
</tr>
|
1150
|
+
</table>
|
1151
|
+
</div>
|
1152
|
+
|
1153
|
+
<div class="method_details ">
|
1154
|
+
<p class="signature " id="pull-instance_method">
|
1155
|
+
|
1156
|
+
- (<tt>Object</tt>) <strong>pull</strong>
|
1157
|
+
|
738
1158
|
|
1159
|
+
|
1160
|
+
</p><table class="source_code">
|
1161
|
+
<tr>
|
1162
|
+
<td>
|
1163
|
+
<pre class="lines">
|
1164
|
+
|
1165
|
+
|
1166
|
+
84
|
1167
|
+
85
|
1168
|
+
86</pre>
|
1169
|
+
</td>
|
1170
|
+
<td>
|
1171
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 84</span>
|
1172
|
+
|
1173
|
+
<span class='kw'>def</span> <span class='id pull'>pull</span>
|
1174
|
+
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id pull'>pull</span>
|
1175
|
+
<span class='kw'>end</span></pre>
|
1176
|
+
</td>
|
1177
|
+
</tr>
|
1178
|
+
</table>
|
1179
|
+
</div>
|
739
1180
|
|
740
|
-
<div
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
<span class="method-click-advice">click to toggle source</span>
|
746
|
-
</div>
|
747
|
-
|
1181
|
+
<div class="method_details ">
|
1182
|
+
<p class="signature " id="push-instance_method">
|
1183
|
+
|
1184
|
+
- (<tt>Object</tt>) <strong>push</strong>
|
1185
|
+
|
748
1186
|
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
1187
|
+
|
1188
|
+
</p><table class="source_code">
|
1189
|
+
<tr>
|
1190
|
+
<td>
|
1191
|
+
<pre class="lines">
|
1192
|
+
|
1193
|
+
|
1194
|
+
108
|
1195
|
+
109
|
1196
|
+
110</pre>
|
1197
|
+
</td>
|
1198
|
+
<td>
|
1199
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 108</span>
|
1200
|
+
|
1201
|
+
<span class='kw'>def</span> <span class='id push'>push</span>
|
1202
|
+
<span class='const'>Response</span><span class='period'>.</span><span class='id where'>where</span><span class='lparen'>(</span><span class='symbol'>:dispatched</span> <span class='op'>=></span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id each'>each</span><span class='lparen'>(</span><span class='op'>&</span><span class='id method'>method</span><span class='lparen'>(</span><span class='symbol'>:dispatch</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
1203
|
+
<span class='kw'>end</span></pre>
|
1204
|
+
</td>
|
1205
|
+
</tr>
|
1206
|
+
</table>
|
1207
|
+
</div>
|
1208
|
+
|
1209
|
+
<div class="method_details ">
|
1210
|
+
<p class="signature " id="request_error-instance_method">
|
1211
|
+
|
1212
|
+
- (<tt>Object</tt>) <strong>request_error</strong>(req, e)
|
1213
|
+
|
753
1214
|
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
<
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
<span class=
|
773
|
-
|
774
|
-
|
775
|
-
|
1215
|
+
|
1216
|
+
</p><table class="source_code">
|
1217
|
+
<tr>
|
1218
|
+
<td>
|
1219
|
+
<pre class="lines">
|
1220
|
+
|
1221
|
+
|
1222
|
+
40
|
1223
|
+
41
|
1224
|
+
42
|
1225
|
+
43
|
1226
|
+
44
|
1227
|
+
45</pre>
|
1228
|
+
</td>
|
1229
|
+
<td>
|
1230
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 40</span>
|
1231
|
+
|
1232
|
+
<span class='kw'>def</span> <span class='id request_error'>request_error</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1233
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Error processing </span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id source'>source</span><span class='period'>.</span><span class='id class'>class</span><span class='rbrace'>}</span><span class='tstring_content'> '</span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>': </span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='rbrace'>}</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='period'>.</span><span class='id backtrace'>backtrace</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n\t</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
1234
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id errors'>errors</span><span class='lbracket'>[</span><span class='const'>Time</span><span class='period'>.</span><span class='id now'>now</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id e'>e</span>
|
1235
|
+
<span class='id req'>req</span><span class='period'>.</span><span class='id save'>save</span>
|
1236
|
+
<span class='id emit'>emit</span><span class='lparen'>(</span><span class='symbol'>:request_error</span><span class='comma'>,</span> <span class='id req'>req</span><span class='comma'>,</span> <span class='id e'>e</span><span class='rparen'>)</span>
|
1237
|
+
<span class='kw'>end</span></pre>
|
1238
|
+
</td>
|
1239
|
+
</tr>
|
1240
|
+
</table>
|
1241
|
+
</div>
|
1242
|
+
|
1243
|
+
<div class="method_details ">
|
1244
|
+
<p class="signature " id="respond-instance_method">
|
1245
|
+
|
1246
|
+
- (<tt>Object</tt>) <strong>respond</strong>(req, text)
|
1247
|
+
|
776
1248
|
|
777
|
-
|
1249
|
+
|
1250
|
+
</p><div class="docstring">
|
1251
|
+
<div class="discussion">
|
1252
|
+
<p>
|
1253
|
+
Adds a response to the queue.
|
1254
|
+
</p>
|
778
1255
|
|
779
|
-
|
780
|
-
</div><!-- run-method -->
|
781
1256
|
|
1257
|
+
</div>
|
1258
|
+
</div>
|
1259
|
+
<div class="tags">
|
1260
|
+
<h3>Parameters:</h3>
|
1261
|
+
<ul class="param">
|
1262
|
+
|
1263
|
+
<li>
|
1264
|
+
|
1265
|
+
<span class='name'>req</span>
|
1266
|
+
|
1267
|
+
|
1268
|
+
<span class='type'></span>
|
1269
|
+
|
1270
|
+
|
1271
|
+
|
1272
|
+
—
|
1273
|
+
<div class='inline'><p>
|
1274
|
+
Request to respond to.
|
1275
|
+
</p>
|
1276
|
+
</div>
|
1277
|
+
|
1278
|
+
</li>
|
1279
|
+
|
1280
|
+
<li>
|
1281
|
+
|
1282
|
+
<span class='name'>text</span>
|
1283
|
+
|
1284
|
+
|
1285
|
+
<span class='type'></span>
|
1286
|
+
|
1287
|
+
|
1288
|
+
|
1289
|
+
—
|
1290
|
+
<div class='inline'><p>
|
1291
|
+
Contents of the response.
|
1292
|
+
</p>
|
1293
|
+
</div>
|
1294
|
+
|
1295
|
+
</li>
|
1296
|
+
|
1297
|
+
</ul>
|
1298
|
+
|
1299
|
+
|
1300
|
+
</div><table class="source_code">
|
1301
|
+
<tr>
|
1302
|
+
<td>
|
1303
|
+
<pre class="lines">
|
1304
|
+
|
1305
|
+
|
1306
|
+
97
|
1307
|
+
98
|
1308
|
+
99
|
1309
|
+
100</pre>
|
1310
|
+
</td>
|
1311
|
+
<td>
|
1312
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 97</span>
|
1313
|
+
|
1314
|
+
<span class='kw'>def</span> <span class='id respond'>respond</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1315
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id user'>user</span><span class='period'>.</span><span class='id name'>name</span><span class='rbrace'>}</span><span class='tstring_content'>: </span><span class='embexpr_beg'>#{</span><span class='id req'>req</span><span class='period'>.</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_content'>\nsafubot: </span><span class='embexpr_beg'>#{</span><span class='id text'>text</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1316
|
+
<span class='const'>Response</span><span class='period'>.</span><span class='id create'>create</span><span class='lparen'>(</span><span class='symbol'>:request</span> <span class='op'>=></span> <span class='id req'>req</span><span class='comma'>,</span> <span class='symbol'>:text</span> <span class='op'>=></span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1317
|
+
<span class='kw'>end</span></pre>
|
1318
|
+
</td>
|
1319
|
+
</tr>
|
1320
|
+
</table>
|
1321
|
+
</div>
|
782
1322
|
|
783
|
-
<div
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
<span class="method-click-advice">click to toggle source</span>
|
789
|
-
</div>
|
790
|
-
|
791
|
-
|
792
|
-
<div class="method-description">
|
793
|
-
|
794
|
-
|
795
|
-
|
1323
|
+
<div class="method_details ">
|
1324
|
+
<p class="signature " id="respond_now-instance_method">
|
1325
|
+
|
1326
|
+
- (<tt>Object</tt>) <strong>respond_now</strong>(req, text)
|
1327
|
+
|
796
1328
|
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
<
|
801
|
-
|
802
|
-
|
803
|
-
<span class="ruby-constant">EM</span><span class="ruby-operator">::</span><span class="ruby-identifier">stop_event_loop</span>
|
804
|
-
<span class="ruby-keyword">end</span></pre>
|
805
|
-
</div><!-- stop-source -->
|
806
|
-
|
807
|
-
</div>
|
1329
|
+
|
1330
|
+
</p><div class="docstring">
|
1331
|
+
<div class="discussion">
|
1332
|
+
<p>
|
1333
|
+
Respond + push
|
1334
|
+
</p>
|
808
1335
|
|
809
|
-
|
810
1336
|
|
811
|
-
|
812
|
-
|
1337
|
+
</div>
|
1338
|
+
</div>
|
1339
|
+
<div class="tags">
|
1340
|
+
|
813
1341
|
|
1342
|
+
</div><table class="source_code">
|
1343
|
+
<tr>
|
1344
|
+
<td>
|
1345
|
+
<pre class="lines">
|
1346
|
+
|
1347
|
+
|
1348
|
+
103
|
1349
|
+
104
|
1350
|
+
105
|
1351
|
+
106</pre>
|
1352
|
+
</td>
|
1353
|
+
<td>
|
1354
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 103</span>
|
1355
|
+
|
1356
|
+
<span class='kw'>def</span> <span class='id respond_now'>respond_now</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1357
|
+
<span class='id respond'>respond</span><span class='lparen'>(</span><span class='id req'>req</span><span class='comma'>,</span> <span class='id text'>text</span><span class='rparen'>)</span>
|
1358
|
+
<span class='id push'>push</span>
|
1359
|
+
<span class='kw'>end</span></pre>
|
1360
|
+
</td>
|
1361
|
+
</tr>
|
1362
|
+
</table>
|
1363
|
+
</div>
|
814
1364
|
|
815
|
-
|
1365
|
+
<div class="method_details ">
|
1366
|
+
<p class="signature " id="run-instance_method">
|
1367
|
+
|
1368
|
+
- (<tt>Object</tt>) <strong>run</strong>
|
816
1369
|
|
817
|
-
</section><!-- 5Buntitled-5D -->
|
818
|
-
|
819
|
-
</div><!-- documentation -->
|
820
1370
|
|
1371
|
+
|
1372
|
+
</p><table class="source_code">
|
1373
|
+
<tr>
|
1374
|
+
<td>
|
1375
|
+
<pre class="lines">
|
1376
|
+
|
1377
|
+
|
1378
|
+
131
|
1379
|
+
132
|
1380
|
+
133
|
1381
|
+
134
|
1382
|
+
135
|
1383
|
+
136
|
1384
|
+
137
|
1385
|
+
138
|
1386
|
+
139
|
1387
|
+
140
|
1388
|
+
141
|
1389
|
+
142
|
1390
|
+
143
|
1391
|
+
144
|
1392
|
+
145
|
1393
|
+
146</pre>
|
1394
|
+
</td>
|
1395
|
+
<td>
|
1396
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 131</span>
|
1397
|
+
|
1398
|
+
<span class='kw'>def</span> <span class='id run'>run</span>
|
1399
|
+
<span class='const'>EventMachine</span><span class='op'>::</span><span class='id run'>run</span> <span class='kw'>do</span>
|
1400
|
+
<span class='const'>EM</span><span class='op'>::</span><span class='id error_handler'>error_handler</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id e'>e</span><span class='op'>|</span>
|
1401
|
+
<span class='kw'>if</span> <span class='id e'>e</span><span class='period'>.</span><span class='id is_a?'>is_a?</span> <span class='const'>Interrupt</span>
|
1402
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Received interrupt, shutting down.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1403
|
+
<span class='id stop'>stop</span>
|
1404
|
+
<span class='kw'>else</span>
|
1405
|
+
<span class='const'>Log</span><span class='period'>.</span><span class='id error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unhandled exception: </span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='rbrace'>}</span><span class='tstring_content'>\n</span><span class='embexpr_beg'>#{</span><span class='id e'>e</span><span class='period'>.</span><span class='id backtrace'>backtrace</span><span class='period'>.</span><span class='id join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\t\n</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
1406
|
+
<span class='kw'>end</span>
|
1407
|
+
<span class='kw'>end</span>
|
1408
|
+
|
1409
|
+
<span class='id cycle'>cycle</span>
|
1410
|
+
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id run'>run</span> <span class='kw'>if</span> <span class='ivar'>@twitter</span>
|
1411
|
+
<span class='ivar'>@xmpp</span><span class='period'>.</span><span class='id run'>run</span> <span class='kw'>if</span> <span class='ivar'>@xmpp</span>
|
1412
|
+
<span class='kw'>end</span>
|
1413
|
+
<span class='kw'>end</span></pre>
|
1414
|
+
</td>
|
1415
|
+
</tr>
|
1416
|
+
</table>
|
1417
|
+
</div>
|
1418
|
+
|
1419
|
+
<div class="method_details ">
|
1420
|
+
<p class="signature " id="stop-instance_method">
|
1421
|
+
|
1422
|
+
- (<tt>Object</tt>) <strong>stop</strong>
|
1423
|
+
|
821
1424
|
|
822
|
-
|
823
|
-
|
824
|
-
<
|
825
|
-
|
826
|
-
|
1425
|
+
|
1426
|
+
</p><table class="source_code">
|
1427
|
+
<tr>
|
1428
|
+
<td>
|
1429
|
+
<pre class="lines">
|
1430
|
+
|
1431
|
+
|
1432
|
+
148
|
1433
|
+
149
|
1434
|
+
150
|
1435
|
+
151
|
1436
|
+
152</pre>
|
1437
|
+
</td>
|
1438
|
+
<td>
|
1439
|
+
<pre class="code"><span class="info file"># File 'lib/safubot/bot.rb', line 148</span>
|
1440
|
+
|
1441
|
+
<span class='kw'>def</span> <span class='id stop'>stop</span>
|
1442
|
+
<span class='ivar'>@twitter</span><span class='period'>.</span><span class='id stop'>stop</span> <span class='kw'>if</span> <span class='ivar'>@twitter</span>
|
1443
|
+
<span class='ivar'>@xmpp</span><span class='period'>.</span><span class='id stop'>stop</span> <span class='kw'>if</span> <span class='ivar'>@xmpp</span>
|
1444
|
+
<span class='const'>EM</span><span class='op'>::</span><span class='id stop_event_loop'>stop_event_loop</span>
|
1445
|
+
<span class='kw'>end</span></pre>
|
1446
|
+
</td>
|
1447
|
+
</tr>
|
1448
|
+
</table>
|
1449
|
+
</div>
|
1450
|
+
|
1451
|
+
</div>
|
827
1452
|
|
1453
|
+
</div>
|
1454
|
+
|
1455
|
+
<div id="footer">
|
1456
|
+
Generated on Mon Nov 28 20:20:03 2011 by
|
1457
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1458
|
+
0.7.3 (ruby-1.9.2).
|
1459
|
+
</div>
|
1460
|
+
|
1461
|
+
</body>
|
1462
|
+
</html>
|