Skip to content

Instantly share code, notes, and snippets.

@sid-r-singh
Created March 16, 2021 07:38
Show Gist options
  • Save sid-r-singh/211090a1457be1038b7ff9c7b4d1233e to your computer and use it in GitHub Desktop.
Save sid-r-singh/211090a1457be1038b7ff9c7b4d1233e to your computer and use it in GitHub Desktop.
#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