imaginaryfriend/src/handler/commands/borscht.py

17 lines
593 B
Python
Raw Normal View History

2017-04-16 15:35:12 +02:00
from .base import Base
2018-06-27 23:26:31 +02:00
from urllib.request import urlopen, Request
2017-04-16 15:35:12 +02:00
class Borscht(Base):
name = 'borscht'
2018-06-27 23:26:31 +02:00
path = 'storage/borscht.jpg'
headers = {'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36"}
2017-04-16 15:35:12 +02:00
2017-08-19 17:19:21 +02:00
def execute(self, command):
2018-06-27 23:26:31 +02:00
req = Request("http://loremflickr.com/500/410/borscht,soup/all", headers=self.headers)
output = open(self.path, "wb")
output.write(urlopen(req).read())
output.close()
2017-04-16 15:35:12 +02:00
2018-06-27 23:26:31 +02:00
self.send_photo(command, photo=open(self.path, 'rb'))