-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathbot-context.xml
More file actions
707 lines (595 loc) · 22 KB
/
bot-context.xml
File metadata and controls
707 lines (595 loc) · 22 KB
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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
<?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@example.com</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)
A string sequence that users can append onto their messages if they want the bot to ignore a message.
-->
<prop key="ignoreMessageSuffix">~</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"/>
<!-- database =============================================== -->
<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" />
-->
<!-- statistics ============================================= -->
<bean id="statistics" class="oakbot.Statistics">
<constructor-arg ref="database" />
</bean>
<!-- "catch all" mention listener =========================== -->
<alias name="chatGPT" alias="catchAllMentionListener" />
<!--
Use this if you are not using the ChatGPT listener:
<bean id="mentionListener" class="oakbot.listener.MentionListener" />
<alias name="mentionListener" alias="catchAllMentionListener" />
-->
<!-- API clients referenced by multiple commands ============ -->
<bean class="oakbot.command.stands4.Stands4Client" id="stands4Client">
<!--
API user ID
-->
<constructor-arg value="API_USER_ID" />
<!--
API token
-->
<constructor-arg value="API_TOKEN" />
</bean>
<bean class="oakbot.command.TheCatDogApiClient" id="theCatDogApiClient">
<!--
(optional)
API key for thecatapi.com
-->
<constructor-arg value="API_KEY" />
</bean>
<!-- /abbr ================================================== -->
<bean class="oakbot.command.stands4.AbbreviationCommand">
<constructor-arg ref="stands4Client" />
</bean>
<!-- /about ================================================= -->
<bean class="oakbot.command.AboutCommand">
<constructor-arg ref="statistics" />
<!--
(optional)
Who the bot is hosted by. Chat markdown allowed.
-->
<constructor-arg value="**Michael**" />
</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.AdventOfCodeLeaderboard" id="aocLeaderboard">
<!--
Leaderboard ID.
-->
<constructor-arg value="123456" />
<!--
(optional)
Leaderboard join code.
Leave out this argument if you want to keep it private.
-->
<constructor-arg value="abc-123" />
</bean>
<bean class="oakbot.command.aoc.AdventOfCode">
<constructor-arg ref="aocApi" />
<!--
Polling interval.
AoC asks that this not be less than 15 minutes.
-->
<constructor-arg value="PT15M" />
<!--
How many days of puzzles there are this year.
In ths past, this has always been 25, but he reduced it to 12 starting in 2025.
-->
<constructor-arg value="12" />
<!--
(optional)
The leaderboard to show for each room if the user does not specify a leaderboard ID.
-->
<constructor-arg>
<util:map>
<entry key="1" value-ref="aocLeaderboard" />
</util:map>
</constructor-arg>
</bean>
<!-- /botler ================================================ -->
<bean class="oakbot.listener.BotlerListener">
<!--
Botler's trigger
-->
<constructor-arg value="Botler," />
<!--
Botler's user ID
-->
<constructor-arg value="13750349" />
<!--
The Botler message that the bot will respond to.
-->
<constructor-arg value="Hello friends!" />
<!--
The response.
-->
<constructor-arg value="Hi, Botler." />
<!--
Cooldown between responses.
-->
<constructor-arg value="P1D" />
</bean>
<!-- /cat =================================================== -->
<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">
<!--
API key for dictionaryapi.com
-->
<constructor-arg value="API_KEY" />
</bean>
<!-- /delete ================================================ -->
<bean class="oakbot.command.DeleteCommand">
<constructor-arg ref="catchAllMentionListener" />
</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">
<!--
API key for tenor.com
-->
<constructor-arg value="API_KEY" />
</bean>
<!-- /fatcat ================================================ -->
<bean class="oakbot.command.FatCatCommand">
<constructor-arg ref="database" />
<!--
A list of users who have permission to add/remove pictures from this command.
Bot admins already have permission to do this.
-->
<constructor-arg>
<util:list>
<value>12345</value>
</util:list>
</constructor-arg>
</bean>
<!-- /fish ================================================== -->
<bean class="oakbot.command.FishCommand">
<constructor-arg ref="database" />
<!--
Min time until quiver.
-->
<constructor-arg value="PT15M" />
<!--
Max time until quiver.
-->
<constructor-arg value="PT2H" />
<!--
Amount of time user has to pull up fish after quiver.
-->
<constructor-arg value="PT30M" />
</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">
<!--
Path to javadoc ZIP file directory
-->
<constructor-arg value="javadoc/zip-files" />
<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" />
<!--
Min time until ping.
-->
<constructor-arg value="PT15M" />
<!--
Max time until ping.
-->
<constructor-arg value="PT2H" />
</bean>
<!-- /react ================================================= -->
<bean class="oakbot.command.ReactGiphyCommand">
<!--
API key for giphy.com.
-->
<constructor-arg value="APT_KEY" />
</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" />
<!-- /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">
<!--
Bot's name.
-->
<constructor-arg value="Oak" />
<constructor-arg ref="catchAllMentionListener" />
</bean>
<!-- morn listener ========================================== -->
<bean class="oakbot.listener.MornListener">
<!--
Amount of time to wait before responding.
-->
<constructor-arg value="PT1S" />
<constructor-arg ref="catchAllMentionListener" />
</bean>
<!-- unitconversion listener ================================ -->
<bean class="oakbot.listener.UnitConversionListener" />
<!-- wave listener ========================================== -->
<bean class="oakbot.listener.WaveListener">
<!--
Amount of time to wait before waving back.
-->
<constructor-arg value="PT1S" />
<constructor-arg ref="catchAllMentionListener" />
</bean>
<!-- welcome listener ======================================= -->
<bean class="oakbot.listener.WelcomeListener">
<constructor-arg ref="database" />
<!--
Users with a reputation less than this will be welcomed.
-->
<constructor-arg value="1000" />
<!--
The welcome message to post for new users that join the room (markdown allowed)
-->
<constructor-arg>
<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">
<!--
The amount time to wait after the comic is posted to the chat room before crawling explainxkcd.com for the explanation.
-->
<constructor-arg value="PT30M" />
</bean>
<!-- AI ===================================================== -->
<bean class="oakbot.ai.openai.OpenAIClient" id="openAIClient">
<!--
OpenAI API key.
-->
<constructor-arg value="API_KEY" />
<!--
(optional)
Log all requests/responses to a CSV file for debugging.
-->
<!--
<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">
<!--
Stability.ai API key.
-->
<constructor-arg value="API_KEY" />
</bean>
<bean class="oakbot.imgur.ImgurClient" id="imgurClient">
<!--
Imgur.com API key.
-->
<constructor-arg value="CLIENT_ID" />
</bean>
<bean class="oakbot.listener.chatgpt.MoodCommand" id="moodCommand">
<constructor-arg ref="database" />
<!--
Default mood.
-->
<constructor-arg value="grumpy" />
</bean>
<bean class="oakbot.listener.chatgpt.ChatGPT" id="chatGPT">
<constructor-arg ref="openAIClient" />
<constructor-arg ref="moodCommand" />
<!--
The model.
-->
<constructor-arg value="gpt-3.5-turbo" />
<!--
Default prompt.
A short description of the bot's personality (e.g. "You are a helpful assistant").
$MOOD = The mood defined by the /mood command.
$ROOMNAME = The name of the chat room.
-->
<constructor-arg value="You are a $MOOD Java developer named 'OakBot'. You are in a room called '$ROOMNAME'." />
<!--
Room-specific prompts.
$MOOD = The mood defined by the /mood command.
$ROOMNAME = The name of the chat room.
-->
<constructor-arg>
<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>
<!--
Max tokens the response can be.
If this number is too short, then the completion may end abruptly (e.g. in an unfinished sentence).
-->
<constructor-arg value="100" />
<!--
(can be null)
Reasoning effort.
Higher values consume more tokens.
Only supported by some models.
-->
<constructor-arg value="low" />
<!--
The amount of time to wait before posting a sponaneous message.
-->
<constructor-arg value="PT12H" />
<!--
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="10" />
<!--
Each chat message that is sent to ChatGPT will not exceed this number of characters (including markdown syntax).
Chat messages that exceed this will be truncated (without cutting off words).
0 to disable truncation.
Each message counts against the usage quota.
-->
<constructor-arg value="300" />
<!--
Requests allowed per user per 24 hours
0 for no limit.
-->
<constructor-arg value="20" />
</bean>
<bean class="oakbot.listener.chatgpt.ImagineCore" id="imagineCore">
<constructor-arg ref="openAIClient" />
<constructor-arg ref="stabilityAIClient" />
<!--
Requests allowed per user per 24 hours.
0 for no limit.
-->
<constructor-arg value="5" />
</bean>
<bean class="oakbot.listener.chatgpt.ImagineCommand">
<constructor-arg ref="imagineCore" />
</bean>
<bean class="oakbot.listener.chatgpt.ImagineExactCommand">
<constructor-arg ref="imagineCore" />
</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="imagineCore" />
</bean>
<!-- fact of the day task =================================== -->
<bean class="oakbot.task.FOTD" />
<!-- health monitor task ==================================== -->
<bean class="oakbot.task.LinuxHealthMonitor">
<!--
The rooms to post health warnings in.
-->
<constructor-arg>
<util:list>
<value>1</value>
</util:list>
</constructor-arg>
<!--
Path to "apt-check" command.
-->
<constructor-arg value="/usr/lib/update-notifier/apt-check" />
</bean>
<!-- quote of the day task ================================== -->
<bean class="oakbot.task.QOTD" />
<!-- fill the silence task ================================== -->
<bean class="oakbot.inactivity.FillTheSilenceTask">
<!--
If the room is quiet for this long, bot will post a message
-->
<constructor-arg value="PT6H" />
</bean>
<!-- leave inactive rooms task ============================== -->
<bean class="oakbot.inactivity.LeaveRoomTask">
<!--
If the room is inactive for this long, bot will leave the room.
-->
<constructor-arg value="P3D" />
</bean>
<!-- Converts duration strings to Duration objects. -->
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
</beans>