🐛 Fix some message bugs and delete message if not verified and group setting set true
This commit is contained in:
parent
cf1e03ef0e
commit
474744f928
@ -30,7 +30,7 @@ func (i infoCommand) ExecuteCommand(bot *tgbotapi.BotAPI, update *tgbotapi.Updat
|
||||
"General Information to this Bot\n" +
|
||||
"===============================\n" +
|
||||
"Developer: @Alphyron\n" +
|
||||
"Version: 2.1.0\n" +
|
||||
"Version: 2.2.2\n" +
|
||||
"Git: [Gitea Repository](https://git.dragon-labs.de/alphyron/group_assistant)\n" +
|
||||
"==============================="
|
||||
|
||||
|
@ -39,7 +39,7 @@ func (i toggleWritingForbidCommand) ExecuteCommand(bot *tgbotapi.BotAPI, update
|
||||
return false, err
|
||||
}
|
||||
|
||||
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Update the group setting for OnlineCheck to: "+strconv.FormatBool(group.OnlineCheck))
|
||||
msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Update the group setting for forbid-writing to: "+strconv.FormatBool(group.ForbidWriting))
|
||||
_, err = bot.Send(msg)
|
||||
|
||||
return err == nil, err
|
||||
|
1
main.go
1
main.go
@ -85,6 +85,7 @@ func InitialRoutineManager(bot *tgbotapi.BotAPI, commandManager *cli.CommandMana
|
||||
rm.RegisterRoutine(routines.NewDatabaseRoutine(service))
|
||||
rm.RegisterRoutine(routines.NewJoinCheckerRoutine(userData))
|
||||
rm.RegisterRoutine(routines.NewVerifierRoutine(service, userData))
|
||||
rm.RegisterRoutine(routines.NewJoinWritingCheckerRoutine(userData))
|
||||
|
||||
return rm
|
||||
}
|
||||
|
37
telegram/routines/joinwritingchecker.go
Normal file
37
telegram/routines/joinwritingchecker.go
Normal file
@ -0,0 +1,37 @@
|
||||
package routines
|
||||
|
||||
import (
|
||||
"git.dragon-labs.de/alphyron/group_helper/models"
|
||||
"git.dragon-labs.de/alphyron/group_helper/obj"
|
||||
"git.dragon-labs.de/alphyron/group_helper/telegram"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
)
|
||||
|
||||
type joinWritingCheckerRoutine struct {
|
||||
verifyData *obj.VerifyData
|
||||
}
|
||||
|
||||
func NewJoinWritingCheckerRoutine(verifyData *obj.VerifyData) telegram.Routine {
|
||||
return joinWritingCheckerRoutine{
|
||||
verifyData: verifyData,
|
||||
}
|
||||
}
|
||||
|
||||
func (j joinWritingCheckerRoutine) Update(botAPI *tgbotapi.BotAPI, update *tgbotapi.Update, group *models.Group) error {
|
||||
|
||||
if update.Message == nil { // ignore any non-Message Updates
|
||||
return nil
|
||||
}
|
||||
|
||||
if update.Message.Chat.IsPrivate() || update.Message.Chat.IsChannel() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if j.verifyData.ExistCountdownForUserInGroup(update.Message.From.ID, group.GroupID) {
|
||||
if group.ForbidWriting {
|
||||
_, err := botAPI.DeleteMessage(tgbotapi.NewDeleteMessage(group.GroupID, update.Message.MessageID))
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user