-
Notifications
You must be signed in to change notification settings - Fork 0
/
oboobs.py
39 lines (35 loc) · 1.01 KB
/
oboobs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
import hook
def getBodyPart(part):
request = requests.get("http://api.o{}.ru/{}/0/1/random".format(part, part))
data = request.json()
url = 'http://media.o{}.ru/{}/{}.jpg'.format(part, part, str(data[0]['id']).zfill(5))
test = requests.get(url)
if test.status_code == 200:
return url
else:
return False
def fetchBodyPart(part):
retry_count = 3
while retry_count > 0:
parts = getBodyPart(part)
if parts:
return parts
retry_count -= 1
return None
@hook.command('boobs')
def oboobs(bot, update):
part = fetchBodyPart('boobs')
if not part:
update.message.reply_text('found no boobs for you')
else:
update.message.reply_photo(photo=part)
@hook.command('butts')
def obutts(bot, update):
part = fetchBodyPart('butts')
if not part:
update.message.reply_text('found no butt for you')
else:
update.message.reply_photo(photo=part)