|
@@ -12,6 +12,8 @@ import json
|
|
|
import time
|
|
|
import subprocess
|
|
|
import random
|
|
|
+from telegram.ext import Updater, MessageHandler, Filters
|
|
|
+
|
|
|
|
|
|
scriptpath = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
@@ -247,6 +249,38 @@ def getposition(file):
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+def __msg_parser(bot, update):
|
|
|
+ print("Messaggio ricevuto")
|
|
|
+ urlz = update.message.text
|
|
|
+ u = update.message.from_user
|
|
|
+ user = "t_" + "-".join([i for i in [str(u.id), u.username] if i])
|
|
|
+ #print (urlz)
|
|
|
+ #print (user)
|
|
|
+
|
|
|
+ #update.message.reply_text("Ciao " + update.message.from_user.username)
|
|
|
+ update.message.reply_text("Messaggio ricevuto. Elaboro...")
|
|
|
+
|
|
|
+ for url in [s for s in urlz.splitlines() if s.strip() != ""]:
|
|
|
+ #update.message.reply_text("Scarico %s" %(url))
|
|
|
+ # start the download
|
|
|
+ dl = playlistalo.add(url, user)
|
|
|
+ update.message.reply_text(dl)
|
|
|
+
|
|
|
+def telegram_bot():
|
|
|
+ print ("Bot avviato")
|
|
|
+ # Create the EventHandler and pass it your bot's token.
|
|
|
+ updater = Updater(os.environ['TELEGRAM_TOKEN'])
|
|
|
+ # Get the dispatcher to register handlers
|
|
|
+ dp = updater.dispatcher
|
|
|
+ # parse message
|
|
|
+ dp.add_handler(MessageHandler(Filters.text, __msg_parser))
|
|
|
+ # Start the Bot
|
|
|
+ updater.start_polling()
|
|
|
+ # Run the bot until you press Ctrl-C
|
|
|
+ updater.idle()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
print ("This is a package, use other commands to run it")
|
|
|
- getposition("playlist/Itec78/20200404145736|George Baker- Little Green Bag|4b1wt3-zpzQ.m4az")
|