Compare commits
1 Commits
fix/issue-
...
feat/issue
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7503ecd14 |
@@ -8,12 +8,12 @@ from telegram.ext import Application, CommandHandler, MessageHandler, filters
|
|||||||
|
|
||||||
from commands import (
|
from commands import (
|
||||||
cmd_add,
|
cmd_add,
|
||||||
|
cmd_admin,
|
||||||
cmd_bounty,
|
cmd_bounty,
|
||||||
cmd_delete,
|
cmd_delete,
|
||||||
cmd_edit,
|
cmd_edit,
|
||||||
cmd_help,
|
cmd_help,
|
||||||
cmd_my,
|
cmd_my,
|
||||||
cmd_show,
|
|
||||||
cmd_start,
|
cmd_start,
|
||||||
cmd_track,
|
cmd_track,
|
||||||
cmd_untrack,
|
cmd_untrack,
|
||||||
@@ -42,7 +42,7 @@ def build_app() -> Application:
|
|||||||
app.add_handler(CommandHandler("delete", cmd_delete))
|
app.add_handler(CommandHandler("delete", cmd_delete))
|
||||||
app.add_handler(CommandHandler("track", cmd_track))
|
app.add_handler(CommandHandler("track", cmd_track))
|
||||||
app.add_handler(CommandHandler("untrack", cmd_untrack))
|
app.add_handler(CommandHandler("untrack", cmd_untrack))
|
||||||
app.add_handler(CommandHandler("show", cmd_show))
|
app.add_handler(CommandHandler("admin", cmd_admin))
|
||||||
|
|
||||||
app.add_handler(MessageHandler(filters.COMMAND, cmd_help))
|
app.add_handler(MessageHandler(filters.COMMAND, cmd_help))
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ async def post_init(app: Application) -> None:
|
|||||||
("edit", "Edit a bounty"),
|
("edit", "Edit a bounty"),
|
||||||
("track", "Track a bounty"),
|
("track", "Track a bounty"),
|
||||||
("untrack", "Stop tracking"),
|
("untrack", "Stop tracking"),
|
||||||
("show", "Show bounty details"),
|
("admin", "List room admins"),
|
||||||
("help", "Show help"),
|
("help", "Show help"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -311,48 +311,6 @@ async def cmd_start(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def cmd_show(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
|
||||||
args = extract_args(update.message.text)
|
|
||||||
if not args:
|
|
||||||
await update.message.reply_text("Usage: /show <bounty_id>")
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
bounty_id = int(args[0])
|
|
||||||
except ValueError:
|
|
||||||
await update.message.reply_text("Invalid bounty ID.")
|
|
||||||
return
|
|
||||||
|
|
||||||
room_id = get_room_id(update)
|
|
||||||
bounty = BOUNTY_SERVICE.get_bounty(room_id, bounty_id)
|
|
||||||
|
|
||||||
if not bounty:
|
|
||||||
await update.message.reply_text("Bounty not found.")
|
|
||||||
return
|
|
||||||
|
|
||||||
timezone = BOUNTY_SERVICE.get_timezone(room_id)
|
|
||||||
|
|
||||||
lines = []
|
|
||||||
|
|
||||||
title = bounty.text or "(no text)"
|
|
||||||
lines.append(f"[#{bounty.id}] {title}")
|
|
||||||
|
|
||||||
if bounty.link:
|
|
||||||
lines.append(f"🔗 {bounty.link}")
|
|
||||||
|
|
||||||
if bounty.due_date_ts:
|
|
||||||
due_str = time.strftime("%d %B %Y %H:%M", time.localtime(bounty.due_date_ts))
|
|
||||||
lines.append(f"📅 {due_str} ({timezone})")
|
|
||||||
|
|
||||||
username = bounty.created_by_username or f"user#{bounty.created_by_user_id}"
|
|
||||||
lines.append(f"👤 @{username}")
|
|
||||||
|
|
||||||
created_str = time.strftime("%Y-%m-%d %H:%M", time.localtime(bounty.created_at))
|
|
||||||
lines.append(f"📌 Created: {created_str}")
|
|
||||||
|
|
||||||
await update.message.reply_text("\n".join(lines), disable_web_page_preview=True)
|
|
||||||
|
|
||||||
|
|
||||||
async def cmd_help(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
async def cmd_help(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
await update.message.reply_text(
|
await update.message.reply_text(
|
||||||
"👻 JIGAIDO Commands:\n\n"
|
"👻 JIGAIDO Commands:\n\n"
|
||||||
@@ -363,8 +321,23 @@ async def cmd_help(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
|||||||
"/delete <id> — delete bounty\n"
|
"/delete <id> — delete bounty\n"
|
||||||
"/track <id> — track a bounty (groups only)\n"
|
"/track <id> — track a bounty (groups only)\n"
|
||||||
"/untrack <id> — stop tracking (groups only)\n"
|
"/untrack <id> — stop tracking (groups only)\n"
|
||||||
"/show <id> — show bounty details\n"
|
"/admin — list room admins\n"
|
||||||
"/start — re-initialize\n"
|
"/start — re-initialize\n"
|
||||||
"/help — this message",
|
"/help — this message",
|
||||||
disable_web_page_preview=True,
|
disable_web_page_preview=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def cmd_admin(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
|
room_id = get_room_id(update)
|
||||||
|
admin_ids = BOUNTY_SERVICE.list_admins(room_id)
|
||||||
|
|
||||||
|
if not admin_ids:
|
||||||
|
await update.message.reply_text("No admins configured for this room.")
|
||||||
|
return
|
||||||
|
|
||||||
|
lines = [f"Room Admins:"]
|
||||||
|
for admin_id in admin_ids:
|
||||||
|
lines.append(f"- @{admin_id}")
|
||||||
|
|
||||||
|
await update.message.reply_text("\n".join(lines))
|
||||||
|
|||||||
Reference in New Issue
Block a user