organize in several files

This commit is contained in:
Bibin Muttappillil 2020-04-02 20:47:11 +02:00
parent 15b695851d
commit 9b367001b4
10 changed files with 495 additions and 879 deletions

65
src/werewolf_bot.py Normal file
View file

@ -0,0 +1,65 @@
import os
import discord
import asyncio
from dotenv import load_dotenv
from werewolf_game import Game as Werewolf_Game
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
if TOKEN is None:
print("Missing discord token!")
exit(1)
bot = discord.Client()
@bot.event
async def on_ready():
print('We have logged in as {0.user}'.format(bot))
async def hello(message):
print("Hello")
await message.channel.send('Hello!:regional_indicator_a:')
print(message.mentions)
@bot.event
async def on_message(message):
global running
if message.author == bot.user:
return
if message.content.startswith('$hello'):
await hello(message)
return
if message.content.startswith('$logout'):
await bot.logout()
return
if message.content.startswith('$werewolf'):
# start (only one instance running)
if werewolf_game.running:
await message.channel.send("Sorry! A game is already running")
return
werewolf_game.running = True
werewolf_game.set_channel(message.channel)
await werewolf_game.game()
return
werewolf_game = Werewolf_Game(bot)
bot.run(TOKEN)