I am trying to canonize an input from a python bot connected to IRC.
My python script is as such: http://pastebin.com/St4A1vLf
If someone says “!help“, this appears in the command prompt (When I run the script at the command prompt).
:bot!~botty@112.443.22.5 #fish :!help
What I want to do is take the variable “data” and canonize it so it just shows the user’s nickname, i.e. “bot” so the staring colon ‘:‘ and the rest of the string (from the !~) is also removed.
After this, I want it to send the user who said “!help” a private message/query with “no help settings“. (I will add in the help commands later.)
First of all: The line you posted makes no sense as the command is missing. What you probably meant is
But why not use one of the existing irc implementations for python such as twisted-words? They allow you to handle certain commands (such as PRIVMSG in your case) easily.
If you do not want to do this, you need to parse the incoming message manually and extract whatever information you need.
Here’s a simple parser.
lineis one line received from the server.Here’s how the parsed lines look like: