test inspire
This commit is contained in:
+10
-4
@@ -245,6 +245,13 @@ class Shitpost(commands.Cog):
|
|||||||
if 'nee' in answer:
|
if 'nee' in answer:
|
||||||
reactie += 'Nee helaas..'
|
reactie += 'Nee helaas..'
|
||||||
yield from ctx.channel.send(ctx.author.mention + ' ' + reactie)
|
yield from ctx.channel.send(ctx.author.mention + ' ' + reactie)
|
||||||
|
|
||||||
|
def get_inspiration(self):
|
||||||
|
inspiration = requests.get(url='http://inspirobot.me/api?generate=true')
|
||||||
|
if inspiration:
|
||||||
|
return inspiration.text
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True, hidden=False)
|
@commands.command(pass_context=True, hidden=False)
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@@ -253,11 +260,10 @@ class Shitpost(commands.Cog):
|
|||||||
Bijvoorbeeld:
|
Bijvoorbeeld:
|
||||||
!inspire
|
!inspire
|
||||||
"""
|
"""
|
||||||
r = requests.get(url='http://inspirobot.me/api?generate=true')
|
inspo = self.get_inspiration()
|
||||||
if r.status_code == 200:
|
if inspo:
|
||||||
url = r.text
|
|
||||||
em = discord.Embed(title='Uw wijze woorden:', type='photo')
|
em = discord.Embed(title='Uw wijze woorden:', type='photo')
|
||||||
em.set_image(url=url)
|
em.set_image(url=inspo)
|
||||||
try:
|
try:
|
||||||
yield from ctx.message.delete()
|
yield from ctx.message.delete()
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -151,3 +151,8 @@ class TestShitpost(unittest.TestCase):
|
|||||||
tegeltje = self.cog.get_tegeltje("Man who put penis in peanut butter is fucking nuts", "Confucius")
|
tegeltje = self.cog.get_tegeltje("Man who put penis in peanut butter is fucking nuts", "Confucius")
|
||||||
self.assertIsInstance(eriku, discord.Embed)
|
self.assertIsInstance(eriku, discord.Embed)
|
||||||
self.assertIsInstance(tegeltje, discord.Embed)
|
self.assertIsInstance(tegeltje, discord.Embed)
|
||||||
|
|
||||||
|
def test_inspire(self):
|
||||||
|
inspo = self.cog.get_inspiration()
|
||||||
|
self.assertIn("https://", inspo)
|
||||||
|
self.assertIn(".jpg", inspo)
|
||||||
Reference in New Issue
Block a user