Files
tiennm99bot/internal/modules/noitu/command.go
T
tiennm99 f60b661444 feat(noitu): send the separate noitubot game from /noitubot
/noitubot now sends its own BotFather game, noitubot, so players can tell a
solo game from a /noitu room card. Both games share the Play handler and page.
A noitubot Play press skips the card lookup and always plays solo.
2026-10-09 16:42:31 +07:00

40 lines
1.3 KiB
Go

package noitu
import (
"context"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
"github.com/tiennm99/tiennm99bot/internal/modules/util/chathelper"
)
const (
// soloCommand sends the game played against the bot. It shares its name
// with that BotFather game.
soloCommand = SoloShortName
msgChannel = "Không thể chơi nối từ trong kênh. Hãy dùng /noitubot trong nhóm hoặc chat riêng với bot."
msgSendGameFail = "Không gửi được trò chơi nối từ. Thử lại sau nhé."
)
// handleCommand (/noitubot) sends the noitubot BotFather game for a solo game. No reply markup: Telegram then adds
// the Play button itself, which is the button the game requires first.
// The command works even when the game is disabled; Play explains why.
func (s *service) handleCommand(ctx context.Context, b *bot.Bot, update *models.Update) error {
msg := update.Message
if msg.Chat.Type == models.ChatTypeChannel {
return chathelper.Reply(ctx, b, msg, msgChannel)
}
_, err := b.SendGame(ctx, &bot.SendGameParams{
ChatID: msg.Chat.ID,
MessageThreadID: msg.MessageThreadID,
GameShorName: SoloShortName, // the library's field name is misspelled
})
if err != nil {
_ = chathelper.Reply(ctx, b, msg, msgSendGameFail)
return err
}
return nil
}