diff --git a/index.py b/index.py index 83a6e39..43da263 100644 --- a/index.py +++ b/index.py @@ -21,6 +21,7 @@ import pyshorteners import pdf2docx import PyPDF2 import urllib +from currency_converter import CurrencyConverter from googletrans import Translator from random import randint from random import random @@ -353,7 +354,7 @@ def uptime_step(message): # bot.send_message(message.chat.id, "Si รจ verificato un errore") #Command /convert -@bot.message_handler(commands=["convert"]) +@bot.message_handler(commands=["convertpdf"]) def addfile(message): logging.info("Triggered CONVERT") sent_msg = bot.send_message(message.chat.id, "Manda il file pdf che vuoi convertire in docx") @@ -444,4 +445,27 @@ def translatepdf_step(message): bot.send_message(message.chat.id, translated_text.text) os.remove(input_file_position) os.remove(text_file_position) + +#Command /convertmoney +@bot.message_handler(commands=["convertmoney"]) +def convertmoney(message): + logging.info("Triggered CONVERT MONEY") + text = message.text + sent_msg = bot.send_message(message.chat.id, "In che valuta vuoi convertire?") + bot.register_next_step_handler(sent_msg, convertmoney_step) + + +def convertmoney_step(message): + text = message.text + c = CurrencyConverter() + second = text + sent_msg = bot.send_message(message.chat.id, "Inserisci quanto vuoi convertire?") + bot.register_next_step_handler(sent_msg,convertmoney_step2, second ) + +def convertmoney_step2(message, second): + many = message.text + c = CurrencyConverter() + example = c.convert(many, 'EUR', second) + bot.send_message(message.chat.id, str(example)) + bot.polling() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 98a64db..8d10da7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,4 +38,6 @@ pdf2docx == 0.5.4 googletrans == 3.0.0 -PyPDF2 == 2.3.1 \ No newline at end of file +PyPDF2 == 2.3.1 + +currencyconverter == 0.16.12 \ No newline at end of file