2017-04-16 15:35:12 +02:00
|
|
|
from .base import Base
|
|
|
|
from urllib.request import build_opener, HTTPRedirectHandler
|
2019-09-18 11:01:40 +02:00
|
|
|
import json
|
2017-04-16 15:35:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Meow(Base):
|
|
|
|
name = 'meow'
|
|
|
|
aliases = [':3', '=3']
|
|
|
|
|
2017-08-19 17:19:21 +02:00
|
|
|
def execute(self, command):
|
2017-04-16 15:35:12 +02:00
|
|
|
opener = build_opener(HTTPRedirectHandler)
|
2019-09-18 11:01:40 +02:00
|
|
|
with opener.open('https://api.thecatapi.com/v1/images/search') as r:
|
|
|
|
cats = json.loads(r.read())
|
2017-04-16 15:35:12 +02:00
|
|
|
|
2019-09-18 11:01:40 +02:00
|
|
|
self.send_photo(command, photo=cats[0]['url'])
|