Merge pull request #274 from fred777/fred777-add_bot_globals

Introduce _bot_globals for persistent data storage between bot executions
This commit is contained in:
Jack Kingsman
2026-06-20 18:03:56 -07:00
committed by GitHub
2 changed files with 13 additions and 0 deletions
@@ -103,6 +103,15 @@ const DEFAULT_BOT_CODE = `def bot(**kwargs) -> str | list[str] | None:
# Don't reply to our own outgoing messages
if is_outgoing:
return None
# If you want to make use of persistant data between calls to this function,
# you can put that data into the global _bot_globals dictionary, e.g.:
#
# bot_globals = globals()["_bot_globals"]
# if not "known_sender_names" in bot_globals:
# bot_globals["known_sender_names"] = set()
#
# bot_globals["known_sender_names"].add(sender_name)
# Example: Only respond in #bot channel to "!pling" command
if channel_name == "#bot" and "!pling" in message_text.lower():