-
Notifications
You must be signed in to change notification settings - Fork 32
/
bot-context.xml
485 lines (412 loc) · 17.8 KB
/
bot-context.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
https://www.springframework.org/schema/util/spring-util.xsd">
<!-- Spring reference documentation: https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html -->
<util:properties id="settings">
<!--
The path to the logging configuration file.
(defaults to: logging.properties)
-->
<prop key="logging.config">logging.properties</prop>
<!--
The website to connect to (each site has its own chat system).
Accepted values are: stackoverflow.com, stackexchange.com, meta.stackexchange.com
(defaults to: stackoverflow.com)
-->
<prop key="account.site">stackoverflow.com</prop>
<!--
The Stack Overflow login credentials for the bot.
-->
<prop key="account.email">[email protected]</prop>
<prop key="account.password">password</prop>
<!--
Manually set the username of the bot's account, incase it can't be parsed automatically.
<prop key="account.username">OakBot</prop>
-->
<!--
Manually set the user ID of the bot's account, incase it can't be parsed automatically.
The user ID can be found in the URL of the account's profile page.
<prop key="account.userId">4258326</prop>
-->
<!--
The string sequence that prefixes all commands (typically a single character).
This cannot contain any spaces and should not contain any of the special characters used in Markdown syntax, including: * _ ` - > ( ) [ ]
-->
<prop key="trigger">=</prop>
<!--
(optional)
The message to post when the bot joins a room. Chat markdown can be used here.
-->
<prop key="greeting">OakBot Online.</prop>
<!--
(optional)
Displays this URL when the "help" command output is condensed.
-->
<prop key="help.webpage">https://github.com/JavaChat/OakBot/wiki/Commands</prop>
<!--
(optional)
Any oneboxes (including images) that the bot posts will be automatically replaced by the onebox's URL after the specified amount of time
This is mainly here to help prevent the bot from spamming the chat with large images.
If this property is not defined, then oneboxes will not be replaced.
Note that this value cannot exceed two minutes, which is the maximum amount of time Stack Overflow Chat gives you to edit/delete your posts.
-->
<prop key="hideOneboxesAfter">PT1M50S</prop>
<!--
The list of rooms the bot cannot be unsummoned from.
At least one room must be specified.
The bot will join these rooms on startup.
This is a comma-separated list of room IDs.
A chat room's ID can be found in its URL.
-->
<prop key="rooms.home">1,139</prop>
<!--
(optional)
The bot will avoid posting things like awkward silence messages (a message that the bot posts when the room is inactive) to these rooms.
This is for rooms that like quiet and do not want to receive a lot of "spam".
This is a comma-separated list of room IDs.
A chat room's ID can be found in its URL.
-->
<prop key="rooms.quiet">1</prop>
<!--
(optional)
The users that are allowed to run admin-level commands against the bot (notably, the "shutdown" command).
This is a comma-separated list of user IDs.
A user ID can be found in the URL of the user's profile page.
-->
<prop key="users.admins">13379</prop>
<!--
(optional)
The users that have been banned from using the bot (red list).
The bot will ignore all messages from these users.
This is a comma-separated list of user IDs.
A user ID can be found in the URL of the user's profile page.
-->
<prop key="users.banned"></prop>
<!--
(optional)
The users that have been given permission to use the bot (green list).
If this property is not empty, the bot will ignore all messages except those that are from the specified users.
This is a comma-separated list of user IDs.
A user ID can be found in the URL of the user's profile page.
-->
<prop key="users.allowed"></prop>
<!--
Enables or disables learned commands.
-->
<prop key="enableLearnedCommands">true</prop>
<!--
(optional)
How often each room's web socket connection is refreshed (a workaround to resolve random disconnects).
-->
<prop key="webSocket.refreshInterval">PT4H</prop>
<!--
(optional)
Port number to use for the local command socket.
The local command socket is used to send commands to the bot process from the command-line.
Sending the string "shutdown" will cause the bot to gracefully shutdown.
If this property is not defined or set to 0, a port number will be automatically chosen and displayed on stdout at startup.
-->
<prop key="socket.port">6243</prop>
</util:properties>
<context:property-placeholder properties-ref="settings"/>
<bean id="database" class="oakbot.JsonDatabase">
<constructor-arg value="db.json" />
</bean>
<!--
Use this bean if you don't want to persist anything to a file:
<bean id="database" class="oakbot.MemoryDatabase" />
-->
<bean id="statistics" class="oakbot.Statistics">
<constructor-arg ref="database" />
</bean>
<!-- /abbr -->
<bean class="oakbot.command.stands4.Stands4Client" id="stands4Client">
<constructor-arg value="API_USER_ID" /> <!-- API user ID -->
<constructor-arg value="API_TOKEN" /> <!-- API token -->
</bean>
<bean class="oakbot.command.stands4.AbbreviationCommand">
<constructor-arg ref="stands4Client" />
</bean>
<!-- /about -->
<bean class="oakbot.command.AboutCommand">
<constructor-arg ref="statistics" />
<constructor-arg><null /></constructor-arg> <!-- who the bot is hosted by (optional, chat markdown can be used) -->
</bean>
<!-- /afk -->
<bean class="oakbot.command.AfkCommand" />
<!-- /aoc -->
<bean id="aocApi" class="oakbot.command.aoc.AdventOfCodeApi">
<!--
Session token is required in order to query the AoC leaderboards. This value can be retrieved
from your own Advent of Code login; just open the site and look at your
browser cookies. Whatever user account is associated with this session ID
must have access to a leaderboard in order for the bot to view it.
-->
<constructor-arg value="session token goes here" />
</bean>
<bean class="oakbot.command.aoc.AdventOfCode">
<constructor-arg value="PT15M" /> <!-- polling interval. AoC asks that this not be less than 15 minutes. -->
<constructor-arg>
<util:map> <!-- the leaderboard to show for each room if the user does not specify a leaderboard ID (can be empty) -->
<entry key="1" value="123456" />
</util:map>
</constructor-arg>
<constructor-arg ref="aocApi" />
</bean>
<!-- /bird -->
<!--
<bean class="oakbot.command.shibe.ShibeOnlineClient" id="shibeOnlineClient" />
<bean class="oakbot.command.shibe.BirdCommand">
<constructor-arg ref="shibeOnlineClient" />
</bean>
-->
<!-- /botler -->
<bean class="oakbot.listener.BotlerListener">
<constructor-arg value="Botler," /> <!-- trigger -->
<constructor-arg value="13750349" /> <!-- user ID -->
<constructor-arg value="Hello friends!" /> <!-- message to respond to -->
<constructor-arg value="Hi, Botler." /> <!-- response -->
<constructor-arg value="P1D" /> <!-- time between responses -->
</bean>
<!-- /cat -->
<bean class="oakbot.command.TheCatDogApiClient" id="theCatDogApiClient">
<!-- <constructor-arg value="API_KEY" /> API key for thecatapi.com (optional) -->
</bean>
<bean class="oakbot.command.CatCommand">
<constructor-arg ref="theCatDogApiClient" />
</bean>
<!-- /coffee -->
<bean class="oakbot.command.CoffeeCommand" />
<!-- /convert -->
<bean class="oakbot.command.stands4.ConvertCommand">
<constructor-arg ref="stands4Client" />
</bean>
<!-- /define -->
<bean class="oakbot.command.define.DefineCommand">
<constructor-arg value="" /> <!-- API key for dictionaryapi.com -->
</bean>
<!-- /delete -->
<bean class="oakbot.command.DeleteCommand">
<constructor-arg ref="chatGPT" />
</bean>
<!-- /dog -->
<bean class="oakbot.command.DogCommand">
<constructor-arg ref="theCatDogApiClient" />
</bean>
<!-- /echo -->
<bean class="oakbot.command.EchoCommand" />
<!-- /ed -->
<bean class="oakbot.command.effective.EffectiveDebuggingCommand" />
<!-- /ej -->
<bean class="oakbot.command.effective.EffectiveJavaCommand" />
<!-- /8ball -->
<bean class="oakbot.command.EightBallCommand" />
<!-- /explain -->
<bean class="oakbot.command.stands4.ExplainCommand">
<constructor-arg ref="stands4Client" />
</bean>
<!-- /facepalm -->
<bean class="oakbot.command.FacepalmCommand">
<constructor-arg value="" /> <!-- API key for tenor.com -->
</bean>
<!-- /fatcat -->
<bean class="oakbot.command.FatCatCommand">
<constructor-arg ref="database" />
<constructor-arg> <!-- a list of users who have permission to add/remove pictures from this command. Bot admins already have permission to do this. -->
<util:list>
<value>12345</value>
</util:list>
</constructor-arg>
</bean>
<!-- /fish -->
<bean class="oakbot.command.FishCommand">
<constructor-arg ref="database" />
<constructor-arg value="PT15M" /> <!-- min time until quiver -->
<constructor-arg value="PT2H" /> <!-- max time until quiver -->
<constructor-arg value="PT30M" /> <!-- time able to pull up fish after quiver -->
</bean>
<!-- /grammar -->
<bean class="oakbot.command.stands4.GrammarCommand">
<constructor-arg ref="stands4Client" />
</bean>
<!-- /groot -->
<bean class="oakbot.filter.GrootFilter" />
<!-- /http -->
<bean class="oakbot.command.http.HttpCommand" />
<!-- /javadoc -->
<bean class="oakbot.command.javadoc.JavadocCommand">
<constructor-arg ref="javadocDao" />
</bean>
<bean id="javadocDao" class="oakbot.command.javadoc.JavadocDaoUncached">
<constructor-arg>
<bean class="java.nio.file.Paths" factory-method="get">
<constructor-arg value="" /> <!-- path to javadoc ZIP file directory -->
<constructor-arg><array /></constructor-arg>
</bean>
</constructor-arg>
</bean>
<!-- /juicebox -->
<bean class="oakbot.command.JuiceBoxCommand" />
<!-- /phish -->
<bean class="oakbot.command.PhishCommand">
<constructor-arg ref="database" />
<constructor-arg value="PT15M" /> <!-- min time until ping -->
<constructor-arg value="PT2H" /> <!-- max time until ping -->
</bean>
<!-- /react -->
<bean class="oakbot.command.ReactGiphyCommand">
<constructor-arg value="" /> <!-- API key for giphy.com -->
</bean>
<!-- /remind -->
<bean class="oakbot.command.RemindCommand" />
<!-- /rhyme -->
<bean class="oakbot.command.stands4.RhymeCommand">
<constructor-arg ref="stands4Client" />
</bean>
<!-- /roll -->
<bean class="oakbot.command.RollCommand" />
<!-- /rollover -->
<bean class="oakbot.filter.UpsidedownTextFilter" />
<!-- /shiba -->
<!--
<bean class="oakbot.command.shibe.ShibaCommand">
<constructor-arg ref="shibeOnlineClient" />
</bean>
-->
<!-- /shrug -->
<bean class="oakbot.command.ShrugCommand" />
<!-- /shutdown -->
<bean class="oakbot.command.ShutdownCommand" />
<!-- /summon and /unsummon (/join and /leave) -->
<bean class="oakbot.command.SummonCommand" />
<bean class="oakbot.command.UnsummonCommand" />
<!-- /tag -->
<bean class="oakbot.command.TagCommand" />
<!-- /timeout -->
<bean class="oakbot.command.TimeoutCommand" />
<!-- /urban -->
<bean class="oakbot.command.urban.UrbanCommand" />
<!-- /wadu -->
<bean class="oakbot.filter.WaduFilter" />
<!-- /wiki -->
<bean class="oakbot.command.WikiCommand" />
<!-- dadjoke listener -->
<bean class="oakbot.listener.DadJokeListener">
<constructor-arg value="Oak" />
<constructor-arg ref="chatGPT" /> <!-- should be set to either mentionListener or chatGPT -->
</bean>
<!-- mention listener -->
<!--
Enable this if you're not using the ChatGPTListener
<bean id="mentionListener" class="oakbot.listener.MentionListener" />
-->
<!-- morn listener -->
<bean class="oakbot.listener.MornListener">
<constructor-arg value="PT1S" /> <!-- amount of time to wait before responding -->
<constructor-arg ref="chatGPT" /> <!-- should be set to either mentionListener or chatGPT -->
</bean>
<!-- wave listener -->
<bean class="oakbot.listener.WaveListener">
<constructor-arg value="PT1S" /> <!-- amount of time to wait before waving back -->
<constructor-arg ref="chatGPT" /> <!-- should be set to either mentionListener or chatGPT -->
</bean>
<!-- welcome listener -->
<bean class="oakbot.listener.WelcomeListener">
<constructor-arg ref="database" />
<constructor-arg value="1000" /> <!-- min rep user must have to NOT be welcomed -->
<constructor-arg> <!-- the welcome message to post for new users that join the room (can be empty, markdown can be used) -->
<util:map>
<entry key="1" value="Welcome to the Sandbox! Use this room to experiment with the features of Stack Overflow Chat." />
</util:map>
</constructor-arg>
</bean>
<!-- XKCD explained -->
<bean class="oakbot.task.XkcdExplained">
<constructor-arg value="PT30M" /> <!-- the amount time to wait after the comic is posted to the chat room before crawling explainxkcd.com for the explanation -->
</bean>
<!-- ChatGPT -->
<bean class="oakbot.ai.openai.OpenAIClient" id="openAIClient">
<constructor-arg value="API_KEY" />
<!-- log all requests/responses for debugging (optional constructor arg)
<constructor-arg>
<bean class="oakbot.util.HttpRequestLogger">
<constructor-arg value="openai-requests.csv" />
</bean>
</constructor-arg>
-->
</bean>
<bean class="oakbot.ai.stabilityai.StabilityAIClient" id="stabilityAIClient">
<constructor-arg value="API_KEY" />
</bean>
<bean class="oakbot.imgur.ImgurClient" id="imgurClient">
<constructor-arg value="CLIENT_ID" />
</bean>
<bean class="oakbot.listener.chatgpt.MoodCommand" id="moodCommand">
<constructor-arg ref="database" />
<constructor-arg value="grumpy" /> <!-- default mood -->
</bean>
<bean class="oakbot.listener.chatgpt.ChatGPT" id="chatGPT">
<constructor-arg ref="openAIClient" />
<constructor-arg ref="moodCommand" />
<constructor-arg value="gpt-3.5-turbo" />
<constructor-arg value="You are a $MOOD Java developer named 'OakBot'. You are in a room called '$ROOMNAME'." /> <!-- default prompt; one or more sentences that define the bot's personality (e.g. "You are a helpful assistant"). This counts against your usage quota. Each word costs around 1.33 tokens. -->
<constructor-arg> <!-- room-specific prompts -->
<util:map>
<entry key="1" value="You are a $MOOD chat bot named 'OakBot'. You are in a room called 'Sandbox', which people use for testing chat features." />
</util:map>
</constructor-arg>
<constructor-arg value="100" /> <!-- places a limit on the length of ChatGPT's completion (response). If this number is too short, then the completion may end abruptly (e.g. in an unfinished sentence). Each word costs around 1.33 tokens. -->
<constructor-arg value="PT12H" /> <!-- the amount of time to wait before posting a message (duration string) -->
<constructor-arg value="10" /> <!-- the number of chat room messages to include in the ChatGPT request to give the bot context of the conversation (each message counts against the usage quota) -->
<constructor-arg value="300" /> <!-- each chat message that is sent to ChatGPT will not exceed this number of characters (includes markdown syntax). Chat messages that do will be truncated (without cutting off words). 0 to disable truncation. Each message counts against the usage quota. Each word costs around 1.33 tokens. -->
<constructor-arg value="20" /> <!-- requests allowed per user per 24 hours, or <= 0 for no limit -->
</bean>
<bean class="oakbot.listener.chatgpt.ImagineCommand" id="imagineCommand">
<constructor-arg ref="openAIClient" />
<constructor-arg ref="stabilityAIClient" />
<constructor-arg value="5" /> <!-- requests allowed per user per 24 hours, or <= 0 for no limit -->
</bean>
<bean class="oakbot.listener.chatgpt.VideoCommand">
<constructor-arg ref="stabilityAIClient" />
<constructor-arg ref="imgurClient" />
</bean>
<bean class="oakbot.listener.chatgpt.PromptCommand">
<constructor-arg ref="chatGPT" />
</bean>
<bean class="oakbot.listener.chatgpt.QuotaCommand">
<constructor-arg ref="chatGPT" />
<constructor-arg ref="imagineCommand" />
</bean>
<!-- fact of the day task -->
<bean class="oakbot.task.FOTD" />
<!-- health monitor task -->
<bean class="oakbot.task.LinuxHealthMonitor">
<constructor-arg> <!-- the rooms to post health warnings in -->
<util:list>
<value>1</value>
</util:list>
</constructor-arg>
<constructor-arg value="/usr/lib/update-notifier/apt-check" /> <!-- path to "apt-check" command -->
</bean>
<!-- quote of the day task -->
<bean class="oakbot.task.QOTD" />
<!-- fill the silence task -->
<bean class="oakbot.inactivity.FillTheSilenceTask">
<constructor-arg value="PT6H" /> <!-- if the room is quiet for this long, bot will post a message -->
</bean>
<!-- leave inactive rooms task -->
<bean class="oakbot.inactivity.LeaveRoomTask">
<constructor-arg value="P3D" /> <!-- if the room is inactive for this long, bot will leave the room -->
</bean>
</beans>