Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases

Reply
 
Thread Tools
Users in IRC Channel(s) Details »»
Users in IRC Channel(s)
Version: 1.00, by FASherman FASherman is offline
Developer Last Online: May 2011 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 11-27-2002 Last Update: Never Installs: 8
 
No support by the author.

Okay, I'm not sure if this qualifies as a "true" hack or not. Feel free to move this to an appropriate area, if not.

At any rate, I have 18 IRC channels supporting a range of topics. What I needed was something to keep track of how many users where in each channel.

1. Create a tables named ircstat in your vbulletin database. The table consists of two fields, channelname (type = text) and channelusers (type = int, length = 3, Not Null, Default = 0).

2. Insert a row for each IRC channel you want to monitor:
INSERT INTO ircstat(channelname,channelusers) VALUES ('#channel','0')

Case IS important. It must match your IRC channel name EXACTLY.

3. Create a perl script called ircstat.pl. Cut and paste below into it and change the values that need changing:

---START CUT&PASTE NEXT LINE
#!/usr/bin/perl
$server = "change.irc.server";
$port = 6667;
$nick = "PickANick";
$realname = "Just passing through...";
use IO::Socket;
use DBI;
$dbname = "yourdbname";
$dbhost = "yourhost";
$dbuser = "yourdbuser";
$dbpasswd = "yourdbpassword";
$vbdb=DBI->connect("dbi:mysql:".$dbname.":".$dbhost,$dbuser, $dbpasswd);
@channels = ('#channel1','#channel2','#channel3');
$irc=IO::Socket::INET->new( PeerAddr=>$server, PeerPort=>$port, Proto=>'tcp')or die "$server: $@\n";
print $irc "USER $nick $nick $nick :$realname\n";
print $irc "NICK $nick\n";
while(@channels) {
$channel = shift @channels;
print $irc "LIST $channel\n";
while(defined($in=<$irc>)){
chop($in);
if($in=~/PING .*)/){
print $irc "PONG $1\n";
}
@field = split(/ /,$in);
if ($channel eq $field[3]) {
$sql = $vbdb->prepare("UPDATE ircstat SET channelusers=$field[4] WHERE channelname=\"$field[3]\"");
$sql->execute;
last;
}
if ($field[1] eq "263") {
print $irc "LIST $channel\n";
}
}
}
close($irc);
-----END CUT&PASTE PREVIOUS LINE----

4. Run this script out of cron. Every 5 minutes if you have 1 or 2 channels, every 10 minutes if you have more than 2 channels.

Remember, all this does is keeps the database updated. with the number of users in your channels. You'll have to decide where you want to display this information and make the appropriate php/template hacks.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 11-29-2002, 08:06 PM
FASherman's Avatar
FASherman FASherman is offline
 
Join Date: Aug 2002
Posts: 289
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Velocd
@FASherman: thanks for the script, I'll try it out and see how much of an annoyance it might be
I've go it running every 5 minutes and gave it the nick Census. With a nick that reflected what it was doing, it became less annoying.

This page uses its output: http://www.daily-web.info/modules.php?s=&name=Live

Open two browsers to this page. Leave one there. In the second, enter one of the discussion rooms. Doesn't matter which one. Wait until you see the census bot join and leave.

Refresh the first browser and verify that the info updated and that your nick in listed in the room.
Reply With Quote
  #13  
Old 11-29-2002, 08:39 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, well I waited for about 10 minutes in a channel yet no census ever showed. Nor the page ever update. :ermm:
Reply With Quote
  #14  
Old 11-29-2002, 09:43 PM
FASherman's Avatar
FASherman FASherman is offline
 
Join Date: Aug 2002
Posts: 289
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're correct. As I said, the script is really an lightweight IRCbot and, like many bots, it got temporarily k-lined. I switched it over to a new bot-friendly server and its fine.
Reply With Quote
  #15  
Old 12-01-2002, 02:08 AM
Scrooge Scrooge is offline
 
Join Date: Nov 2001
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First of all, I've been begging for this for months....thank you!

I could use a little help though. I'm not sure exactly how to fill out some of the values.

Quote:
INSERT INTO ircstat(channelname,channelusers) VALUES ('#channel','0')
Okay, you stated that it is case sensitive, so I assume something should be edited here. I only have one channel, #reefaquariumguide, do I enter this into the #channel spot? And do I leave a 0 after it?


In this line from the perl script:

Quote:
@channels = ('#channel1','#channel2','#channel3');
Do I edit that with the name of my channel as well?

I've got it setup now but get nothing. I am monitoring the chat and the bot never shows up. Just in case I setup the cron wrong I also tried running it in the command prompt. I checked the error logs and I don't see any errors it caused, but nothing shows up in the chat.

Thanks for any help
Reply With Quote
  #16  
Old 12-01-2002, 03:29 AM
Scrooge Scrooge is offline
 
Join Date: Nov 2001
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, solved my own question through trial and error I think. For others who might be as dumb as me.....put your channel in the first part I asked about....the second part stays as is.

The database is updating for me now. Could you give me a quick clue on what to edit in the php/templates? I tried putting $channelusers into the forumhome template but think I need to do something else because nothing displays.
Reply With Quote
  #17  
Old 12-01-2002, 10:02 PM
Scrooge Scrooge is offline
 
Join Date: Nov 2001
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any help? Or maybe at least point me to a place for the answer?
Reply With Quote
  #18  
Old 12-02-2002, 05:15 PM
Scrooge Scrooge is offline
 
Join Date: Nov 2001
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm feeling soooo unloved

Come on guys, someone help me out? I have the hack basically working, but being a PHP/SQL dummy I don't know how to make the variables work so I can display it. I know how to edit a template and put the variable where I want it.....but it is empty. I think I need to edit index.php maybe? I've been waiting for a who's in chat hack that didn't require eggdrop since January.......now I'm so close but not quite there.
Reply With Quote
  #19  
Old 12-03-2002, 01:51 AM
FASherman's Avatar
FASherman FASherman is offline
 
Join Date: Aug 2002
Posts: 289
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're on the right track. You have a variable in a template, but it contains nothing because it hasn't been loaded. Go into index.php and add the sql commands to load the variable.

Sorry for the late response, but I've been working on a tcl script for an eggdrop bot that does the database inserts directly via Mytcl on JOINs PARTs KICKs, QUICKs and server pings. That way the data will always be current since it'll be even driven, not time driven.
Reply With Quote
  #20  
Old 04-11-2003, 09:13 PM
deepdark's Avatar
deepdark deepdark is offline
 
Join Date: Dec 2001
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

any help about mysql query please how to add can any body send to me a copmleted copy paste query please
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05013 seconds
  • Memory Usage 2,292KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete