Compare commits
3 Commits
feature/ca
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 54a41a7250 | |||
|
|
3743dc6a45 | ||
| 7e0bc1f8a3 |
@@ -386,6 +386,17 @@ async def cmd_bounty(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
|
||||
async def cmd_my(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
user_id = get_user_id(update)
|
||||
args = extract_args(update.message.text)
|
||||
|
||||
# Parse show_all flag
|
||||
show_all = "all" in args
|
||||
args = [a for a in args if a != "all"]
|
||||
|
||||
# Parse optional limit
|
||||
try:
|
||||
limit = int(args[0]) if args else 5
|
||||
except (ValueError, IndexError):
|
||||
limit = 5
|
||||
|
||||
if is_group(update):
|
||||
group_id = get_group_id(update)
|
||||
@@ -397,7 +408,25 @@ async def cmd_my(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
|
||||
timezone_str = BOUNTY_SERVICE.get_timezone(room_id)
|
||||
|
||||
if not bounties:
|
||||
now = int(time.time())
|
||||
cutoff_24h = now - 86400
|
||||
|
||||
def is_expired(b) -> bool:
|
||||
return b.due_date_ts is not None and b.due_date_ts < cutoff_24h
|
||||
|
||||
def sort_key(b):
|
||||
if b.due_date_ts is not None:
|
||||
return (0, b.due_date_ts)
|
||||
return (1, b.created_at)
|
||||
|
||||
# Filter expired and sort
|
||||
filtered_bounties = [b for b in bounties if not is_expired(b) or show_all]
|
||||
filtered_bounties.sort(key=sort_key)
|
||||
|
||||
total_count = len(filtered_bounties)
|
||||
displayed_bounties = filtered_bounties[:limit]
|
||||
|
||||
if not displayed_bounties:
|
||||
msg = (
|
||||
"You are not tracking any bounties."
|
||||
if is_group(update)
|
||||
@@ -406,10 +435,27 @@ async def cmd_my(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
await update.message.reply_text(msg)
|
||||
return
|
||||
|
||||
lines = [
|
||||
format_bounty(b, show_id=True, timezone_str=timezone_str) for b in bounties
|
||||
]
|
||||
await update.message.reply_text("\n".join(lines), disable_web_page_preview=True)
|
||||
lines = []
|
||||
if limit < total_count:
|
||||
lines.append(f"Showing {limit} of {total_count} bounties:")
|
||||
slice_length = 40
|
||||
elif show_all and total_count > limit:
|
||||
lines.append(f"Showing {limit} of {total_count} bounties (including expired):")
|
||||
slice_length = 40
|
||||
else:
|
||||
lines.append(f"Showing {total_count} bounties:")
|
||||
slice_length = 0
|
||||
|
||||
for b in displayed_bounties:
|
||||
lines.append(
|
||||
format_bounty(b, show_id=True, slice_length=slice_length, timezone_str=timezone_str)
|
||||
)
|
||||
|
||||
keyboard = [[InlineKeyboardButton("🗑️ Delete", callback_data=f"del_msg:{user_id}")]]
|
||||
reply_markup = InlineKeyboardMarkup(keyboard)
|
||||
await update.message.reply_text(
|
||||
"\n".join(lines), disable_web_page_preview=True, reply_markup=reply_markup
|
||||
)
|
||||
|
||||
|
||||
async def cmd_add(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
|
||||
Reference in New Issue
Block a user