jrabbit / pyborg-1up

:robot: A modern overhaul of an old favorite irc bot for multiple platforms
https://pyborg.readthedocs.io/en/latest/
GNU General Public License v3.0
33 stars 12 forks source link

Trigger words #118

Open researcx opened 4 years ago

researcx commented 4 years ago

Have a configurable list of trigger words and a configuration option for % chance to reply upon a word being said. Perhaps do something like how weechat's highlights work.

This could also change how #26 is done as users could just have bot's nick in the list and optionally put a "(?-i)" before it to make it case sensitive if desired, you could just set the default/example as the bot's nick.

Example:

# Trigger words
# Put "(?-i)" before a word to make it case sensitive
# Words may begin or end with "*" for partial match
trigger_words = ["(?-i)Pyborg"]
# Chance of reply (%) per trigger word
trigger_reply_chance = 100
researcx commented 4 years ago

i've implemented the changes for the IRC module in my personal fork that i use for my network i decided to make multiple sets of trigger words, global and channel-specific, and allow the setting of chance percentages per each word, whilst trying not to make it too inconvenient to set up for end-users

the code: https://github.com/unendingPattern/pyborg-1up/blob/trigger-words/pyborg/pyborg/mod/mod_irc.py#L137

the config options: https://github.com/unendingPattern/pyborg-1up/blob/trigger-words/pyborg/example.irc.toml#L23 https://github.com/unendingPattern/pyborg-1up/blob/trigger-words/pyborg/example.irc.toml#L44

it probably wouldn't be difficult to implement this for the other protocols, personally i'm only using the IRC module for now

i can also open a PR for this if you wish