Solved IRC parsing

Discussion in 'Plugin Development' started by Skionz, Dec 6, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Skionz

    I am working on a plugin that uses an IRC but I have run into an issue. When the server send the bot a message it is in a format similar to this.
    Code:
    :Skionz!18d0584c@gateway/web/freenode/ip.24.208.88.76 PRIVMSG #Skionz :This is a test.
    What would be the best way to parse this data? To get the name I would do something like this:
    Code:
    line.substring(1, line.indexOf("!"))
    Assuming 'line' is the message it would return the users name. Would that be the best way to do it? Another question, does this format change at all? There are plenty of IRC commands and I need to make sure the format doesn't change or plenty of exceptions will be thrown.
     
  2. Offline

    PreFiXAUT

    Skionz My Idea would be to split it via PRIVMSG or any other IRC-Command. With this you get the name + Message. Otherwise you could also try to split it by empty spaces " ". I haven't done much with IRC (I tried to make an PHP-Twitch-Bot), but they look simular to your example and I think they also have these spaces.
     
  3. Offline

    Skionz

    PreFiXAUT It looks like the part after the 'PRIVMSG' command is the channels name but if you get a /msg then it is your name and the part after the '!' is the person sending you the message.
     
  4. Offline

    PreFiXAUT

    Skionz Well I didn't know that :/ I guess you should try to get a Page where all Commands/Messages have an Example how they look like when they aren't parsed yet, or you can only try it out I guess.

    When you got the Patterns/Examples and know what they look like, you can surely find a thing that they share and parse it from that point.
     
    Skionz likes this.
  5. Offline

    Skionz

    PreFiXAUT Yea I will probably end up just running every command and writing down the output.
     
Thread Status:
Not open for further replies.

Share This Page