Skip to content

Commit 77385b2

Browse files
author
Koehler, Jonathan
committed
add default Description, removed public/private (if visibilty: public ignored)
1 parent aa1074f commit 77385b2

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

bot.py

100644100755
File mode changed.

bot_osm_edit.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def get_conversation(self):
2626

2727
states={
2828
CHOOSING: [MessageHandler(Filters.regex('tag'), self.tag),
29-
MessageHandler(Filters.regex('cancel'), self.cancel)
3029
],
3130

3231

@@ -45,9 +44,8 @@ def get_conversation(self):
4544
]
4645
},
4746

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)]
5149
)
5250

5351
def start(self, update: Update, context: CallbackContext):
@@ -78,13 +76,18 @@ def gpx_name(self, update, context):
7876

7977
def gpx_desc(self, update, context):
8078
context.user_data['gpx'].desc = update.message.text
79+
self.gpx_up_content(update, context)
8180
return GPX_SAVE
8281

8382
def gpx_up_content(self, update, context):
8483
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+
8891
return GPX_SAVE
8992

9093
def gpx_toggles(self, update, context):
@@ -93,14 +96,13 @@ def gpx_toggles(self, update, context):
9396
self.gpx_save(update, context)
9497
del context.user_data['gpx']
9598
self.cancel(update, context)
96-
elif update.callback_query.data == 'public':
97-
gpx.public = not gpx.public
98-
context.user_data['gpx'] = gpx
9999
elif update.callback_query.data == 'vis':
100100
vis = ['identifiable', 'trackable', 'public', 'private']
101101
gpx.visibility = vis[vis.index(gpx.visibility) - 1]
102102
context.user_data['gpx'] = gpx
103+
update.callback_query.answer()
103104
self.gpx_up_content(update, context)
105+
return GPX_SAVE
104106

105107
def gpx_save(self, update, context):
106108
gpx = context.user_data['gpx']

osm/osm_util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __init__(self, tid: int, gpx: str, filename: str, username: str, time: str,
130130
self.name = filename
131131
self._username = username
132132
self._timestamp = time
133-
self.desc = desc or ''
133+
self.desc = desc or 'no Description'
134134
self.tags = tags or []
135135
self.public = public
136136
self.visibility = visibility

0 commit comments

Comments
 (0)