2020-12-17 02:06:52 +01:00
|
|
|
#!/usr/bin/python3
|
2019-09-19 01:59:13 +02:00
|
|
|
from telegram.ext import Updater, CommandHandler
|
2020-12-17 01:31:57 +01:00
|
|
|
from randstrip import createStrip,readConfig
|
2019-09-19 01:59:13 +02:00
|
|
|
import requests
|
2019-09-24 13:26:31 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
fileDir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
fileDir = fileDir +"/"
|
2019-09-19 01:59:13 +02:00
|
|
|
|
2020-12-29 01:29:51 +01:00
|
|
|
def newStrip(bot, update, args):
|
|
|
|
config = readConfig(platform="telegram",profile=args)
|
2020-12-17 01:31:57 +01:00
|
|
|
status = createStrip(config)
|
2019-09-19 01:59:13 +02:00
|
|
|
if status == 0:
|
|
|
|
try:
|
2021-05-27 16:06:15 +02:00
|
|
|
strip_file=open(config["saveLocation"]+config["filename"],"rb")
|
|
|
|
bot.send_photo(chat_id=update.message.chat_id,photo=strip_file)
|
|
|
|
strip_file.close()
|
2019-09-19 01:59:13 +02:00
|
|
|
except Exception as err:
|
|
|
|
print(err)
|
|
|
|
else:
|
|
|
|
print("Creation of image failed\n")
|
|
|
|
print(status)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-12-17 01:31:57 +01:00
|
|
|
config = readConfig(platform="telegram")
|
|
|
|
with open(config["token"]) as token_file:
|
2019-09-19 01:59:13 +02:00
|
|
|
content = token_file.readlines()
|
|
|
|
token = content[0].strip()
|
|
|
|
updater = Updater(token)
|
|
|
|
dp = updater.dispatcher
|
2020-12-29 01:29:51 +01:00
|
|
|
dp.add_handler(CommandHandler('strip',newStrip, pass_args=True))
|
2019-09-19 01:59:13 +02:00
|
|
|
updater.start_polling()
|
|
|
|
updater.idle()
|