Implement initial flavouor of ban by caps
This commit is contained in:
21
buny.go
21
buny.go
@@ -254,8 +254,10 @@ func bunyChat(v xmpp.Chat) error {
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Действовать мы можем только в рамках тех комнат, где явно присуствуем.
|
||||||
for _, cRoom := range roomsConnected {
|
for _, cRoom := range roomsConnected {
|
||||||
if cRoom == room {
|
if cRoom == room {
|
||||||
|
// Перебирём правила чёрных списков.
|
||||||
for _, bEntry := range blackList.Blacklist {
|
for _, bEntry := range blackList.Blacklist {
|
||||||
// Обработаем правила глобального чёрного списка
|
// Обработаем правила глобального чёрного списка
|
||||||
if bEntry.RoomName == "" {
|
if bEntry.RoomName == "" {
|
||||||
@@ -344,6 +346,25 @@ func bunyChat(v xmpp.Chat) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Если включено, проверяем фразу на КАПС.
|
||||||
|
for _, channel := range config.Jabber.Channels {
|
||||||
|
if channel.Name == room && channel.AllCaps.Enabled {
|
||||||
|
// Нормализуем строку и вырежем из неё пробелы
|
||||||
|
normPhrase := strings.ReplaceAll(nString(v.Text), " ", "")
|
||||||
|
|
||||||
|
// Проверяем согласно тому, что длина фразы более чем сколько-то символов
|
||||||
|
if len(normPhrase) >= channel.AllCaps.MinLength {
|
||||||
|
normPhraseUpper := strings.ReplaceAll(nStringUpper(v.Text), " ", "")
|
||||||
|
|
||||||
|
if normPhrase == normPhraseUpper {
|
||||||
|
realJID := getRealJIDfromNick(v.Remote)
|
||||||
|
squash(room, realJID, false, v.Type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
types.go
4
types.go
@@ -30,12 +30,12 @@ type myConfig struct {
|
|||||||
Bayes struct {
|
Bayes struct {
|
||||||
Enabled bool `json:"enabled,omitempty"`
|
Enabled bool `json:"enabled,omitempty"`
|
||||||
MinWords int64 `json:"min_words,omitempty"`
|
MinWords int64 `json:"min_words,omitempty"`
|
||||||
MinLength int64 `json:"min_length,omitempty"`
|
MinLength int `json:"min_length,omitempty"`
|
||||||
DefaultAction string `json:"default_action,omitempty"`
|
DefaultAction string `json:"default_action,omitempty"`
|
||||||
} `json:"bayes,omitempty"`
|
} `json:"bayes,omitempty"`
|
||||||
AllCaps struct {
|
AllCaps struct {
|
||||||
Enabled bool `json:"enabled,omitempty"`
|
Enabled bool `json:"enabled,omitempty"`
|
||||||
MinLength int64 `json:"min_length,omitempty"`
|
MinLength int `json:"min_length,omitempty"`
|
||||||
DefaultAction string `json:"default_action,omitempty"`
|
DefaultAction string `json:"default_action,omitempty"`
|
||||||
} `json:"all_caps,omitempty"`
|
} `json:"all_caps,omitempty"`
|
||||||
} `json:"channels"`
|
} `json:"channels"`
|
||||||
|
|||||||
Reference in New Issue
Block a user