|
|
|
@ -20,6 +20,8 @@ from telethon import TelegramClient, events |
|
|
|
|
|
|
|
|
|
import secrets |
|
|
|
|
|
|
|
|
|
TANNERCOIN = -1001394158904 |
|
|
|
|
SANDBOX = -1001258001846 |
|
|
|
|
PROTOSPACE = -1001298858490 |
|
|
|
|
JASON = 172033414 |
|
|
|
|
TANNER = 79316791 |
|
|
|
@ -38,22 +40,22 @@ def snap_size(size): |
|
|
|
|
if s >= size: |
|
|
|
|
return s |
|
|
|
|
|
|
|
|
|
def dreamer(prompt, steps=30, seed=1234, height=512, width=512): |
|
|
|
|
def dreamer(prompt, negative_prompt='', steps=30, seed=1234, height=512, width=512): |
|
|
|
|
url = secrets.DREAM_API |
|
|
|
|
|
|
|
|
|
#sd_settings_json = '{"fn_index":12,"data":["","","None","None",30,"Euler a",false,false,1,1,7,-1,-1,0,0,0,false,512,512,false,false,0.7,"None",false,"Seed","","Steps","",true,false,false,null,"",null,"",""],"session_hash":"qpydye2zzsh"}' |
|
|
|
|
sd_settings_json = '{"fn_index":12,"data":["","","None","None",30,"Euler a",false,false,1,1,7,-1,-1,0,0,0,false,512,512,false,false,0.7,"None",false,false,null,"","Seed","","Nothing","",true,false,null,"",""],"session_hash":"qpydye2zzsh"}' |
|
|
|
|
|
|
|
|
|
sd_settings = json.loads(sd_settings_json) |
|
|
|
|
sd_settings['data'][0] = prompt |
|
|
|
|
sd_settings['data'][4] = steps |
|
|
|
|
sd_settings['data'][11] = seed |
|
|
|
|
sd_settings['data'][17] = snap_size(height) |
|
|
|
|
sd_settings['data'][18] = snap_size(width) |
|
|
|
|
sd_settings = dict( |
|
|
|
|
prompt=prompt, |
|
|
|
|
negative_prompt=negative_prompt, |
|
|
|
|
steps=steps, |
|
|
|
|
seed=seed, |
|
|
|
|
height=snap_size(height), |
|
|
|
|
width=snap_size(width), |
|
|
|
|
save_images=True, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
if width > 512 or height > 512: |
|
|
|
|
# highres fix |
|
|
|
|
sd_settings['data'][19] = True |
|
|
|
|
sd_settings['enable_hr'] = True |
|
|
|
|
|
|
|
|
|
logging.info('Dreaming of: %s', prompt) |
|
|
|
|
|
|
|
|
@ -109,7 +111,7 @@ async def message_handler(event): |
|
|
|
|
|
|
|
|
|
#!chat |
|
|
|
|
if command in ['chat', 'yarr', 'hwhat']: |
|
|
|
|
await client.send_read_acknowledge(event.chat, event.message, clear_mentions=True) |
|
|
|
|
await client.send_read_acknowledge(event.chat, message=event.message, clear_mentions=True) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -149,6 +151,32 @@ async def message_handler(event): |
|
|
|
|
reply = '> error' |
|
|
|
|
await event.reply(reply, link_preview=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#!dumpster |
|
|
|
|
if command == 'dumpster': |
|
|
|
|
logging.info('Chat: {:<14} | ID: {:<6} | User: {} {} | Command: {} | Data: {}'.format(chat, event.id, name, sender.id, command, data or 'None')) |
|
|
|
|
|
|
|
|
|
headers = {'Authorization': 'Basic YWRtaW46NXFoaDM0ZHFqMzRx'} |
|
|
|
|
try: |
|
|
|
|
res = requests.get('http://cameras.dns.t0.vc/image/Dump?&w=9999', headers=headers, timeout=4) |
|
|
|
|
res.raise_for_status() |
|
|
|
|
with open('tmp.jpg', 'wb') as f: |
|
|
|
|
f.write(res.content) |
|
|
|
|
|
|
|
|
|
await event.reply('', file='tmp.jpg', link_preview=False) |
|
|
|
|
except: |
|
|
|
|
reply = '> error' |
|
|
|
|
await event.reply(reply, link_preview=False) |
|
|
|
|
|
|
|
|
|
#!dumpstervid |
|
|
|
|
if command == 'dumpstervid': |
|
|
|
|
logging.info('Chat: {:<14} | ID: {:<6} | User: {} {} | Command: {} | Data: {}'.format(chat, event.id, name, sender.id, command, data or 'None')) |
|
|
|
|
|
|
|
|
|
reply_file = await client.upload_file('dumpster.mp4') |
|
|
|
|
|
|
|
|
|
await event.reply('', file=reply_file, link_preview=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#!garden |
|
|
|
|
if command == 'garden': |
|
|
|
|
logging.info('Chat: {:<14} | ID: {:<6} | User: {} {} | Command: {} | Data: {}'.format(chat, event.id, name, sender.id, command, data or 'None')) |
|
|
|
@ -261,6 +289,7 @@ async def message_handler(event): |
|
|
|
|
reply += '\n> height:512 (512-1024)' |
|
|
|
|
reply += '\n> width:512 (512-1024)' |
|
|
|
|
reply += '\n> seed:number' |
|
|
|
|
reply += '\n> negative_prompt:text,words (no spaces)' |
|
|
|
|
reply += '\n> favourites: https://t.me/+UyMF3ArBe4pmYzQ5' |
|
|
|
|
|
|
|
|
|
if not reply: |
|
|
|
@ -268,6 +297,7 @@ async def message_handler(event): |
|
|
|
|
'steps': 30, |
|
|
|
|
'height': 512, |
|
|
|
|
'width': 512, |
|
|
|
|
'negative_prompt': 'text,words', |
|
|
|
|
'seed': random.randint(11111, 19999), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -345,8 +375,7 @@ async def message_handler(event): |
|
|
|
|
dream_res = dreamer(prompt, **settings) |
|
|
|
|
finish = time.time() |
|
|
|
|
|
|
|
|
|
url_enc = dream_res['data'][0][0] |
|
|
|
|
b64_str = url_enc[22:] |
|
|
|
|
b64_str = dream_res['images'][0] |
|
|
|
|
|
|
|
|
|
reply_file = base64.decodebytes(bytes(b64_str, 'utf-8')) |
|
|
|
|
|
|
|
|
@ -374,6 +403,31 @@ async def message_edited(event): |
|
|
|
|
async def new_message(event): |
|
|
|
|
await message_handler(event) |
|
|
|
|
|
|
|
|
|
@client.on(events.NewMessage) |
|
|
|
|
async def detect_cats(event): |
|
|
|
|
chat = event.chat_id |
|
|
|
|
|
|
|
|
|
if chat not in [PROTOSPACE, TANNERCOIN, SANDBOX]: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
if not event.photo: |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
photo = BytesIO() |
|
|
|
|
await client.download_media(event.photo, photo) |
|
|
|
|
photo.seek(0) |
|
|
|
|
|
|
|
|
|
res = requests.post("http://192.168.0.105:32168/v1/vision/detection", files={'image': photo}).json() |
|
|
|
|
print(res) |
|
|
|
|
|
|
|
|
|
for prediction in res['predictions']: |
|
|
|
|
if prediction['label'] == 'cat' and prediction['confidence'] > 0.70: |
|
|
|
|
logging.info('Found a cat!') |
|
|
|
|
await event.reply('Cat.') |
|
|
|
|
return |
|
|
|
|
except: |
|
|
|
|
logging.info('Failed to try and find a cat.') |
|
|
|
|
|
|
|
|
|
client.start() |
|
|
|
|
client.run_until_disconnected() |
|
|
|
|