Compare commits

...

2 Commits

Author SHA1 Message Date
Wojciech Kwolek 5d7698462a implement /unread 2022-01-09 05:20:02 +01:00
Wojciech Kwolek f64f0bff12 fix typo 2022-01-09 05:16:24 +01:00
2 changed files with 13 additions and 3 deletions

14
main.py
View File

@ -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:

View File

@ -31,7 +31,7 @@ class Link:
return cls(
id=id,
link=link,
user_id=useredid,
user_id=user_id,
read_at=read_at,
added_at=added_at
)