Jump to content


This topic is now archived and is closed to further replies.

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');
        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;
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)

Share this post

Link to post
Share on other sites
hi im setting up a christian based chat site and i need code about what u said before your probelm , how does one connect to irc to recieve the channels list and user count if you would share code i would aprcitate it

Share this post

Link to post
Share on other sites
[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.

Share this post

Link to post
Share on other sites
This topic is now closed to further replies.


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.