fixed telegram spam problem!!111

This commit is contained in:
b3yond 2018-09-09 18:06:12 +02:00
parent 0624bcb378
commit 6f3c953736
2 changed files with 3 additions and 3 deletions

View file

@ -28,12 +28,12 @@ class TelegramBot(Bot):
tb.send_message(update.message.sender.id, "You are now unsubscribed from report notifications.") tb.send_message(update.message.sender.id, "You are now unsubscribed from report notifications.")
# TODO: /stop message should be set in frontend # TODO: /stop message should be set in frontend
elif update.message.text.lower() == "/help": elif update.message.text.lower() == "/help":
tb.send_message(update.message.sender.id, "Send reports here to share them with other users. Use /start and /stop to be included/excluded.") tb.send_message(update.message.sender.id, "Send reports here to share them with other users. Use /start and /stop to get reports or not.")
# TODO: /help message should be set in frontend # TODO: /help message should be set in frontend
else: else:
reports.append(Report(update.message.sender.username, self, reports.append(Report(update.message.sender.username, self,
update.message.text, None, update.message.date)) update.message.text, None, update.message.date))
user.save_seen_tg(update.message.id) user.save_seen_tg(update.update_id)
except AttributeError: except AttributeError:
print(updates[0], updates[1]) # Telegram API returns an Error print(updates[0], updates[1]) # Telegram API returns an Error
return reports return reports

View file

@ -187,7 +187,7 @@ schlitz
def get_seen_tg(self): def get_seen_tg(self):
db.execute("SELECT tg_id FROM seen_telegrams WHERE user_id = ?;", db.execute("SELECT tg_id FROM seen_telegrams WHERE user_id = ?;",
(self.uid,)) (self.uid,))
return db.cur.fetchone() return db.cur.fetchone()[0]
def save_seen_tg(self, tg_id): def save_seen_tg(self, tg_id):
db.execute("UPDATE seen_telegrams SET tg_id = ? WHERE user_id = ?;", db.execute("UPDATE seen_telegrams SET tg_id = ? WHERE user_id = ?;",