Last active
August 30, 2018 19:26
-
-
Save slapglif/76ed7210c7a26a848a3d7656ea077111 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from telegram.ext import (Updater, CommandHandler, RegexHandler, ConversationHandler) | |
def tele(direction, pair, bot, update): | |
update.message.reply_text( | |
"Signal Detected by IcarusBot: " + direction + " on " + pair) | |
return SIGNALS | |
bots = [] | |
updates = [] | |
def start(bot, update): | |
bots.append(bot) | |
updates.append(update) | |
update.message.reply_text( | |
"Hi. I'm IcarusBot. I'm waiting for your input!") | |
return SIGNALS | |
def cancel(bot, update): | |
user = update.message.from_user | |
update.message.reply_text('Bye! I hope we can talk again some day.') | |
return ConversationHandler.END | |
def error(bot, update, error): | |
"""Log Errors caused by Updates.""" | |
# print('Update "%s" caused error "%s"', update, error) | |
pass | |
def main(): | |
try: | |
print("Listening to Telegram Channel...") | |
updater = Updater(token) | |
dp = updater.dispatcher | |
conv_handler = ConversationHandler( | |
entry_points=[CommandHandler('start', start)], | |
states={ | |
SIGNALS: [] | |
}, | |
fallbacks=[CommandHandler('cancel', cancel)] | |
) | |
dp.add_handler(conv_handler) | |
dp.add_error_handler(error) | |
updater.start_polling() | |
updater.idle() | |
except Exception as e: | |
log(e) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment