Initial commit

This commit is contained in:
eleksir
2025-05-08 18:12:52 +03:00
commit b21e3c84c0
1553 changed files with 649819 additions and 0 deletions

52
internal/moon/squash.go Normal file
View File

@@ -0,0 +1,52 @@
package moon
import (
"time"
"github.com/NicoNex/echotron/v3"
)
// TODO: refactor to return bool, error
// squash bans given chat member.
func squash(chatid, userid int64) {
banUntilDate := time.Now().Unix() + 10
if timestamp := FindSquashedMember(chatid, userid); timestamp != 0 {
Log.Infof("Skip banning user %d, already banned")
return
}
if res, err := Tg.BanChatMember(
chatid,
userid,
&echotron.BanOptions{
UntilDate: int(banUntilDate),
},
); err != nil {
Log.Errorf(
"Unable to ban user with id %d in chat %s: %s",
userid,
chatid,
res.Description,
)
} else {
if !res.Ok {
Log.Errorf(
"Unable to ban user with id %d in chat %s: %s",
userid,
chatid,
res.Description,
)
} else {
Log.Infof(
"Banned user with id %d in chat %d.",
userid,
chatid,
)
AddSquashedMember(chatid, userid)
}
}
}