On ban event log also full nick
This commit is contained in:
17
buny.go
17
buny.go
@@ -86,7 +86,7 @@ func bunyPresense(v xmpp.Presence) error { //nolint:gocognit,gocyclo
|
|||||||
log.Debugf("Checking jid %s vs global blacklist regex %s", evilJid, jidRegexp)
|
log.Debugf("Checking jid %s vs global blacklist regex %s", evilJid, jidRegexp)
|
||||||
|
|
||||||
if re.MatchString(evilJid) {
|
if re.MatchString(evilJid) {
|
||||||
if id, err := squash(room, evilJid, bEntry.ReasonEnable, v.Type); err != nil {
|
if id, err := squash(room, evilJid, room+"/"+evilNick, bEntry.ReasonEnable, v.Type); err != nil {
|
||||||
err := fmt.Errorf(
|
err := fmt.Errorf(
|
||||||
"unable to ban user: id=%s, err=%w",
|
"unable to ban user: id=%s, err=%w",
|
||||||
id,
|
id,
|
||||||
@@ -117,7 +117,7 @@ func bunyPresense(v xmpp.Presence) error { //nolint:gocognit,gocyclo
|
|||||||
|
|
||||||
if re.MatchString(evilNick) {
|
if re.MatchString(evilNick) {
|
||||||
// Баним именно jid
|
// Баним именно jid
|
||||||
if id, err := squash(room, evilJid, bEntry.ReasonEnable, v.Type); err != nil {
|
if id, err := squash(room, evilJid, room+"/"+evilNick, bEntry.ReasonEnable, v.Type); err != nil {
|
||||||
err := fmt.Errorf(
|
err := fmt.Errorf(
|
||||||
"unable to ban user: id=%s, err=%w",
|
"unable to ban user: id=%s, err=%w",
|
||||||
id,
|
id,
|
||||||
@@ -152,7 +152,7 @@ func bunyPresense(v xmpp.Presence) error { //nolint:gocognit,gocyclo
|
|||||||
log.Debugf("Checking jid %s vs room %s blacklist regex %s", evilJid, room, jidRegexp)
|
log.Debugf("Checking jid %s vs room %s blacklist regex %s", evilJid, room, jidRegexp)
|
||||||
|
|
||||||
if re.MatchString(evilJid) {
|
if re.MatchString(evilJid) {
|
||||||
if id, err := squash(room, evilJid, bEntry.ReasonEnable, v.Type); err != nil {
|
if id, err := squash(room, evilJid, room+"/"+evilNick, bEntry.ReasonEnable, v.Type); err != nil {
|
||||||
err := fmt.Errorf(
|
err := fmt.Errorf(
|
||||||
"unable to ban user: id=%s, err=%w",
|
"unable to ban user: id=%s, err=%w",
|
||||||
id,
|
id,
|
||||||
@@ -184,7 +184,7 @@ func bunyPresense(v xmpp.Presence) error { //nolint:gocognit,gocyclo
|
|||||||
|
|
||||||
if re.MatchString(evilNick) {
|
if re.MatchString(evilNick) {
|
||||||
// Баним именно jid
|
// Баним именно jid
|
||||||
if id, err := squash(room, evilJid, bEntry.ReasonEnable, v.Type); err != nil {
|
if id, err := squash(room, evilJid, room+"/"+evilNick, bEntry.ReasonEnable, v.Type); err != nil {
|
||||||
err := fmt.Errorf(
|
err := fmt.Errorf(
|
||||||
"unable to ban user: id=%s, err=%w",
|
"unable to ban user: id=%s, err=%w",
|
||||||
id,
|
id,
|
||||||
@@ -214,7 +214,6 @@ func bunyPresense(v xmpp.Presence) error { //nolint:gocognit,gocyclo
|
|||||||
func bunyChat(v xmpp.Chat) error {
|
func bunyChat(v xmpp.Chat) error {
|
||||||
var (
|
var (
|
||||||
room = (strings.SplitN(v.Remote, "/", 2))[0]
|
room = (strings.SplitN(v.Remote, "/", 2))[0]
|
||||||
// :wq
|
|
||||||
// nick = (strings.SplitN(v.Remote, "/", 2))[1]
|
// nick = (strings.SplitN(v.Remote, "/", 2))[1]
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
@@ -240,7 +239,7 @@ func bunyChat(v xmpp.Chat) error {
|
|||||||
log.Debugf("Checking phrase %s vs room %s blacklist regex %s", v.Text, room, phraseRegexp)
|
log.Debugf("Checking phrase %s vs room %s blacklist regex %s", v.Text, room, phraseRegexp)
|
||||||
|
|
||||||
if re.MatchString(v.Text) {
|
if re.MatchString(v.Text) {
|
||||||
if id, err := squash(room, getRealJIDfromNick(v.Remote), bEntry.ReasonEnable, v.Type); err != nil {
|
if id, err := squash(room, getRealJIDfromNick(v.Remote), v.Remote, bEntry.ReasonEnable, v.Type); err != nil {
|
||||||
err := fmt.Errorf(
|
err := fmt.Errorf(
|
||||||
"unable to ban user: id=%s, err=%w",
|
"unable to ban user: id=%s, err=%w",
|
||||||
id,
|
id,
|
||||||
@@ -273,7 +272,7 @@ func bunyChat(v xmpp.Chat) error {
|
|||||||
log.Debugf("Checking phrase %s vs room %s blacklist regex %s", v.Text, room, phraseRegexp)
|
log.Debugf("Checking phrase %s vs room %s blacklist regex %s", v.Text, room, phraseRegexp)
|
||||||
|
|
||||||
if re.MatchString(v.Text) {
|
if re.MatchString(v.Text) {
|
||||||
if id, err := squash(room, getRealJIDfromNick(v.Remote), bEntry.ReasonEnable, v.Type); err != nil {
|
if id, err := squash(room, getRealJIDfromNick(v.Remote), v.Remote, bEntry.ReasonEnable, v.Type); err != nil {
|
||||||
err := fmt.Errorf(
|
err := fmt.Errorf(
|
||||||
"unable to ban user: id=%s, err=%w",
|
"unable to ban user: id=%s, err=%w",
|
||||||
id,
|
id,
|
||||||
@@ -299,13 +298,13 @@ func bunyChat(v xmpp.Chat) error {
|
|||||||
// squash банит указанный jid в указанной комнате.
|
// squash банит указанный jid в указанной комнате.
|
||||||
// reasonEnable указывает, надо ли писать дату автобана в банлисте в поле reason (это единственная причина, в которую
|
// reasonEnable указывает, надо ли писать дату автобана в банлисте в поле reason (это единственная причина, в которую
|
||||||
// умеет бот).
|
// умеет бот).
|
||||||
func squash(room, jid string, reasonEnable bool, vType string) (string, error) {
|
func squash(room, jid string, nick string, reasonEnable bool, vType string) (string, error) {
|
||||||
var (
|
var (
|
||||||
id string
|
id string
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Infof("Hammer falls on %s", jid)
|
log.Infof("Hammer falls on %s(%s)", nick, jid)
|
||||||
|
|
||||||
if config.Jabber.BanPhrasesEnable {
|
if config.Jabber.BanPhrasesEnable {
|
||||||
phrase := randomPhrase(config.Jabber.BanPhrases)
|
phrase := randomPhrase(config.Jabber.BanPhrases)
|
||||||
|
|||||||
Reference in New Issue
Block a user