feat: enhance duty information handling with contact details and current duty view
- Added `bot_username` to settings for dynamic retrieval of the bot's username. - Implemented `_resolve_bot_username` function to fetch the bot's username if not set, improving user experience in group chats. - Updated `DutyWithUser` schema to include optional `phone` and `username` fields for enhanced duty information. - Enhanced API responses to include contact details for users, ensuring better communication. - Introduced a new current duty view in the web app, displaying active duty information along with contact options. - Updated CSS styles for better presentation of contact information in duty cards. - Added unit tests to verify the inclusion of contact details in API responses and the functionality of the current duty view.
This commit is contained in:
@@ -11,6 +11,14 @@ from telegram.ext import ApplicationBuilder
|
||||
from duty_teller import config
|
||||
from duty_teller.config import require_bot_token
|
||||
from duty_teller.handlers import group_duty_pin, register_handlers
|
||||
|
||||
|
||||
async def _resolve_bot_username(application) -> None:
|
||||
"""If BOT_USERNAME is not set from env, resolve it via get_me()."""
|
||||
if not config.BOT_USERNAME:
|
||||
me = await application.bot.get_me()
|
||||
config.BOT_USERNAME = (me.username or "").lower()
|
||||
logger.info("Resolved BOT_USERNAME from API: %s", config.BOT_USERNAME)
|
||||
from duty_teller.utils.http_client import safe_urlopen
|
||||
|
||||
logging.basicConfig(
|
||||
@@ -69,6 +77,7 @@ def main() -> None:
|
||||
ApplicationBuilder()
|
||||
.token(config.BOT_TOKEN)
|
||||
.post_init(group_duty_pin.restore_group_pin_jobs)
|
||||
.post_init(_resolve_bot_username)
|
||||
.build()
|
||||
)
|
||||
register_handlers(app)
|
||||
|
||||
Reference in New Issue
Block a user