aboutsummaryrefslogblamecommitdiff
path: root/bot.py
blob: f2be049a88fd9b2b65445a36a5286abc9e4541f9 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
                     
 
              

                                                                                                                        
 




                                                                                     
 
                   
                                                                
 
                                          
                      
                                                   
                                                                        

                

                                                                            
              


                                                                               
              


                                                                      
              


                                                                   
              

                                                                          
          
                                                             
                          
                           

     

                                                                 




                             
#!/usr/bin/env python

import logging
from callback import *
from telegram.ext import Application, CallbackQueryHandler, CommandHandler, MessageHandler, filters, ConversationHandler

logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
)
logger = logging.getLogger(__name__)


def main() -> None:
    application = Application.builder().token(BOT_TOKEN).build()

    checkin_handler = ConversationHandler(
        entry_points=[
            CommandHandler("start", start_command),
            MessageHandler(filters.LOCATION, callback_location_sharing),
        ],
        states={
            WAIT_LOCATION: [
                MessageHandler(filters.LOCATION, callback_location_sharing),
            ],
            LOCATION_SEARCH_KEYWORD: [
                MessageHandler(filters.TEXT, callback_location_keyword_search),
                CallbackQueryHandler(callback_skip_location_keyword),
            ],
            LOCATION_CONFIRMATION: [
                CallbackQueryHandler(callback_location_confirmation),
                MessageHandler(filters.TEXT, callback_manual_location)
            ],
            ADD_COMMENT: [
                MessageHandler(filters.TEXT, callback_add_comment),
                CallbackQueryHandler(callback_skip_comment),
            ],
            ADD_MEDIA: [MessageHandler(filters.PHOTO, callback_add_media),
                        CallbackQueryHandler(callback_skip_media)],
        },
        fallbacks=[CommandHandler("cancel", cancel_command)],
        per_message=False,
        allow_reentry=True,
    )

    application.add_handler(CommandHandler("help", help_command))
    application.add_handler(checkin_handler)
    application.run_polling()


if __name__ == "__main__":
    main()
Powered by cgit v1.2.3 (git 2.41.0)