1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/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()
|