Browse Source

compatible with v.13.1.1 of python-telegram

oloturia 1 year ago
parent
commit
5c9473fcc9
1 changed files with 24 additions and 24 deletions
  1. 24 24
      telegram_main.py

+ 24 - 24
telegram_main.py

@@ -7,28 +7,28 @@ import os
 fileDir = os.path.dirname(os.path.abspath(__file__))
 fileDir = fileDir +"/"
 
-def newStrip(bot, update, args):
-	config = readConfig(platform="telegram",profile=args)
-	status = createStrip(config)
-	if status == 0:
-		try:
-			strip_file=open(config["saveLocation"]+config["filename"],"rb")
-			bot.send_photo(chat_id=update.message.chat_id,photo=strip_file)
-			strip_file.close()
-			os.remove(config["saveLocation"]+config["filename"])
-		except Exception as err:
-			print(err)
-	else:
-		print("Creation of image failed\n")
-		print(status)
-	
+def newStrip(update, context):
+    config = readConfig(platform="telegram",profile=context.args)
+    status = createStrip(config)
+    if status == 0:
+        try:
+            strip_file=open(config["saveLocation"]+config["filename"],"rb")
+            context.bot.send_photo(chat_id=update.message.chat_id,photo=strip_file)
+            strip_file.close()
+            os.remove(config["saveLocation"]+config["filename"])
+        except Exception as err:
+            print(err)
+    else:
+        print("Creation of image failed\n")
+        print(status)
+    
 if __name__ == "__main__":
-	config = readConfig(platform="telegram")
-	with open(config["token"]) as token_file:
-		content = token_file.readlines()
-	token = content[0].strip()
-	updater = Updater(token)
-	dp = updater.dispatcher
-	dp.add_handler(CommandHandler('strip',newStrip, pass_args=True))
-	updater.start_polling()
-	updater.idle()
+    config = readConfig(platform="telegram")
+    with open(config["token"]) as token_file:
+        content = token_file.readlines()
+    token = content[0].strip()
+    updater = Updater(token, use_context=True)
+    dp = updater.dispatcher
+    dp.add_handler(CommandHandler('strip',newStrip, pass_args=True))
+    updater.start_polling()
+    updater.idle()