Skip to content

Instantly share code, notes, and snippets.

@KenwoodFox
Created April 28, 2020 06:33
Show Gist options
  • Save KenwoodFox/b83ca0f7e4e1f8fb3b68b10e3ea63c3c to your computer and use it in GitHub Desktop.
Save KenwoodFox/b83ca0f7e4e1f8fb3b68b10e3ea63c3c to your computer and use it in GitHub Desktop.
import discord
import asyncio
import games.poker
import logging as log
log.basicConfig(filename='last_run.log',level=log.INFO) # Setup logging
current_game = None # initalize with a null game
client = discord.Client()
@client.event
async def on_message(message): # When a message comes in
content = message.content # Get the content of the message
if message.author == client.user:
return #Returns loop if robot says something.
if content.startswith("poker"):
if message.author.name != "Snowsune":
await message.channel.send("Sorry, you are not Snowsune, and i only listen to daddy. :wink:")
return
if "cool beans" in content.strip(): # if in the string content, exists "cool beans"
await message.channel.send("Cool Beans, i heard this message in " + message.channel.name + " and by " + message.author.name) # using await so we sync with discord API, send cool beans ASAP
if "start poker" in content.strip():
if current_game == None:
await message.channel.send("Could not create new game. Game already in progress.")
await message.channel.send("Starting a new poker game.")
current_game = games.poker.texas_holdem(message.author) # Create a new instance of texas holdem
await message.channel.send(current_game.status())
if "define the word is" in content.strip():
log.info("Backdoor routine was called")
await message.channel.send("Force exiting")
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment