@@ -26,7 +26,6 @@ def get_conversation(self):
26
26
27
27
states = {
28
28
CHOOSING : [MessageHandler (Filters .regex ('tag' ), self .tag ),
29
- MessageHandler (Filters .regex ('cancel' ), self .cancel )
30
29
],
31
30
32
31
@@ -45,9 +44,8 @@ def get_conversation(self):
45
44
]
46
45
},
47
46
48
- fallbacks = [MessageHandler (Filters .regex ('^Done$' ), self .cancel ),
49
- MessageHandler (Filters .command , self .invalid , 0 ),
50
- CallbackQueryHandler (self .invalid )]
47
+ fallbacks = [MessageHandler (Filters .regex ('cancel' ), self .cancel ),
48
+ MessageHandler (Filters .command , self .invalid , 0 )]
51
49
)
52
50
53
51
def start (self , update : Update , context : CallbackContext ):
@@ -78,13 +76,18 @@ def gpx_name(self, update, context):
78
76
79
77
def gpx_desc (self , update , context ):
80
78
context .user_data ['gpx' ].desc = update .message .text
79
+ self .gpx_up_content (update , context )
81
80
return GPX_SAVE
82
81
83
82
def gpx_up_content (self , update , context ):
84
83
gpx : osm .osm_util .Trace = context .user_data ['gpx' ]
85
- markup = InlineKeyboardMarkup ([[InlineKeyboardButton (gpx .visibility , callback_data = 'vis' )],
86
- [InlineKeyboardButton ('Upload' , callback_data = 'save' )]])
87
- context .bot .send_message (update .effective_chat .id , str (gpx ), reply_markup = markup )
84
+ markup = InlineKeyboardMarkup ([[InlineKeyboardButton (gpx .visibility , callback_data = 'vis' ),
85
+ InlineKeyboardButton ('Upload' , callback_data = 'save' )]])
86
+ try :
87
+ update .callback_query .edit_message_text (str (gpx ), reply_markup = markup )
88
+ except AttributeError :
89
+ update .message .reply_text (str (gpx ), reply_markup = markup )
90
+
88
91
return GPX_SAVE
89
92
90
93
def gpx_toggles (self , update , context ):
@@ -93,14 +96,13 @@ def gpx_toggles(self, update, context):
93
96
self .gpx_save (update , context )
94
97
del context .user_data ['gpx' ]
95
98
self .cancel (update , context )
96
- elif update .callback_query .data == 'public' :
97
- gpx .public = not gpx .public
98
- context .user_data ['gpx' ] = gpx
99
99
elif update .callback_query .data == 'vis' :
100
100
vis = ['identifiable' , 'trackable' , 'public' , 'private' ]
101
101
gpx .visibility = vis [vis .index (gpx .visibility ) - 1 ]
102
102
context .user_data ['gpx' ] = gpx
103
+ update .callback_query .answer ()
103
104
self .gpx_up_content (update , context )
105
+ return GPX_SAVE
104
106
105
107
def gpx_save (self , update , context ):
106
108
gpx = context .user_data ['gpx' ]
0 commit comments