From 2bdd975c3c0a751ed8c2a81b2464f914f4138faf Mon Sep 17 00:00:00 2001 From: Speng Reb Date: Tue, 5 May 2026 01:34:00 +0200 Subject: [PATCH] Add python example bot using lib --- examples/python-simple-bot/bot.py | 26 +++++++++++++++++++++ examples/python-simple-bot/requirements.txt | 13 +++++++++++ 2 files changed, 39 insertions(+) create mode 100644 examples/python-simple-bot/bot.py create mode 100644 examples/python-simple-bot/requirements.txt diff --git a/examples/python-simple-bot/bot.py b/examples/python-simple-bot/bot.py new file mode 100644 index 00000000..a80a9563 --- /dev/null +++ b/examples/python-simple-bot/bot.py @@ -0,0 +1,26 @@ +from veretube_bot import Bot, Rank + +bot = Bot( + token="TOKEN_HERE", + channel="CHANNEL_NAME_HERE", + socket_url="http://localhost:1337", + api_url="http://localhost:8080/api/v1" +) + +@bot.on("chatMsg") +def on_chat(data): + if data["msg"] == "!playlist": + playlist = bot.api.get_playlist() + bot.send_message(f"{len(playlist['items'])} items in queue") + elif data["msg"].startswith("!kick "): + name = data["msg"].split(" ", 1)[1] + bot.kick(name, "Kicked by command") + elif data["msg"] == "!emotes": + emotes = bot.get_emotes() + print(emotes) + +@bot.on("changeMedia") +def on_media(data): + bot.send_message(f"Now playing: {data['title']}") + +bot.run() diff --git a/examples/python-simple-bot/requirements.txt b/examples/python-simple-bot/requirements.txt new file mode 100644 index 00000000..204e0e07 --- /dev/null +++ b/examples/python-simple-bot/requirements.txt @@ -0,0 +1,13 @@ +bidict==0.23.1 +certifi==2026.4.22 +charset-normalizer==3.4.7 +h11==0.16.0 +idna==3.13 +python-engineio==4.13.1 +python-socketio==5.16.1 +requests==2.33.1 +simple-websocket==1.1.0 +urllib3==2.6.3 +veretube-bot==0.1.0 +websocket-client==1.9.0 +wsproto==1.3.2