Getting user perms?
How can i get the senders perms?
ex: sender uses !test -> checks if sender has op perms
This is actually fairly complicated and involves setting up a number of callbacks and tracking a bunch of stuff.
I've got a relatively detailed write up of the callbacks you'll need here: https://gist.github.com/belak/09edcc4f5e51056bf5bc728647659d81
ugh its to confusing :/
if wish there was somthing like e.Perm("Username") that returns true or false
Unfortunately because of how IRC is designed (there's not consistency between daemons) this is hard. There are some IRCv3 CAPs you could use (which I think are mentioned in the gist) but they don't work everywhere.
I;ve been messing a bit with this, and I have come up with a helper function that illustrates how to do it. I use this to check if the bot has +o:
// RequestReply abstracts sending a command to the IRC server and listening for a reply. Eventcodes must match the
// commands. See https://www.alien.net.au/irc/irc2numerics.html
func RequestReply(c *irc.Connection, eventcode, command string) (string, error) {
reply := make(chan string, 1)
id := c.AddCallback(eventcode, func(e *irc.Event) {
reply <- e.Message()
defer close(reply)
})
defer c.RemoveCallback(eventcode, id)
c.SendRaw(command)
var r string
select {
case r = <-reply:
case <-time.NewTicker(5 * time.Second).C:
return "", errors.New("timeout getting command response")
}
return r, nil
}
Then I can use it to send a "NAMES -ops
o, err := RequestReply(c, "366", "NAMES -ops "+channel)
if err != nil {
SendReply(c, channel, fmt.Sprintf("Error getting ops list: %s", err), false)
return
}
o is then a space-separated string of all channel operators on channel. Then you just need to make sure your bot's name's in there. However, see also #130