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
  #2  
Old 11-28-2002, 04:31 AM
KelteN KelteN is offline
 
Join Date: Nov 2002
Location: California
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool, if I ever setup a IRC channel for my forum. Ill be sure to use this hack/mod

Thx
Reply With Quote
  #3  
Old 11-28-2002, 05:46 AM
JulianD's Avatar
JulianD JulianD is offline
 
Join Date: Jan 2002
Posts: 455
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK thanks for the script All the script to get users in IRC made with PHP doesn't work on my host... I hope this one works
Reply With Quote
  #4  
Old 11-28-2002, 07:50 AM
futureal futureal is offline
 
Join Date: Feb 2002
Location: Del Mar, CA, USA
Posts: 556
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow, this is something I have been looking for, for a long time. Thanks!

Any idea what the server load might be like? It seems negligible, which is great. Hopefully the IRC servers my forums use will allow it to connect.
Reply With Quote
  #5  
Old 11-28-2002, 12:28 PM
FASherman's Avatar
FASherman FASherman is offline
 
Join Date: Aug 2002
Posts: 289
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by futureal
Wow, this is something I have been looking for, for a long time. Thanks!

Any idea what the server load might be like? It seems negligible, which is great. Hopefully the IRC servers my forums use will allow it to connect.
They will. They see it as just another client. Server load is practically nothing. Most of the load is on the IRC server, hence the check for "263" messages, which means the server responded that load is too high, please try again.

With 18 channels on a heavily used IRC server, it still completes in just under 3 minutes.
Reply With Quote
  #6  
Old 11-28-2002, 02:42 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Some questions:

#1. Does this bog down the server if you are NOT using a dedicated server? This was an issue with the egg-drop method.

#2. How might you store the nick as well for each person in the database? You could probably modify the table to be:
Code:
create table ircstat
(  channelname text not null primary key,
   channelusers smallint(5) not null default'0',
   usernicks text not null
);
But within your perl script, how might with the following query:
Code:
$sql = $vbdb->prepare("UPDATE ircstat SET channelusers=$field[4] WHERE channelname=\"$field[3]\"");
I could insert as well the nick each person (seperated by commas, maybe using variable $nick or $username?) It would be great if the nick corresponded with the persons actual username on the forum, but that would be much more difficult to achieve.

Anyway, if this is possible I'll defiantly consider installing the hack.
Reply With Quote
  #7  
Old 11-28-2002, 05:00 PM
FASherman's Avatar
FASherman FASherman is offline
 
Join Date: Aug 2002
Posts: 289
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You do NOT want to gather the nicks of everyone in a channel. Trust me. To do that, you would have to have the script (really a lightweight bot) JOIN each channel, run NAMES in each channel, parse the results, update the database and exit.

Imagine how disruptive it would be for this bot to bounce in and out every 5 minutes or so...

As for the server load, its minimal. The real load is on the IRC server.
Reply With Quote
  #8  
Old 11-29-2002, 04:10 PM
FASherman's Avatar
FASherman FASherman is offline
 
Join Date: Aug 2002
Posts: 289
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To get it to do what you request, change the script to this:

---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 = ('#Newsdesk','#Education','#Politics-&-Govt','#Military-&-Vets','#DallasMavericks','#TexasRangers','#Houston Texans','#YouthSports','#bits-&-bytes','#Daily-Web.Info','#technology','#religion-&-faith','#business-&-finance','#health','#SportsPage','#DallasStars','# DallasCowboys','#entertainment');
$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 "JOIN $channel\n";
while(defined($in=<$irc>)){
chop($in);
if($in=~/PING .*)/){
print $irc "PONG $1\n";
}
@field = split(/ /,$in);
if ($field[1] eq "353") {
@users = split(/:/,$in);
$users[2] =~ s/@//g;
$users[2] =~ s/\+//g;
$users[2] =~ s/ PutNickHere//; # <----Don't forget!
@nicks = split(/ +/,$users[2]);
$sql = $vbdb->prepare("UPDATE ircstat SET channelusers=$#nicks, channelnicks=\"$users[2]\" WHERE channelname=\"$field[4]\"");

$sql->execute;
print $irc "PART $channel\n";
last;
}
}
}
close($irc);
-----END CUT&PASTE PREVIOUS LINE----

This runs considerably faster, 20 seconds for 18 channels instead of 3 minutes, but it does have drawbacks.

First, is whatever time interval you set the script to run via cron, thats how often this user is going to join/leave the channel. The more often you do it, the more annoying it is. The less often you do it, the more stale your data becomes.

If you have channel bots, make sure they do not do an on_join greet to this nick. It just increases the annoyance factor. Also make sure this nick is exempy from excessive join/part bans.

This script is an example of the axiom, "Be careful what you wish for, you may get it".
Reply With Quote
  #9  
Old 11-29-2002, 06:08 PM
GoTTi GoTTi is offline
 
Join Date: Jun 2002
Posts: 1,346
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im confused as hell...ive never used cron jobs, but this would be of some good for me...

can you put the instructions in simpl form with more detailed instructions...it is kinda throwing me off...

example:
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.

I dont know how to use cron, so what would be the commands that I would use?
Reply With Quote
  #10  
Old 11-29-2002, 06:55 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@da_gotti: http://www.aota.net/Script_Installat.../cronhelp.php4

@FASherman: thanks for the script, I'll try it out and see how much of an annoyance it might be
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 10:49 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.13481 seconds
  • Memory Usage 2,297KB
  • Queries Executed 23 (?)
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
  • (2)bbcode_code
  • (1)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