Make join events available to handlers

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-02-13 15:12:20 +01:00
parent 1ade654a13
commit 31ca8ee35c
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 11 additions and 0 deletions

View file

@ -3,6 +3,7 @@ package main
func ptrStr(s string) *string { return &s }
var (
eventTypeJoin = ptrStr("join")
eventTypeHost = ptrStr("host")
eventTypePermit = ptrStr("permit")
eventTypeRaid = ptrStr("raid")

10
irc.go
View file

@ -79,6 +79,12 @@ func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
})
i.ExecuteJoins(config.Channels)
case "JOIN":
// JOIN (Default IRC Command)
// User enters the channel, might be triggered multiple times
// should not be used to greet users
i.handleJoin(m)
case "NOTICE":
// NOTICE (Twitch Commands)
// General notices from the server.
@ -110,6 +116,10 @@ func (i ircHandler) Handle(c *irc.Client, m *irc.Message) {
func (i ircHandler) Run() error { return errors.Wrap(i.c.Run(), "running IRC client") }
func (i ircHandler) handleJoin(m *irc.Message) {
go handleMessage(i.c, m, eventTypeJoin)
}
func (i ircHandler) handlePermit(m *irc.Message) {
badges := i.ParseBadgeLevels(m)
if !badges.Has(badgeBroadcaster) && (!config.PermitAllowModerator || !badges.Has(badgeModerator)) {