diff --git a/db.py b/db.py
index 742dd22e..af32d39c 100644
--- a/db.py
+++ b/db.py
@@ -1249,10 +1249,14 @@ class Match(Base):
plist = f"Giocatori{minimum}:\n"
ignore_count = 0
for player in player_list:
- if player.status == MatchmakingStatus.WAIT_FOR_ME:
- icon = "π"
- elif player.status == MatchmakingStatus.READY:
+ if player.status == MatchmakingStatus.READY:
icon = "π΅"
+ elif player.status == MatchmakingStatus.WAIT_FOR_ME:
+ icon = "π"
+ elif player.status == MatchmakingStatus.MAYBE:
+ icon = "β"
+ elif player.status == MatchmakingStatus.SOMEONE_ELSE:
+ icon = "π¬"
elif player.status == MatchmakingStatus.IGNORED:
ignore_count += 1
continue
@@ -1282,6 +1286,8 @@ class Match(Base):
class MatchmakingStatus(enum.IntEnum):
WAIT_FOR_ME = 1
READY = 2
+ MAYBE = 3
+ SOMEONE_ELSE = 4
IGNORED = -1
diff --git a/telegrambot.py b/telegrambot.py
index 534274b2..5b49cd58 100644
--- a/telegrambot.py
+++ b/telegrambot.py
@@ -313,10 +313,20 @@ def cmd_mm(bot: Bot, update: Update):
creator=user)
session.add(db_match)
session.flush()
- inline_keyboard = InlineKeyboardMarkup([[InlineKeyboardButton("π΅ Ci sono!", callback_data="match_ready")],
- [InlineKeyboardButton("π Sto arrivando, aspettatemi!", callback_data="match_wait_for_me")],
- [InlineKeyboardButton("β Non vengo.", callback_data="match_ignore")],
- [InlineKeyboardButton("π© [termina la ricerca]", callback_data="match_close")]])
+ inline_keyboard = InlineKeyboardMarkup([[InlineKeyboardButton("π΅ Possiamo iniziare!",
+ callback_data="match_ready")],
+ [InlineKeyboardButton("π Ci sarΓ², aspettatemi!",
+ callback_data="match_wait_for_me")],
+ [InlineKeyboardButton("β Forse vengo, se non ci sono fate senza di me.",
+ callback_data="match_maybe")],
+ [InlineKeyboardButton("π¬ Solo se viene anche qualcun altro...",
+ callback_data="match_someone_else")],
+ [InlineKeyboardButton("β Non ci sarΓ².",
+ callback_data="match_ignore")],
+ [InlineKeyboardButton("π [annulla la partita]",
+ callback_data="match_delete")],
+ [InlineKeyboardButton("π© [avvia la partita]",
+ callback_data="match_close")]])
message = bot.send_message(config["Telegram"]["announcement_group"], db_match.generate_text(session=session),
parse_mode="HTML",
reply_markup=inline_keyboard)
@@ -398,19 +408,26 @@ def on_callback_query(bot: Bot, update: Update):
elif update.callback_query.data == "match_ignore":
status = db.MatchmakingStatus.IGNORED
text = "β Non ti interessa questa partita."
- elif update.callback_query.data == "match_close":
+ elif update.callback_query.data == "match_maybe":
+ status = db.MatchmakingStatus.MAYBE
+ text = "β Hai detto che forse ci sarai."
+ elif update.callback_query.data == "match_someone_else":
+ status = db.MatchmakingStatus.SOMEONE_ELSE
+ text = "π¬ Hai detto che vuoi aspettare che venga qualcun altro."
+ elif update.callback_query.data == "match_close" or update.callback_query.data == "match_delete":
status = None
if match.creator == user:
match.closed = True
text = "π© Matchmaking chiuso!"
- for player in match.players:
- if player.status == db.MatchmakingStatus.READY or player.status == db.MatchmakingStatus.WAIT_FOR_ME:
- try:
- bot.send_message(player.user.telegram_id,
- f"π© Sei pronto? {match.match_title} sta iniziando!",
- parse_mode="HTML")
- except Exception as e:
- logger.warning(f"Failed to notify {player.user.username}: {e}")
+ if update.callback_query.data == "match_close":
+ for player in match.players:
+ if player.status == db.MatchmakingStatus.READY or player.status == db.MatchmakingStatus.WAIT_FOR_ME:
+ try:
+ bot.send_message(player.user.telegram_id,
+ f"π© Sei pronto? {match.match_title} sta iniziando!",
+ parse_mode="HTML")
+ except Exception as e:
+ logger.warning(f"Failed to notify {player.user.username}: {e}")
else:
bot.answer_callback_query(update.callback_query.id, show_alert=True,
text="β Non sei il creatore di questo match!")
@@ -435,12 +452,19 @@ def on_callback_query(bot: Bot, update: Update):
session.commit()
bot.answer_callback_query(update.callback_query.id, text=text, cache_time=1)
if not match.closed:
- inline_keyboard = InlineKeyboardMarkup([[InlineKeyboardButton("π΅ Ci sono!", callback_data="match_ready")],
- [InlineKeyboardButton("π Sto arrivando, aspettatemi!",
+ inline_keyboard = InlineKeyboardMarkup([[InlineKeyboardButton("π΅ Possiamo iniziare!",
+ callback_data="match_ready")],
+ [InlineKeyboardButton("π Ci sarΓ², aspettatemi!",
callback_data="match_wait_for_me")],
- [InlineKeyboardButton("β Non vengo.",
+ [InlineKeyboardButton("β Forse vengo, se non ci sono fate senza di me.",
+ callback_data="match_maybe")],
+ [InlineKeyboardButton("π¬ Solo se viene anche qualcun altro...",
+ callback_data="match_someone_else")],
+ [InlineKeyboardButton("β Non ci sarΓ².",
callback_data="match_ignore")],
- [InlineKeyboardButton("π© [termina la ricerca]",
+ [InlineKeyboardButton("π [annulla la partita]",
+ callback_data="match_delete")],
+ [InlineKeyboardButton("π© [avvia la partita]",
callback_data="match_close")]])
else:
inline_keyboard = None