This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Listing Users in a channel

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
N
Night_Prowler
Voice
Posts: 1
Joined: Sat Feb 24, 2007 4:20 pm

Listing Users in a channel

Post by Night_Prowler »

I've been searching trying to find a tcl script that will allow me to list users in my IRC channel, and export the data to a text file. I have foun several, but I havent yet to get anything to work. One I did find, has two parts, the tcl script, which exports the data to a text file, and a php script that reads the text file. the tcl script works "I think" and exports to a text file, but the php script I cant figure out. Below are the two parts, any help would be greately appchiated, or if you know of something maybe more simple that would be great! :))

Thanks
Night_Prowler

The TCLScript:

Code: Select all

set i2h_htmlfile "/var/www/html/Chat/users.txt"
set i2h_chan "#STK"
set i2h_text "#000000"
set maxupdate 60

bind join - "$i2h_chan %" i2h:make
bind kick - "$i2h_chan %" i2h:make
bind nick - "$i2h_chan %" i2h:make
 
proc i2h:make {args} {

  global i2h_htmlfile i2h_chan i2h_text server maxupdate 
  set i2h_file [open $i2h_htmlfile w]
  set online [chanlist $i2h_chan]
  set count [llength $online]
  set users [lindex $online 0]
  set users "[nick2hand $users $i2h_chan]users"


  for {set i 1} {$i < $count} {incr i 1} {
     set user [lindex $online $i]
  set ch_text [getchanhost $user]
  regsub -all \@.* $ch_text "" ch_text
  regsub -all ~ $ch_text "" ch_text
     set users "$users%20[nick2hand $user]%20$ch_text%20$user"

  }

  puts $i2h_file "$users<br>\n"
  close $i2h_file

if {[utimerexists ""] == ""} {utimer $maxupdate i2h:make}
  return 1
}

proc utimerexists {i2h:make} {
  foreach j [utimers] {if {[string compare [lindex $j 1] i2h:make] == 0} {return [lindex $j 2]}}
  return
}

proc i2h:convert {i2h_text} {
  #Strip control codes.. sorta
  regsub -all . $i2h_text "" i2h_text
  regsub -all . $i2h_text "" i2h_text
  regsub -all . $i2h_text "" i2h_text
  regsub -all . $i2h_text "" i2h_text
  regsub -all . $i2h_text "" i2h_text
  #Convert special chars
  regsub -all & $i2h_text "\&" i2h_text
  regsub -all \" $i2h_text "\"" i2h_text
  regsub -all < $i2h_text "\<" i2h_text
  regsub -all > $i2h_text "\>" i2h_text
  regsub -all "  " $i2h_text " \ " i2h_text
  return $i2h_text
}

i2h:make

utlog "IRC Bot nick list loaded."
The PHP Scipt

Code: Select all

<?
$onlinefile = "http://chat.hl2stk.net/~jgriggs/users.txt";
$killname = array("bot", "_$");
$httpfaulttime = 5;
function urlExists($url)
{
$url = ereg_replace("http://", "", $url);
list($domain, $file) = explode("/", $url, 2);
$fid=fsockopen($domain,80, $errno1, $errstr1,$httpfaulttime);
@fputs($fid,"GET /$file HTTP/1.0\r\nHost: $domain\r\n\r\n");
@$gets = fgets($fid, 1024);
@fclose($fid);
if (ereg("HTTP/1.1 200 OK", $gets)) return true;
else return false;
}
   if (!urlExists($onlinefile)) {
        $chatterson ="Error Getting User List.\n";
        $onlineirc="0";
        }
 else {
$file = fopen($onlinefile, "r");
while (!feof($file)) {
        $buffer .= fgets($file, 4096);
}
        fclose($file);
$buffer = strip_tags ($buffer); 
$buffer = chop($buffer);
$chatterson ="";
        $temparray = explode ("%20", $buffer);
        $temparraysize = sizeof ($temparray);

$k = 0;
for ($i = 0; $i < $temparraysize; $i+=3) {
$bufferarray[handle1][$k] = ($temparray[$i]);
$bufferarray[host][$k] =  ($temparray[$i+1]);
$bufferarray[nick][$k] = ($temparray[$i+2]);
$k+=1;
}
        $bufferarraysize = (sizeof ($temparray)/3);
        $onlineirc = ($bufferarraysize);
        $buffercount=0;
        for  ($buffercount=0; $buffercount < $bufferarraysize; $buffercount++) {
                        $tempbuff=$bufferarray[nick][$buffercount];

                foreach ($killname as $kilvalue) {
                        if (eregi($kilvalue, $tempbuff)) {
                $onlineirc=$onlineirc-1;
                $bufferarray[nick][$buffercount] = "";
                continue ;
                }  }  }
unset($chatterson);
 for ($i = 0; $i < $bufferarraysize; $i++) {
        if (!$bufferarray[nick][$i] == "") {
        if (!$chatterson == "") {
        $chatterson = $chatterson.", ".$bufferarray[nick][$i];
        }
        else { $chatterson = $bufferarray[nick][$i]; }
        }}


}


echo "<tr><td colspan=\"3\" bgcolor=\"#FFFFFF\"><font color=\"#FF6600\" size=\"1\"><div align=\"center\"><b>
$chatterson</div></b></font></td>
</tr><tr><td width=\"33%\" bgcolor=\"#FFFFFF\"><font color=\"#000000\"><b><div align=\"center\">Total Number of Users:</b></font></a><font color=\"#000000\"><b> $onlineirc</div></td><td width=\"34%\" bgcolor=\"#FFFFFF\"><div align=\"center\"><b><a href=\"jIRC+main.html\" target=\"_blank\">Click Here to Connect.</div></b></td><td width=\"33%\" bgcolor=\"#FFFFFF\"><div align=\"center\"><b><a href=\"irc://irc.ircserver.com:6667/Channelname\">#Channelname on irc.ircserver.com:6667</a></div></b></font></td></tr>";
?>
The Text Output
On channel #STK
STKBot
Juston
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

This forum is concerned with Eggdrop Tcl scripts and not php. Here you'll find a Tcl code which will save the nick list of each channel in a file.
Post Reply