mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Compare commits
1 Commits
0c4c4757d3
...
ignore-oth
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
979b0c6495 |
@@ -7,6 +7,9 @@ BOT_DISPLAY_NAME=GogoBee
|
|||||||
# Which rooms the bot posts scheduled content to (comma-separated room IDs)
|
# Which rooms the bot posts scheduled content to (comma-separated room IDs)
|
||||||
BROADCAST_ROOMS=!roomid:example.com
|
BROADCAST_ROOMS=!roomid:example.com
|
||||||
|
|
||||||
|
# Bots to ignore wholesale: no repost, no XP (comma-separated user IDs)
|
||||||
|
IGNORED_BOTS=@pete:matrix.example.org
|
||||||
|
|
||||||
# Admins who can run admin-only commands (comma-separated Matrix user IDs)
|
# Admins who can run admin-only commands (comma-separated Matrix user IDs)
|
||||||
ADMIN_USERS=@yourmxid:example.com
|
ADMIN_USERS=@yourmxid:example.com
|
||||||
|
|
||||||
|
|||||||
22
main.go
22
main.go
@@ -206,6 +206,14 @@ func main() {
|
|||||||
|
|
||||||
// ---- Set up event handlers ----
|
// ---- Set up event handlers ----
|
||||||
|
|
||||||
|
// Bots we ignore wholesale (no repost, no XP). Set IGNORED_BOTS to a
|
||||||
|
// comma-separated list of Matrix user IDs. Pete (@pete:...) posts plain
|
||||||
|
// m.text, so the m.notice convention below won't catch it on its own.
|
||||||
|
ignoredBots := make(map[id.UserID]bool)
|
||||||
|
for _, u := range splitAndTrim(os.Getenv("IGNORED_BOTS"), ",") {
|
||||||
|
ignoredBots[id.UserID(u)] = true
|
||||||
|
}
|
||||||
|
|
||||||
syncer := client.Syncer.(*mautrix.DefaultSyncer)
|
syncer := client.Syncer.(*mautrix.DefaultSyncer)
|
||||||
|
|
||||||
// Auto-join on invite + moderation member tracking
|
// Auto-join on invite + moderation member tracking
|
||||||
@@ -260,11 +268,25 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip explicitly ignored bots (e.g. Pete, which posts m.text).
|
||||||
|
if ignoredBots[evt.Sender] {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
content := evt.Content.AsMessage()
|
content := evt.Content.AsMessage()
|
||||||
if content == nil || content.Body == "" {
|
if content == nil || content.Body == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore messages from other bots. By Matrix convention automated
|
||||||
|
// clients send m.notice (instead of m.text) precisely so other bots
|
||||||
|
// don't react to them, which avoids feedback loops. Dropping notices
|
||||||
|
// here means no plugin reposts them (urls.go) or awards XP for them
|
||||||
|
// (xp.go). Our own messages are already skipped by the sender check.
|
||||||
|
if content.MsgType == event.MsgNotice {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore edits — they arrive as m.room.message with m.replace relation.
|
// Ignore edits — they arrive as m.room.message with m.replace relation.
|
||||||
// Without this check, edits re-trigger URL previews and inflate stats.
|
// Without this check, edits re-trigger URL previews and inflate stats.
|
||||||
if content.RelatesTo != nil && content.RelatesTo.Type == event.RelReplace {
|
if content.RelatesTo != nil && content.RelatesTo.Type == event.RelReplace {
|
||||||
|
|||||||
Reference in New Issue
Block a user