Search code examples
pythonbotsircnames

Python IRC bot that reads data returned from a command of the IRC server


I have a similar question to PHP IRC bot that reads data returned from a command of the IRC server

I'm using an IRC bot written in Python found widely across the web.

I must send a "NAMES" command to the IRC server, which then returns a list of usernames that are currently in the channel that the bot is in. But I can't seem to catch that list, NOR get a message back from the server - the bot receives and prints messages sent by other users, but not by himself nor command outputs.

To print the data I'm using the following:

while True:
    data = irc.recv ( 4096 )
    (...)
    print data

To send the NAMES command I tried the following:

irc.send ( 'NAMES #channel\r\n' )

And:

irc.send ( 'PRIVMSG #channel :/names\r\n' )

The complete code at pastebin dot com: http://pastebin.com/xjymEjPu


Solution

  • I was just able to see the NAMES list in the script output

    :botty!~botty@durrrrrrrrr JOIN :#channel
    :retribution.sg.as.irchighway.net 353 botty = #channel :botty IlPalazzo-ojiisan @Nibelung 
    :retribution.sg.as.irchighway.net 366 botty #channel :End of /NAMES list.
    :retribution.sg.as.irchighway.net 353 botty = #channel :botty IlPalazzo-ojiisan @Nibelung 
    :retribution.sg.as.irchighway.net 366 botty #channel :End of /NAMES list.
    

    It isn't the last thing to pop up though. Perhaps you missed it? It was above a set of global notices that were the last lines to return.