Skip to content
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

After joining a channel, how do I get a list of usernames? #207

Open
MrBruz opened this issue May 13, 2023 · 1 comment
Open

After joining a channel, how do I get a list of usernames? #207

MrBruz opened this issue May 13, 2023 · 1 comment

Comments

@MrBruz
Copy link

MrBruz commented May 13, 2023

Im trying connection.names() after I join the channel (run the join function) but its returning None

@OrpheusGr
Copy link

OrpheusGr commented May 16, 2023

I believe connection.names() sends the command to the server, you probably need to make use of the "namreply" event to get the reply.

If you are using the SingleServerIRCBot or the SimpleIRCClient class, you can just add

def on_namreply(self, connection, event):
    #code here

to your code

Otherwise (if you're using the Reactor class) you probably gotta use add_global_handler() on a ServerConnection object:

e.g

def yourmethodnamehere(self, connection, event):
    #code here

x = irc.client.Reactor()
y = x.server()
y.add_global_handler("namreply", yourmethodnamehere)
y.connect(serverhere, porthere, nickhere)

P.S i assume connection.names() takes the channel name as an argument but i'm not sure.

P.S 2 You may need to use connection.names() within the on_join event cause i'm not sure that by calling it right after doing connection.join("#chan") there is enough time for the client to join #chan. In other words you might be sending NAMES too soon, before actually joining the channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants