Added LabelTooLongError() and changed names

This commit is contained in:
Profitroll
2022-12-22 22:11:36 +01:00
parent 7db8c9ac5c
commit 12da1b2376
4 changed files with 13 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ async def callback_query_sponsor_yes(app, clb):
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}}, {"$set": {"state": "approved", "sent": False}})
await holo_user.set_label(configGet("destination_group"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"])
await holo_user.label_set(configGet("destination_group"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"])
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]

View File

@@ -21,14 +21,14 @@ async def cmd_label(app, msg):
label = " ".join(msg.command[2:])
if label.lower() == "reset":
await target.reset_label(msg.chat)
await target.label_reset(msg.chat)
await msg.reply_text(f"Resetting **{target.id}**'s label...", quote=should_quote(msg))
else:
if len(label) > 16:
await msg.reply_text(locale("label_too_long", "message"))
return
await target.set_label(msg.chat, label)
await target.label_set(msg.chat, label)
await msg.reply_text(f"Setting **{target.id}**'s label to **{label}**...", quote=should_quote(msg))
else:

View File

@@ -61,7 +61,7 @@ if configGet("enabled", "scheduler", "sponsorships"):
try:
holo_user = HoloUser(entry["user"])
await app.send_message( entry["user"], locale("sponsorships_expired", "message") ) # type: ignore
await holo_user.reset_label(configGet("destination_group"))
await holo_user.label_reset(configGet("destination_group"))
try:
tg_user = await app.get_users(entry["user"])
logWrite(f"Notified user that sponsorship expires in {until_expiry} days")