Add support for ! cmd char

This commit is contained in:
Nonoo 2023-08-22 10:30:40 +02:00
parent 5184d43d78
commit d5b81a3b5a

View File

@ -77,20 +77,21 @@ func handleMsg(ctx context.Context, entities tg.Entities, u *tg.UpdateNewMessage
} }
// Check if message is a command. // Check if message is a command.
if msg.Message[0] == '/' { if msg.Message[0] == '/' || msg.Message[0] == '!' {
cmd := strings.Split(msg.Message, " ")[0] cmd := strings.Split(msg.Message, " ")[0]
if strings.Contains(cmd, "@") { if strings.Contains(cmd, "@") {
cmd = strings.Split(cmd, "@")[0] cmd = strings.Split(cmd, "@")[0]
} }
msg.Message = strings.TrimPrefix(msg.Message, cmd+" ") msg.Message = strings.TrimPrefix(msg.Message, cmd+" ")
cmd = cmd[1:] // Cutting the command character.
switch cmd { switch cmd {
case "/dlp": case "dlp":
handleCmdDLP(ctx, entities, u, msg) handleCmdDLP(ctx, entities, u, msg)
return nil return nil
case "/dlpcancel": case "dlpcancel":
handleCmdDLPCancel(ctx, entities, u, msg) handleCmdDLPCancel(ctx, entities, u, msg)
return nil return nil
case "/start": case "start":
fmt.Println(" (start cmd)") fmt.Println(" (start cmd)")
if fromGroup == nil { if fromGroup == nil {
_, _ = telegramSender.Reply(entities, u).Text(ctx, "🤖 Welcome! This bot downloads videos from various "+ _, _ = telegramSender.Reply(entities, u).Text(ctx, "🤖 Welcome! This bot downloads videos from various "+