-
Notifications
You must be signed in to change notification settings - Fork 8
/
mtg.py
18 lines (17 loc) · 833 Bytes
/
mtg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import requests
import sopel
@sopel.module.commands('mtg','magic')
def mtg(bot,trigger):
if not trigger.group(2):
return bot.say("Please enter a card name.")
x = requests.get('https://api.magicthegathering.io/v1/cards?name={0}'.format(trigger.group(2))).json()
if not x['cards']:
return bot.say('Card not found.')
js = x['cards'][0]
if 'Creature' in js['types']:
if 'power' in js:
bot.say('{0} [{1}] {2}| {3} | {4}/{5}'.format(js['name'], js['type'], js.get('manaCost', ''), js.get('text',''), js['power'], js['toughness']))
else:
bot.say('{0} [{1}] {2}| {3}'.format(js['name'], js['type'], js.get('manaCost',''), js.get('text','')))
else:
bot.say('{0} [{1}] {2}| {3}'.format(js['name'], js['type'], js.get('manaCost', ''), js.get('text','')))