-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_discord.py
46 lines (33 loc) · 1.14 KB
/
run_discord.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Derived from a modification of a test script by Rapptz, by TAOTheCrab, by me.
# (You get all that?)
import discord
import logging
import td2tasks
import yaml
client = discord.Client()
logging.basicConfig(level=logging.INFO)
@client.event
async def on_ready():
print("Logged in as")
print(client.user.name)
print(client.user.id)
print("------")
@client.event
async def on_message(message):
# We do not want the bot to reply to itself
if message.author == client.user:
return
if "!patchnotes" in message.content:
response = td2tasks.patchnotes.run(message.content)
if response and response != "":
name = response.split("]")[0][1:]
response = ("**" + name + "**" + response.split("):")[1])
await client.send_message(message.channel, response)
if "!teamsummary" in message.content:
response = td2tasks.newteamsummary.run(message.content)
if response and response != "":
await client.send_message(message.channel, response)
with open("config_discord.yml") as file:
config = yaml.safe_load(file)
token = config["token"]
client.run(token)