bot client

This commit is contained in:
Diego 2026-04-11 14:36:49 -07:00
commit 8eaa8e3adf
4 changed files with 307 additions and 5 deletions

26
examples/botexample.py Normal file
View file

@ -0,0 +1,26 @@
import os, sys
sys.path.append(os.path.abspath("../"))
from botclient import r2bot
import time
bot = r2bot(channel="chat", username="genericbot")
def mainhandler(msg):
if "/test" in msg:
bot.send("hello world")
def mentionhandler(msg):
bot.send("mentioned")
bot.on("on_message", mainhandler)
bot.on("on_mention", mentionhandler)
try:
print("Bot is running.")
while True:
bot.poll()
time.sleep(1)
except KeyboardInterrupt:
print("Stopping bot.")
bot.leave_channel()