-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (52 loc) · 3.14 KB
/
main.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import discord
import os
import requests
import json
import yaml
SC = open('Starcraft.json')
SCData = json.load(SC)
SCDataFinal = json.dumps(SCData['Starcraft'][0]["Marine"][0]["Strong Against"]["Zerg"],indent=4)
my_secret = os.environ['TOKEN']
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('!'):
input = message.content[1:]
splitInput = input.split(' ')
firstInput = splitInput[0].title()
shortcut_word = ["bc", "st", "ht", "dt", "wm", "pf", "mt", "at", "sh", "bl", "nd", "wp", "vr", "pc", "sb"]
properly_word = ["Battlecruiser", "Siege Tank", "High Templar", "Dark Templar", "Widow Mine", "Planetary Fortress", "Missile Turret", "Auto Turret", "Swarm Host", "Brood Lord", "Nydus Worm", "Warp Prism", "Void Ray", "Photon Cannon", "Shield Battery"]
try:
if len(splitInput) == 1:
for word in shortcut_word:
if firstInput.lower() == word:
counter = shortcut_word.index(word)
firstInput = properly_word[counter]
await message.channel.send(yaml.safe_dump(SCData['Starcraft'][0][firstInput], indent=4))
if len(splitInput) > 1:
if "." in input:
dotInput = input.split('.')
twoWordInput = dotInput[0].rstrip()
twoWordInputSecond = dotInput
for word in shortcut_word:
if twoWordInput == word:
counter = shortcut_word.index(word)
twoWordInput = properly_word[counter]
if ("Zerg" in twoWordInputSecond) or ("zerg" in twoWordInputSecond):
await message.channel.send("Strong Against: " + yaml.dump(SCData['Starcraft'][0][twoWordInput.title()][0]["Strong Against"]["Zerg"], default_style="", explicit_end=None) + "Weak Against: " + yaml.dump(SCData['Starcraft'][0][twoWordInput.title()][1]["Weak Against"]["Zerg"], default_style="", explicit_end=None))
elif ("Protoss" in twoWordInputSecond) or ("protoss" in twoWordInputSecond):
await message.channel.send("Strong Against: " + yaml.dump(SCData['Starcraft'][0][twoWordInput.title()][0]["Strong Against"]["Protoss"], default_style="", explicit_end=None) + "Weak Against: " + yaml.dump(SCData['Starcraft'][0][twoWordInput.title()][1]["Weak Against"]["Protoss"], default_style="", explicit_end=None))
elif (".Terran" in twoWordInputSecond) or ("terran" in twoWordInputSecond):
await message.channel.send("Strong Against: " + yaml.dump(SCData['Starcraft'][0][twoWordInput.title()][0]["Strong Against"]["Terran"], default_style="", explicit_end=None) + "Weak Against: " + yaml.dump(SCData['Starcraft'][0][twoWordInput.title()][1]["Weak Against"]["Terran"], default_style="", explicit_end=None))
else: return
if not "." in input:
secondInput = splitInput[1].title()
await message.channel.send(yaml.safe_dump(SCData['Starcraft'][0][firstInput + ' ' + secondInput], indent=4))
except:
await message.channel.send('Wrong unit name or something')
client.run(my_secret)