Commit Graph

33 Commits

Author SHA1 Message Date
930839ab58
Prevent dice overflow
rand.Int() would panic when the max value is <= 0, which happens when
big.NewInt() was fed with a too large number. Avoid this by validating
the big.NewInt() return beforehand. Add error handling to all callers to
both gracefully return to IRC and to log an error message.
Rename the shadowed "max" variable whilst at it to avoid confusion.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-10 18:43:46 +02:00
dfe7deff72
Configurable database path
Allow the database file to reside in a user defined location instead of
requiring it to be in the working directory.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-10 00:04:16 +02:00
5ce4d4bfe4
Lower nickname in Jeopardy cashout
Align with GetTarget() which is used in games to have consistent
handling of nicknames regardless of their casing.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-09 23:36:45 +02:00
7ec49a9769
Improve Jeopardy cashout message
Print only a single message instead of one per winner to reduce chat
clutter.
Skip cashout to users who won less than the possible cashout value as
limited by the division value to avoid congratulating someone who only
gets 0.
Abort should a regression cause the logic to process an empty set of
finishers to prevent unexpected behavior.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-03 19:43:39 +02:00
accf16c92a
Change host lookup to be optional
Some parts of the logic do not make use of the host column in the
players table, allow the field to be empty and do not query for an empty
value (which might return bogus entries) if no value is passed to the
lookup function.
This additionally avoids the need for the hardcoded initial host when
configuring the bot player.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-02 22:30:06 +02:00
d99a0d84bf
Strip formatting codes
To allow for correct parsing of messages containing formatting codes and
to avoid exploitation of unparseable messages, strip all formatting
codes from a message when entering the parsing chain.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-02 21:40:30 +02:00
89ed59a9c7
Explain Jeopardy finishers parsing
Elaborate as the convoluted logic can be difficult to understand.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-02 20:03:56 +02:00
d06e724f06
Refactor integrations
Move to a separate file for better code structure and to avoid huge
branching inside Msg().

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-10-02 20:03:56 +02:00
97e9d7d0c2
Implement Jeopardy cashout
This adds integration between Watbot and the Limnoria Jeopardy plugin.
If a game of Jeopardy ends, Watbot will parse the finishers message and
pay a small share of the Jeopardy price money in the form of Watcoins.
To avoid abuse, only Jeopardy finishing messages from authorized bots
are considered. An IRC user is considered an authorized bot if the
hostmask matches one of the configured bot hostmasks, and if the
nickname is configured for "jeopardy" in the newly introduced bot games
configuration.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>

Add sample message to Jeopardy logic

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-09-29 14:36:23 +02:00
0a90b6e483
Implement automatic channel joining
Avoid the need for an administrator to join the bot to channels by
implementing a configuration option allowing the passing of channels
the bot should always join to by itself upon startup.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-09-28 19:33:18 +02:00
cc322e87e6
Replace redundant logic in Admin()
The Allowed() function already implements this loop, use it to reduce
redundant code.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-09-28 19:33:18 +02:00
bde9a8defb
Implement configuration file
Abstract settings which commonly differ between instances to a YAML
based configuration file to allow for easy administration without the
need for modifying the source code.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-09-28 19:33:17 +02:00
84696672cd
Add myself as admin
For some administrative operations, such as joining channels, it would
be useful if I could "imp"ersonate the bot.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
2024-09-21 01:09:28 +02:00
mogad0n
379891b2d0
initial commit 2021-03-10 19:33:48 +05:30
alex
85ff6578e8 fixes #8 2019-09-22 10:56:10 +01:00
alex
03d9024509 fixes #9 2019-09-22 10:48:24 +01:00
alex
304fcff75c fixes #5 2019-07-10 16:29:44 +01:00
alex
e1eddb1b11 fixes #6 2019-06-28 18:55:46 +01:00
alex
62144ce8a1 fixes #7 2019-06-28 18:54:32 +01:00
alex
3b9233307a moved config around somewhat 2019-01-04 09:55:40 +00:00
alex
d4c4e38ba8 Added time limited bankrupcy, steroids for benching (don't persist across restarts), removed aliases from command list, ping, strongest, don't allow vlk to roll. 2019-01-04 09:20:39 +00:00
alex
ca91956e27 int64 -> uint64 for coins, disable noisy logging, turned off wattery (it was quickly abused), made anarchy less likely to win and time limited 2018-12-03 23:21:11 +00:00
alex
88d612e041 CanAct func, used in Riot and Lift 2018-11-16 01:01:29 +00:00
alex
7f72f6e3ec added actions table, makes it easier to add time based commands
reactivated bench with a 2400 limit
help command just outputs command structs because that's easier
lower all commands to account for caps mistakes
some hardcoded nick bits :\
removed disused db structs
2018-11-15 02:11:45 +00:00
alex
5c24c985d3 changed coins to uint64 and started using uints all over the place
added toplost
removed an ignore
2018-11-14 22:38:32 +00:00
alex
237d91de16 formatting changes from goimport
added a link to source, healing
parse ints through one function and return helpful errors that can be used as return values
added more error checking
improved some output
made some more joke methods
lazily added more if conditions for people i'm sick of
2018-11-08 10:40:08 +00:00
alex
ecb988a3d9 nm 2018-10-27 14:05:12 +01:00
alex
db4c1257b9 fixed rand to use crypto rand
fixed imp with imps but should go back to privmsg detection
give the bot money when people lose lel
2018-10-26 12:40:27 +01:00
alex
2b1c9889e5 misc improvements
added self reference, allowing the bot to accrue currency
messed about with some messages (removed swears, changed 'schlorped', etc)
improved send output
regular wattery to make 'wat' interesting
2018-10-25 01:04:35 +01:00
alex
30d5e6f076 added resting, messed about with stuff 2018-10-23 02:36:02 +01:00
alex
9120ee3691 fixed some bugs, fixed some debug behaviour, changed over to a command -> method map to avoid sending spurious messages 2018-10-23 00:15:28 +01:00
alex
19716c3afb added admin command for impersonating any irc command
remove db
2018-10-21 13:14:08 +01:00
alex
61b84d9fd9 Reimplemented python bot in golang, skipped a few features 2018-10-21 13:04:35 +01:00