Guest footballkid4 Posted April 22, 2006 Share Posted April 22, 2006 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 More sharing options...
buckd Posted September 16, 2008 Share Posted September 16, 2008 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 Link to comment Share on other sites More sharing options...
rarebit Posted September 16, 2008 Share Posted September 16, 2008 [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 More sharing options...
wildteen88 Posted September 16, 2008 Share Posted September 16, 2008 Locked. Link to comment Share on other sites More sharing options...
Recommended Posts