Python random.cat() Examples

The following are code examples for showing how to use random.cat(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: CorpBot.py   Author: corpnewt   File: Cats.py    (license) View Source Project 6 votes vote down vote up
def randomcat(self, ctx):
		"""Meow."""
		
		channel = ctx.message.channel
		author  = ctx.message.author
		server  = ctx.message.server
		
		if not self.canDisplay(server):
			return
		
		url = 'http://random.cat/meow'

		# Grab our image url
		r = requests.get(url, headers = {'User-agent': self.ua})

		catURL = r.json()['file']
		
		await GetImage.get(catURL, self.bot, channel, 'A cat for you!', self.ua) 
Example 2
Project: Godavaru   Author: Godavaru   File: cog_utils.py    (license) View Source Project 6 votes vote down vote up
def dog(self, ctx):
        """Get a random cat image!

        **Usage:** `g_dog`

        **Permission:** User"""
        isVideo = True
        while isVideo:
            r = requests.get('https://random.dog/woof.json')
            js = r.json()
            if js['url'].endswith('.mp4'):
                pass
            else:
                isVideo = False
        colours = [0x1abc9c, 0x11806a, 0x2ecc71, 0x1f8b4c, 0x3498db, 0x206694, 0x9b59b6, 0x71368a, 0xe91e63, 0xad1457, 0xf1c40f, 0xc27c0e, 0xa84300, 0xe74c3c, 0x992d22, 0x95a5a6, 0x607d8b, 0x979c9f, 0x546e7a]
        col = int(random.random() * len(colours))
        content = [":dog: Don't be sad! This doggy wants to play with you!", "You seem lonely, {0.mention}. Here, have a dog. They're not as nice as cats, but enjoy!".format(ctx.message.author), "Weuf, woof, woooooooooof. Woof you.", "Pupper!", "Meow... wait wrong animal."]
        con = int(random.random() * len(content))
        em = discord.Embed(color=colours[col])
        em.set_image(url=js['url'])
        await ctx.send(content=content[con], embed=em) 
Example 3
Project: DisKvlt-Bot   Author: MitchWeaver   File: bot.py    (license) View Source Project 6 votes vote down vote up
def cat(ctx):
    """Grabs a random cat picture"""
    r = requests.get("https://random.cat/meow")
    r = str(r.content)
    r = r.replace("b'","")
    r = r.replace("'","")
    r = r.replace("\\","")
    url = json.loads(r)["file"]
    await client.say(url)
    i = random.randint(0, 29)
    if i == 0:
        await asyncio.sleep(3)
        await client.say("MEOW.")
    elif i == 1:
        await asyncio.sleep(3)
        await client.say("I love cats.")
    elif i == 2:
        await asyncio.sleep(3)
        await client.say("*purr...*")

# RANDOM DOG 
Example 4
Project: rowboat   Author: b1naryth1ef   File: utilities.py    (license) View Source Project 6 votes vote down vote up
def cat(self, event):
        # Sometimes random.cat gives us gifs (smh)
        for _ in range(3):
            try:
                r = requests.get('http://random.cat/meow')
                r.raise_for_status()
            except:
                continue

            url = r.json()['file']
            if not url.endswith('.gif'):
                break
        else:
            return event.msg.reply('404 cat not found :(')

        r = requests.get(url)
        r.raise_for_status()
        event.msg.reply('', attachments=[('cat.jpg', r.content)]) 
Example 5
Project: discord_bot   Author: Der-Eddy   File: fun.py    (license) View Source Project 6 votes vote down vote up
def neko(self, ctx):
        '''Zufällige Katzen Bilder nyan~'''
        #http://discordpy.readthedocs.io/en/latest/faq.html#what-does-blocking-mean
        async with aiohttp.ClientSession() as cs:
            async with cs.get('http://random.cat/meow') as r:
                res = await r.json()
                emojis = [':cat2: ', ':cat: ', ':heart_eyes_cat: ']
                await ctx.send(random.choice(emojis) + res['file']) 
Example 6
Project: Luna   Author: Moonlington   File: Funstuff.py    (license) View Source Project 5 votes vote down vote up
def cats(self, ctx):
        async with aiohttp.get('http://random.cat/meow') as r:
            if r.status == 200:
                js = await r.json()
                await self.bot.say(js['file']) 
Example 7
Project: Godavaru   Author: Godavaru   File: cog_utils.py    (license) View Source Project 5 votes vote down vote up
def cat(self, ctx):
        """Get a random cat image!

        **Usage:** `g_cat`

        **Permission:** User"""
        colours = [0x1abc9c, 0x11806a, 0x2ecc71, 0x1f8b4c, 0x3498db, 0x206694, 0x9b59b6, 0x71368a, 0xe91e63, 0xad1457, 0xf1c40f, 0xc27c0e, 0xa84300, 0xe74c3c, 0x992d22, 0x95a5a6, 0x607d8b, 0x979c9f, 0x546e7a]
        col = int(random.random() * len(colours))
        content = [";w; Don't be sad, here's a cat!", "You seem lonely, {0.mention}. Here, have a cat".format(ctx.message.author), "Meeeooowwww!", "Awww, so cute! Look at the kitty!!1!", "Woof... wait wrong animal."]
        con = int(random.random() * len(content))
        r = requests.get('http://random.cat/meow')
        js = r.json()
        em = discord.Embed(color=colours[col])
        em.set_image(url=js['file'])
        await ctx.send(content=content[con], embed=em) 
Example 8
Project: kitsuchan-2   Author: n303p4   File: rng.py    (license) View Source Project 5 votes vote down vote up
def cat(self, ctx):
        """Fetch a random cat."""
        async with ctx.bot.session.get(URL_RANDOM_CAT_API) as response:
            if response.status == 200:
                data = await response.text()
                catto = json.loads(data)
                url = catto["file"]
                await ctx.send(url)
            else:
                await ctx.send("Could not reach random.cat. :<") 
Example 9
Project: goldmine   Author: Armored-Dragon   File: cosmetic.py    (license) View Source Project 5 votes vote down vote up
def cat(self, ctx):
        """Get a random cat! Because why not.
        Usage: cat"""
        with async_timeout.timeout(8):
            async with self.bot.cog_http.get('http://random.cat/meow') as response:
                ret = await response.json()
        e = discord.Embed(color=random.randint(1, 255**3-1))
        e.set_image(url=ret['file'])
        await ctx.send(embed=e) 
Example 10
Project: tuxbot-bot   Author: outout14   File: funs.py    (license) View Source Project 5 votes vote down vote up
def randomcat(self, ctx):
        """Display a random cat"""

        r = requests.get('http://random.cat/meow.php')
        cat = str(r.json()['file'])
        embed = discord.Embed(title="Meow", description="[Voir le chat plus grand]({})".format(cat), colour=0x03C9A9)
        embed.set_thumbnail(url=cat)
        embed.set_author(name="Random.cat", url='https://random.cat/', icon_url='http://outout.tech/tuxbot/nyancat2.gif')
        await ctx.send(embed=embed) 
Example 11
Project: Tuxedo   Author: ClarityMoe   File: lul.py    (license) View Source Project 5 votes vote down vote up
def cat(self, ctx):
        with ctx.channel.typing():
            with aiohttp.ClientSession() as session:
                async with session.get("http://random.cat/meow") as r:
                    r = await r.read()
                    url = json.JSONDecoder().decode(r.decode("utf-8"))["file"]
                    await ctx.send(embed=discord.Embed(title="Random Cat").set_image(url=url).set_footer(text="Powered by random.cat")) 
Example 12
Project: Turbo   Author: jaydenkieran   File: commands.py    (license) View Source Project 4 votes vote down vote up
def c_cat(self):
        """
        Sends a random cat picture

        {prefix}cat
        """
        cat = await self.req.get('http://random.cat/meow')
        return Response(cat['file'])