Add !scope command

master
Tanner Collin 1 year ago
parent f89e97feb8
commit 8b9ea0f593
  1. 1
      .gitignore
  2. 36
      dreamer.py
  3. 0
      frames/.gitkeep

1
.gitignore vendored

@ -114,3 +114,4 @@ settings.py
*.session-journal
tmp.png
secrets.py
frames/

@ -5,12 +5,15 @@ logging.basicConfig(
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
level=logging.DEBUG if DEBUG else logging.INFO)
import asyncio
import requests
import random
import json
import base64
import time
import re
from PIL import Image
from datetime import datetime, timezone, timedelta
from io import BytesIO
from telethon import TelegramClient, events
@ -18,6 +21,10 @@ import secrets
PROTOSPACE = -1001298858490
JASON = 172033414
TANNER = 79316791
TANNERBOT_MICROSCOPY = -1001886549266
scope_subject = ''
client = TelegramClient('data/dreamer.session', secrets.TG_API_ID, secrets.TG_API_HASH)
@ -56,6 +63,8 @@ def dreamer(prompt, steps=30, seed=1234, height=512, width=512):
return None
async def message_handler(event):
global scope_subject
text = event.raw_text
chat = event.chat_id
@ -90,6 +99,33 @@ async def message_handler(event):
command = command.lower()
#!setscope
if command == 'setscope' and data:
if not reply and sender.id != TANNER:
reply = '> do !scope to look under the microscope'
await event.reply(reply)
if not reply:
scope_subject = data
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)
await reply_msg.forward_to(TANNERBOT_MICROSCOPY)
#!scope
if command == 'scope':
logging.info('Chat: {:<14} | ID: {:<6} | User: {} {} | Command: {} | Data: {}'.format(chat, event.id, name, sender.id, command, data or 'None'))
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)
#!dream
if command == 'dream':

Loading…
Cancel
Save