[WIP] update linter rules, fix many linter warnings
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package tg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/NicoNex/echotron/v3"
|
||||
)
|
||||
@@ -10,10 +10,13 @@ import (
|
||||
// Непотребными могут быть аудиосообщения, аудиофайлы, видеосообщения, сообщения от имени других каналов итп.
|
||||
// Это могут настроить админы чятика через команду !admin censor.
|
||||
func Censor(msg *echotron.Update) bool {
|
||||
result := false
|
||||
var (
|
||||
result bool
|
||||
chatID = msg.ChatID()
|
||||
)
|
||||
|
||||
switch {
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "VoiceMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "VoiceMsg") == "1":
|
||||
result = true
|
||||
|
||||
// Предполагаем, что у voice-ов здесь всегда не ноль.
|
||||
@@ -23,7 +26,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "AudioMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "AudioMsg") == "1":
|
||||
// Предполагаем, что у аудио здесь всегда не ноль.
|
||||
if msg.Message.Audio.Duration != 0 {
|
||||
delMsg(msg)
|
||||
@@ -31,7 +34,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "PhotoMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "PhotoMsg") == "1":
|
||||
// Обычное сообщение не содержит фоток.
|
||||
if len(msg.Message.Photo) != 0 {
|
||||
delMsg(msg)
|
||||
@@ -39,7 +42,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "VideoMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "VideoMsg") == "1":
|
||||
// Предполагаем, что у видео здесь всегда не ноль.
|
||||
if msg.Message.Video.Duration != 0 {
|
||||
delMsg(msg)
|
||||
@@ -47,7 +50,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "VideoNoteMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "VideoNoteMsg") == "1":
|
||||
// Предполагаем, что у видео-заметки здесь всегда не ноль.
|
||||
if msg.Message.VideoNote.Duration != 0 {
|
||||
delMsg(msg)
|
||||
@@ -55,7 +58,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "AnimationMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "AnimationMsg") == "1":
|
||||
// Предполагаем, что у анимации здесь всегда не ноль.
|
||||
if msg.Message.Animation.Duration != 0 {
|
||||
delMsg(msg)
|
||||
@@ -63,7 +66,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "StickerMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "StickerMsg") == "1":
|
||||
// Предполагаем, что FileID не пустое только у стикера.
|
||||
if msg.Message.Sticker.FileID != "" {
|
||||
delMsg(msg)
|
||||
@@ -71,7 +74,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "DiceMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "DiceMsg") == "1":
|
||||
// Предполагаем, что Value > 0 только у дайса.
|
||||
if msg.Message.Dice.Value != 0 {
|
||||
delMsg(msg)
|
||||
@@ -79,7 +82,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "GameMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "GameMsg") == "1":
|
||||
// Предполагаем, что title только у game-а.
|
||||
if msg.Message.Game.Title != "" {
|
||||
delMsg(msg)
|
||||
@@ -87,7 +90,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "PollMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "PollMsg") == "1":
|
||||
// Предполагаем, что title только у game-а.
|
||||
if msg.Message.Poll.Question != "" {
|
||||
delMsg(msg)
|
||||
@@ -95,7 +98,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
result = true
|
||||
}
|
||||
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "DocumentMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "DocumentMsg") == "1":
|
||||
// Предполагаем, что FileID есть только у document-а.
|
||||
if msg.Message.Document.FileID != "" {
|
||||
delMsg(msg)
|
||||
@@ -107,7 +110,7 @@ func Censor(msg *echotron.Update) bool {
|
||||
// пидорство он будет удалять asap.
|
||||
// 136817688 - это специальный id пользователя, который принимает облик канала, на него можно нажать и попасть
|
||||
// на рекламируемый канал.
|
||||
case GetSetting(fmt.Sprintf("%d", msg.ChatID()), "ChanMsg") == "1":
|
||||
case GetSetting(strconv.FormatInt(chatID, 10), "ChanMsg") == "1":
|
||||
if msg.Message.From.ID == 136817688 {
|
||||
delMsg(msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user