implement /unread
This commit is contained in:
parent
f64f0bff12
commit
5d7698462a
14
main.py
14
main.py
|
|
@ -9,6 +9,7 @@ from pprint import pprint
|
|||
|
||||
from dotenv import load_dotenv
|
||||
from telegram import Update, user
|
||||
import telegram
|
||||
from telegram.ext import (CallbackContext, CommandHandler, MessageHandler,
|
||||
Updater)
|
||||
|
||||
|
|
@ -90,9 +91,18 @@ class Bot:
|
|||
def cmd_unread(self, update: Update, context: CallbackContext):
|
||||
# TODO: ignore messages from group
|
||||
user_id = update.effective_user.id
|
||||
self.send_unread(context.bot, user_id)
|
||||
|
||||
def send_unread(self, bot: telegram.Bot, user_id: str):
|
||||
with self.db as db:
|
||||
links = Link.get_unread(db, user_id)
|
||||
pprint(list(links))
|
||||
unread = Link.get_unread(db, user_id)
|
||||
|
||||
bot.send_message(
|
||||
user_id, f"**Your unread links as of {datetime.now().isoformat()}:", parse_mode="MARKDOWN")
|
||||
for link in unread:
|
||||
bot.send_message(user_id, link.link)
|
||||
# TODO: button to read or postpone
|
||||
# TODO: button to mark all as read or postpone
|
||||
|
||||
def _natural_count(self, n, singular, plural):
|
||||
if abs(n) == 1:
|
||||
|
|
|
|||
Loading…
Reference in New Issue