Jump to content

IRC To HTML


Guest footballkid4

Recommended Posts

Guest footballkid4
I'm not sure if anyone's had a project like this before, but now it's come upon me. I'm making a script that connects to a network, uses the LIST command, and gets a list of all of the channels, the amount of users on them, the channel mode, and the topic. What I've realized is that the topics need some formatting, and I can't seem to find the best way to do that. I've used preg_replace_callback, like this:
[code]$topic = preg_replace_callback("#".$c."([0-9]+)(,([0-9]+)|$)#is",array($this,'color'),$topic);[/code]

[code]    function color($topic)
    {
        $colors = array(0 => 'white' , 1 => 'black' ,
         2 => 'blue' , 3 => 'green' , 4 => 'red' ,
         5 => 'maroon' , 6 => 'purple' , 7 => 'orange' ,
         8 => 'yellow' , 9 => 'lime' , 10 => 'teal' ,
         11 => 'cyan' , 12 => 'blue' , 13 => 'magenta' ,
         14 => 'gray' , 15 => 'lightgray');
        $_SESSION['tags']['c']++;
        if ((strlen($topic[1]) == 2) && (substr($topic[1],0,1) == 0)) {
            $topic[1] = substr($topic[1],1);
        }
        if ((strlen($topic[3]) == 2) && (substr($topic[3],0,1) == 0)) {
            $topic[3] = substr($topic[3],1);
        }
        if (($topic[3]) && $this->valid($topic[3])) {
            $tag = "<span style='color:".$colors[$topic[1]].";background-color:".$colors[$topic[3]].";'>";
        }
        elseif (($topic[1]) && $this->valid($topic[1])) {
            $tag = "<span style='color:".$colors[$topic[1]]."'>";
        }
        return $tag;
    }[/code]
With no luck. If anyone knows about IRC, and can help...I'd appreciate it

(PS: The code I posted *works*, it just doesn't actually replace every color)
Link to comment
Share on other sites

  • 2 years later...
[b]buckd[/b], you basically use a socket to connect and the implement the IRC protocol [url=http://tools.ietf.org/html/rfc1459]rfc1459[/url], see section 4.2.6 for the LIST command. To reverse engineer use something like ethereal to capture a session over the network and study the communication.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.