2021-09-02 21:26:39 +00:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2023-09-11 17:51:38 +00:00
|
|
|
"gopkg.in/irc.v4"
|
2021-09-02 21:26:39 +00:00
|
|
|
)
|
|
|
|
|
2021-11-11 13:59:08 +00:00
|
|
|
func DeriveChannel(m *irc.Message, evtData *FieldCollection) string {
|
2021-09-02 21:26:39 +00:00
|
|
|
if m != nil && len(m.Params) > 0 && strings.HasPrefix(m.Params[0], "#") {
|
|
|
|
return m.Params[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
if s, err := evtData.String("channel"); err == nil {
|
|
|
|
return fmt.Sprintf("#%s", strings.TrimLeft(s, "#"))
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2021-11-11 13:59:08 +00:00
|
|
|
func DeriveUser(m *irc.Message, evtData *FieldCollection) string {
|
2021-09-02 21:26:39 +00:00
|
|
|
if m != nil && m.User != "" {
|
|
|
|
return m.User
|
|
|
|
}
|
|
|
|
|
|
|
|
if s, err := evtData.String("user"); err == nil {
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2021-10-16 12:44:11 +00:00
|
|
|
if s, err := evtData.String("username"); err == nil {
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2021-09-02 21:26:39 +00:00
|
|
|
return ""
|
|
|
|
}
|