-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting user perms? #120
Comments
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 |
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 " command to the IRC server, and record the response: o, err := RequestReply(c, "366", "NAMES -ops "+channel)
if err != nil {
SendReply(c, channel, fmt.Sprintf("Error getting ops list: %s", err), false)
return
}
|
How can i get the senders perms?
ex: sender uses !test -> checks if sender has op perms
The text was updated successfully, but these errors were encountered: