-
Notifications
You must be signed in to change notification settings - Fork 10
/
pugbot.py
47 lines (33 loc) · 1.22 KB
/
pugbot.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
47
import json
import os
import discord
# Commands #
from commands.pug import pug
CLIENT = discord.Client()
def config_value(key):
with open(os.path.join(os.path.dirname(__file__), 'config.json')) as config_file:
config = json.load(config_file)
try:
value = os.environ[key.upper()]
except KeyError:
value = config.get(key)
return value
@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):
if message.content.startswith('!info') or message.content.startswith('!help'):
await CLIENT.send_message(message.channel, "I'm PugBot, the pug analyzer!\n"
"Use: !pug <name> <server> <region> \n"
"Example: !pug Basimot Lightbringer us")
if message.content.startswith('!pug'):
await pug(CLIENT, DEFAULT_REGION, BLIZZARD_API_KEY, message)
if __name__ == '__main__':
BLIZZARD_API_KEY = config_value('blizzard_api_key')
DEFAULT_REGION = config_value('default_region')
DISCORD_TOKEN = config_value('discord_token')
CLIENT.run(DISCORD_TOKEN)