From b389988a92aa54192b41f11408317d23d88161f9 Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Tue, 31 Mar 2020 01:00:06 +0200 Subject: [PATCH] Commenting in gwendolyn.py --- Gwendolyn.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Gwendolyn.py b/Gwendolyn.py index 5792695..19bf9d1 100644 --- a/Gwendolyn.py +++ b/Gwendolyn.py @@ -11,11 +11,13 @@ import funcs logging.basicConfig(filename="gwendolyn.log", level=logging.INFO) +# Gets secret bot token with open("token.txt","r") as f: token = f.read().replace("\n","") client = discord.Client() +# Logs in @client.event async def on_ready(): localtime = time.asctime( time.localtime(time.time()) ) @@ -28,8 +30,10 @@ async def on_ready(): game = discord.Game("Some weeb shit") await client.change_presence(activity=game) +# Reads messages and tests if they are Gwendolyn commands @client.event async def on_message(message): + # Sends the contents of "help.txt" if message.content.lower().startswith("!help"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !help") @@ -40,18 +44,21 @@ async def on_message(message): em = discord.Embed(title = "Help", description = text,colour = 0x59f442) await message.channel.send(embed = em) + # Stops the bot elif message.content.lower().startswith("!stop"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !stop") logging.info("\n"+localtime+"\n"+message.author.name+" ran !stop") await client.logout() + # Does a hello with the helloFunc function from funcs/gwendolynFuncs.py elif message.content.lower().startswith("!hello"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !hello") logging.info("\n"+localtime+"\n"+message.author.name+" ran !hello") await message.channel.send(funcs.helloFunc(message.author.name)) + # Rolls dice with the roll_dice function from funcs/roll/dice.py elif message.content.lower().startswith("!roll"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !roll") @@ -61,12 +68,14 @@ async def on_message(message): else: await message.channel.send(funcs.roll_dice(message.author.name, message.content.lower().replace("!roll",""))) + # Looks up a spell with the spellFunc function from funcs/lookup/lookupFuncs.py elif message.content.lower().startswith("!spell "): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !spell") logging.info("\n"+localtime+"\n"+message.author.name+" ran !spell") await message.channel.send(funcs.spellFunc(message.content)) + # Looks up a monster with the monsterFuncs() from funcs/lookup/lookupFuncs.py elif message.content.lower().startswith("!monster "): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !monster") @@ -114,18 +123,23 @@ async def on_message(message): em5_2 = discord.Embed(title = "", description = text5[2048:], colour=0xDEADBF) await message.channel.send(embed = em5_2) + # Sends an image of the Senkulpa map elif message.content.lower().startswith("!map"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !map") logging.info("\n"+localtime+"\n"+message.author.name+" ran !map") await message.channel.send("https://i.imgur.com/diMXXJs.jpg") + # Finds a random image on the internet with the imageFuncs function from + # funcs/gwendolynFuncs.py elif message.content.lower().startswith("!image"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !image") logging.info("\n"+localtime+"\n"+message.author.name+" ran !image") await message.channel.send(funcs.imageFunc()) + # Sends information about a random movie with the movieFunc function from + # funcs/other/movie.py elif message.content.lower().startswith("!movie"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !movie") @@ -140,18 +154,21 @@ async def on_message(message): embed.add_field(name="Cast", value=cast,inline = True) await message.channel.send(embed = embed) + # Generates a random name with the nameGen function from funcs/other/generators.py elif message.content.lower().startswith("!name"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !name") logging.info("\n"+localtime+"\n"+message.author.name+" ran !name") await message.channel.send(funcs.nameGen()) + # Generates a random tavern name with the tavernGen function from funcs/other/generators.py elif message.content.lower().startswith("!tavern"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !tavern") logging.info("\n"+localtime+"\n"+message.author.name+" ran !tavern") await message.channel.send(funcs.tavernGen()) + # Changes the "Playing this game" thing in Discord elif message.content.lower().startswith("!game "): gamePlaying = funcs.cap(message.content.lower().replace("!game ","")) localtime = time.asctime( time.localtime(time.time()) ) @@ -160,6 +177,7 @@ async def on_message(message): game = discord.Game(gamePlaying) await client.change_presence(activity=game) + # Rolls star wars dice with the parseRoll function from funcs/swfuncs/swroll.py elif message.content.lower().startswith("!swroll"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !swroll") @@ -167,6 +185,8 @@ async def on_message(message): command = funcs.cap(message.content.lower().replace("!swroll","")) await message.channel.send(funcs.parseRoll(message.author.name,command)) + # Accesses and changes character sheet data with the parseChar function + # from funcs/swfuncs/swchar.py elif message.content.lower().startswith("!swchar"): localtime = time.asctime(time.localtime(time.time())) print("\n"+localtime+"\n"+message.author.name+" ran !swchar") @@ -180,5 +200,6 @@ async def on_message(message): await message.channel.send(desc) +# Runs the whole shabang client.run(token)