2021-05-08 06:50:39 +00:00
|
|
|
from io import BytesIO
|
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
from base64 import b64encode
|
|
|
|
from qrcode import make as qrcode_make
|
2021-05-10 20:09:55 +00:00
|
|
|
from telegram.error import Unauthorized
|
2021-05-08 06:50:39 +00:00
|
|
|
|
2020-08-06 05:52:36 +00:00
|
|
|
from tipbot import config
|
|
|
|
|
|
|
|
def is_tg_admin(chat_id):
|
|
|
|
if chat_id == config.TG_ADMIN_ID:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
2021-05-08 06:50:39 +00:00
|
|
|
|
|
|
|
def generate_qr(s):
|
|
|
|
_address_qr = BytesIO()
|
|
|
|
qrcode_make(s).save(_address_qr, format="PNG")
|
|
|
|
_address_qr.seek(0)
|
|
|
|
return _address_qr
|
2021-05-10 20:09:55 +00:00
|
|
|
|
2021-05-13 15:14:10 +00:00
|
|
|
def reply_user(msg, context, text, pm=True, delete=False):
|
2021-05-10 20:09:55 +00:00
|
|
|
try:
|
|
|
|
if pm:
|
|
|
|
msg.from_user.send_message(text)
|
|
|
|
else:
|
|
|
|
msg.reply_text(text)
|
|
|
|
except Unauthorized:
|
2021-05-19 20:29:22 +00:00
|
|
|
msg.reply_text(f'You have to initiate a convo with the bot first: https://t.me/{context.bot.username}')
|
2021-05-10 20:09:55 +00:00
|
|
|
except:
|
2021-05-19 20:29:22 +00:00
|
|
|
msg.reply_text(f'Something borked -_-')
|
2021-05-10 20:09:55 +00:00
|
|
|
|
|
|
|
if delete:
|
|
|
|
msg.delete()
|