|
|
|
@ -12,6 +12,7 @@ import json |
|
|
|
|
import base64 |
|
|
|
|
import time |
|
|
|
|
import re |
|
|
|
|
import pytz |
|
|
|
|
from PIL import Image |
|
|
|
|
from datetime import datetime, timezone, timedelta |
|
|
|
|
from io import BytesIO |
|
|
|
@ -24,7 +25,10 @@ JASON = 172033414 |
|
|
|
|
TANNER = 79316791 |
|
|
|
|
TANNERBOT_MICROSCOPY = -1001886549266 |
|
|
|
|
|
|
|
|
|
TIMEZONE_TANNER = pytz.timezone('America/Edmonton') |
|
|
|
|
|
|
|
|
|
scope_subject = '' |
|
|
|
|
scope_zoom = '' |
|
|
|
|
|
|
|
|
|
client = TelegramClient('data/dreamer.session', secrets.TG_API_ID, secrets.TG_API_HASH) |
|
|
|
|
|
|
|
|
@ -63,7 +67,7 @@ def dreamer(prompt, steps=30, seed=1234, height=512, width=512): |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
async def message_handler(event): |
|
|
|
|
global scope_subject |
|
|
|
|
global scope_subject, scope_zoom |
|
|
|
|
|
|
|
|
|
text = event.raw_text |
|
|
|
|
chat = event.chat_id |
|
|
|
@ -99,6 +103,25 @@ async def message_handler(event): |
|
|
|
|
|
|
|
|
|
command = command.lower() |
|
|
|
|
|
|
|
|
|
#!garden |
|
|
|
|
if command == 'garden': |
|
|
|
|
headers = {'Authorization': 'Basic YWRtaW46NXFoaDM0ZHFqMzRx'} |
|
|
|
|
try: |
|
|
|
|
res = requests.get('http://cameras.dns.t0.vc/image/G-1?&w=9999', headers=headers, timeout=4) |
|
|
|
|
res.raise_for_status() |
|
|
|
|
with open('tmp.jpg', 'wb') as f: |
|
|
|
|
f.write(res.content) |
|
|
|
|
|
|
|
|
|
start = datetime(2023, 3, 5, 19, 0, tzinfo=TIMEZONE_TANNER) |
|
|
|
|
delta = datetime.now(pytz.utc) - start |
|
|
|
|
reply = '> secret garden #3 day {}'.format(delta.days + 1) |
|
|
|
|
reply += '\n> iceberg lettuce' |
|
|
|
|
await event.reply(reply, file='tmp.jpg', link_preview=False) |
|
|
|
|
except: |
|
|
|
|
reply = '> error' |
|
|
|
|
await event.reply(reply, link_preview=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#!setscope |
|
|
|
|
if command == 'setscope' and data: |
|
|
|
|
if not reply and sender.id != TANNER: |
|
|
|
@ -108,10 +131,20 @@ async def message_handler(event): |
|
|
|
|
if not reply: |
|
|
|
|
scope_subject = data |
|
|
|
|
|
|
|
|
|
for zoom in ['4x', '10x', '40x']: |
|
|
|
|
if zoom in scope_subject: |
|
|
|
|
scope_zoom = zoom |
|
|
|
|
scope_subject = scope_subject.replace(zoom, '') |
|
|
|
|
|
|
|
|
|
now = datetime.now(tz=timezone.utc) - timedelta(seconds=1) |
|
|
|
|
reply = '> ' + scope_subject |
|
|
|
|
reply_file = 'frames/' + now.strftime('image%S.jpg') |
|
|
|
|
reply_msg = await event.reply(reply, file=reply_file, link_preview=False) |
|
|
|
|
file_name = 'frames/' + now.strftime('image%S.jpg') |
|
|
|
|
frame = Image.open(file_name) |
|
|
|
|
if scope_zoom: |
|
|
|
|
label = Image.open(scope_zoom + '_label.png') |
|
|
|
|
frame.paste(label, (0,0), label) |
|
|
|
|
frame.save('tmp.jpg') |
|
|
|
|
reply_msg = await event.reply(reply, file='tmp.jpg', link_preview=False) |
|
|
|
|
|
|
|
|
|
await reply_msg.forward_to(TANNERBOT_MICROSCOPY) |
|
|
|
|
|
|
|
|
@ -122,9 +155,15 @@ async def message_handler(event): |
|
|
|
|
if not reply: |
|
|
|
|
|
|
|
|
|
now = datetime.now(tz=timezone.utc) - timedelta(seconds=1) |
|
|
|
|
reply = '> ' + scope_subject |
|
|
|
|
reply_file = 'frames/' + now.strftime('image%S.jpg') |
|
|
|
|
reply_msg = await event.reply(reply, file=reply_file, link_preview=False) |
|
|
|
|
if scope_subject: |
|
|
|
|
reply = '> ' + scope_subject |
|
|
|
|
file_name = 'frames/' + now.strftime('image%S.jpg') |
|
|
|
|
frame = Image.open(file_name) |
|
|
|
|
if scope_zoom: |
|
|
|
|
label = Image.open(scope_zoom + '_label.png') |
|
|
|
|
frame.paste(label, (0,0), label) |
|
|
|
|
frame.save('tmp.jpg') |
|
|
|
|
reply_msg = await event.reply(reply, file='tmp.jpg', link_preview=False) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#!dream |
|
|
|
|