Created
March 16, 2021 07:38
-
-
Save sid-r-singh/211090a1457be1038b7ff9c7b4d1233e 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
#Releavant code | |
def run(updater): | |
PORT = int(os.environ.get("PORT", "8443")) | |
HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME") | |
updater.start_webhook(listen="0.0.0.0", | |
port=PORT, | |
url_path=TOKEN) | |
updater.bot.set_webhook("https://{}.herokuapp.com/{}".format(HEROKU_APP_NAME, TOKEN)) | |
def main(): | |
# Create the Updater and pass it your bot's token. | |
# Make sure to set use_context=True to use the new context based callbacks | |
# Post version 12 this will no longer be necessary | |
updater = Updater(TOKEN, use_context=True) | |
# Get the dispatcher to register handlers | |
dp = updater.dispatcher | |
# Add conversation handler with the states GENDER, PHOTO, LOCATION and BIO | |
conv_handler = ConversationHandler( | |
entry_points=[CommandHandler('start', start)], | |
states={ | |
PAR_1: [CommandHandler('start', start), MessageHandler(Filters.text, par_1)], | |
CONFIRMATION: [MessageHandler(Filters.regex('^Confirm$'),confirmation), | |
MessageHandler(Filters.regex('^Restart$'),start)] | |
}, | |
fallbacks=[CommandHandler('cancel', cancel)] | |
) | |
dp.add_handler(conv_handler) | |
# log all errors | |
dp.add_error_handler(error) | |
run(updater) | |
# Run the bot until you press Ctrl-C or the process receives SIGINT, | |
# SIGTERM or SIGABRT. This should be used most of the time, since | |
# start_polling() is non-blocking and will stop the bot gracefully. | |
updater.idle() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment