mirror of
https://github.com/Spengreb/sync.git
synced 2026-05-13 19:22:05 +00:00
Add python example bot using lib
This commit is contained in:
parent
0c15e06975
commit
2bdd975c3c
2 changed files with 39 additions and 0 deletions
26
examples/python-simple-bot/bot.py
Normal file
26
examples/python-simple-bot/bot.py
Normal file
|
|
@ -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()
|
||||||
13
examples/python-simple-bot/requirements.txt
Normal file
13
examples/python-simple-bot/requirements.txt
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Reference in a new issue