Jump to content


IRC To HTML


  • This topic is locked This topic is locked
3 replies to this topic

#1 Guest_footballkid4_*

Guest_footballkid4_*
  • Guests

Posted 22 April 2006 - 03:26 AM

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:
$topic = preg_replace_callback("#".$c."([0-9]+)(,([0-9]+)|$)#is",array($this,'color'),$topic);

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

#2 buckd

buckd
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 September 2008 - 04:08 PM

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

#3 rarebit

rarebit
  • Members
  • PipPipPip
  • Advanced Member
  • 1,002 posts

Posted 16 September 2008 - 04:24 PM

buckd, you basically use a socket to connect and the implement the IRC protocol rfc1459, 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.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 16 September 2008 - 05:57 PM

Locked.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users