Initial commit adding the test code

This commit is contained in:
JKuijperM 2023-01-05 15:04:40 +01:00
parent ca1dc02e83
commit ee4261755d
3 changed files with 56 additions and 0 deletions

1
.gitignore vendored
View File

@ -109,6 +109,7 @@ venv/
ENV/
env.bak/
venv.bak/
.idea
# Spyder project settings
.spyderproject

13
Pipfile Normal file
View File

@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
twitchio = "*"
[dev-packages]
[requires]
python_version = "3.10"
python_full_version = "3.10.8"

42
bot.py Normal file
View File

@ -0,0 +1,42 @@
import os
from twitchio.ext import commands
class Bot(commands.Bot):
def __init__(self):
super().__init__(token=os.environ['TMI_TOKEN'],
# client_id=os.environ['CLIENT_ID'],
nick=os.environ['BOT_NICK'],
prefix=os.environ['BOT_PREFIX'],
initial_channels=[os.environ['CHANNEL']])
async def event_ready(self):
# We are logged in and ready to chat and use commands...
print(f'Logged in as | {self.nick}')
print(f'User id is | {self.user_id}')
await bot.connected_channels[0].send('/me El brujero ha llegado!')
async def event_message(self, message):
# Messages with echo set to True are messages sent by the bot...
# For now we just want to ignore them...
if message.echo:
return
# Print the contents of our message to console...
print(message.content)
# Since we have commands and are overriding the default `event_message`
# We must let the bot know we want to handle and invoke our commands...
await self.handle_commands(message)
@commands.command()
async def hello(self, ctx: commands.Context):
# Send a hello back!
await ctx.send('Hello world')
if __name__ == "__main__":
bot = Bot()
bot.run()