digital adj. Having digits.     peer n. A comrade; a companion; a fellow; an associate. inmotion    
   
Recent Articles
Handling a Subversion Repository URL Change
Sunday, May 3, 2009
If your repository URL changes, you can use the following command to fix existing snapshots.
vfat Mounts Default to Lowercase Shortnames
Tuesday, April 21, 2009
I want a "this is brain-damage" quote from Linus for this mess.
VirtualBox or VMWare Virtual Machine at Login
Sunday, April 12, 2009
How to start a virtual machine in X when a user logs in.
Dialog Progress Bar Through Pipe
Sunday, April 12, 2009
How to use dialog to display a script progress bar and communicate progress to it through a named pipe.
Mount JFFS2 Image
Saturday, October 25, 2008
Example of how to mount a JFFS2 image using mtdblock.
Ottawa Linux Symposium 2008
Sunday, July 27, 2008
Here are some pictures from the 2008 Linux Symposium.
Linux Symposium 2008
Sunday, July 20, 2008
I'll be attending the Linux Symposium this year.
Clay Shirky: Institutions vs. collaboration
Monday, July 14, 2008
This is a rather interesting talk that takes some very foundational ideas from open source software development, P2P networks, and social networking and implies that these paradigms can apply to a lot more.

It is a simple task to make things complex, but a complex task to make them simple.

Projects-Gaim Plugins-IRC Chat...

IRC Chat Autoresponder

Sunday, July 11, 2004 by digitalpeer, updated Friday, August 6, 2004

This simply responds to shit people say in an IRC chat room so I don't have to be nice and type things like "hello" and "bye."
#!/usr/bin/perl -w
#
# AutoHello 0.0.1 by digitalpeer
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License 2 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License (http://www.gnu.org/copyleft/gpl.html)
# for more details.
#
# If you have no access to read the license, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Any suggestions are welcome.  There is sometimes a bot in #gaim on
# irc.openprojects.net running this code, but with more triggers, if
# you want to see it.


# I swear some people in #gaim use a damn script to say hi.
# So, here's my attempt to make one that's pretty "realistic."
# Of course, the brains are modeled after LSchiere AI.

# this is the max wait seconds when responding to a buddy joining the room
# a random second is picked somewhere in this
#WARNING: the min is 3 seconds, so if you put 1 here you'll get 3 or 4 seconds
$maxwait = 60;

# every time i respond, i go into sleep mode for this many seconds before I can talk again
# use this so you don't annoy those #gaim folks (i wouldn't go below 10)
$sleeptime = 10;

# what to respond with when bot is said
@iamnotabot = ("I AM NOT A BOT!, i don't think", "i have feelings too you know", "leave me alone", "there, i just wrote you down in my I don't like you book");

# greeting responses
@greetresponse = ("hello", "hi", "hey", "wahoo! it's", "howdy", "what's up", "what have you been up to");

# here are the responses used for saying goodbye
@ungreetresponse = ("goodbye", "later", "bye", "see you later", "see ya");

# this is the response that is used on "welcome back"
@wbresponse = ("wb", "welcome back", "back so soon", "in or out", "we missed you");

#here's a first in first out queue to use for welcome back
$lastusertoleave = "nobody";

# flag to keepp track of sleep mode
$allowspeak = 0;
$forcenospeak = "";

$queue_what = "";
$queue_where = "";
$queue_gc = "";
$queue_who = "";

# got a chat message, so lets decipher it
sub autohello_chat_recv
{
	if ($allowspeak)
	{
		$gc = $_[0];
		$where = $_[1];
		$who = $_[2];
		$what = $_[3];

		$me = GAIM::get_info(3, $gc);
		if ($who eq $me)
		{
			return 0;
		}
		elsif ($what =~ "GAIM " || $what =~ "gAIM" || $what =~ "gAim" || $what =~ "GAim" || $what =~ "gaIM")
		{
			$allowspeak = 0;
			#$answer = $ungreetresponse[rand @ungreetresponse];
			$queue_what = $who.": it is prefered that you use 'gaim' or 'Gaim' as the spelling";
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = $who;
			$minsleep = rand(10);
			GAIM::add_timeout_handler($minsleep, "autohello_dospeak");
			GAIM::add_timeout_handler($minsleep + $sleeptime, "autohello_enable_speak");
		}
		elsif ($what =~ "FAQ" || $what =~ "faq")
		{
			$allowspeak = 0;
			#$answer = $ungreetresponse[rand @ungreetresponse];
			$queue_what = "yes, the gaim FAQ can be found at http://gaim.sf.net/faq.php";
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = $who;
			$minsleep = rand(10);
			GAIM::add_timeout_handler($minsleep, "autohello_dospeak");
			GAIM::add_timeout_handler($minsleep + $sleeptime, "autohello_enable_speak");
		}
		elsif ($what =~ "digitalpeer" && ($what =~ "script" || $what =~ "bot"))
		{
			$allowspeak = 0;
			#$answer = $ungreetresponse[rand @ungreetresponse];
			$queue_what = $iamnotabot[rand @iamnotabot];
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = $who;
			GAIM::add_timeout_handler(2, "autohello_dospeak");
			GAIM::add_timeout_handler(20 + $sleeptime, "autohello_enable_speak");

		}
		elsif ($what =~ "digitalpeer" && ($what =~ "shutup" || $what =~ "quiet"|| $what =~ "stop"))
		{
			$allowspeak = 0;
			#$answer = $ungreetresponse[rand @ungreetresponse];
			$queue_what = "/me now walks and talks with a limp thanks to you";
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = $who;
			GAIM::add_timeout_handler(2, "autohello_dospeak");
			GAIM::add_timeout_handler(10 + $sleeptime, "autohello_enable_speak");

		}
		elsif ($what =~ "gaim" && ($what =~ "doesn't" || $what =~ "work"))
		{
			$allowspeak = 0;
			#$answer = $ungreetresponse[rand @ungreetresponse];
			$queue_what = "if your having a problem with gaim, FAQ can be found at http://gaim.sf.net/faq.php";
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = $who;
			GAIM::add_timeout_handler(5, "autohello_dospeak");
			GAIM::add_timeout_handler(10 + $sleeptime, "autohello_enable_speak");

		}
		elsif (($what =~ "MSN" || $what =~ "msn") && ($what =~ "work" || $what =~ "suck"))
		{
			$allowspeak = 0;
			#$answer = $ungreetresponse[rand @ungreetresponse];
			$queue_what = "You shouldn't use MSN.  MSN is evil.  Besides: it sux0rz.  If your friends use MSN, make them change.  If they won't change, get new friends.";
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = "";
			GAIM::add_timeout_handler(5, "autohello_dospeak");
			GAIM::add_timeout_handler(10 + $sleeptime, "autohello_enable_speak");

		}

	}
}


sub autohello_chat_buddy_leave
{
	$gc = $_[0];
	$where = $_[1];
	$who = $_[2];
	$me = GAIM::get_info(3, $gc);

	#make sure this isn't me
	if ($who eq $me)
	{
		return 0;
	}
	if ($queue_who =~ $who)
	{
		$forcenospeak = "1";
	}
	$lastusertoleave = $who;
}

#a buddy has entered the room
sub autohello_chat_buddy_join
{
	if ($allowspeak)
	{
		$gc = $_[0];
		$where = $_[1];
		$who = $_[2];
		$me = GAIM::get_info(3, $gc);

		#make sure this isn't me
		if ($who eq $me)
		{
			return 0;
		}

		if ($lastusertoleave =~ $who)
		{
			$allowspeak = 0;
			$answer = $wbresponse[rand @wbresponse];
			$queue_what = $answer." ".$who;
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = $who;
			$minsleep = rand($maxwait);
			GAIM::add_timeout_handler($minsleep, "autohello_dospeak");
			GAIM::add_timeout_handler($minsleep + $sleeptime, "autohello_enable_speak");
		}
		else
		{
			$allowspeak = 0;
			$answer = $greetresponse[rand @greetresponse];
			$queue_what = $answer." ".$who;
			$queue_where = $where;
			$queue_gc = $gc;
			$queue_who = $who;
			$minsleep = rand($maxwait);
			GAIM::add_timeout_handler($minsleep, "autohello_dospeak");
			GAIM::add_timeout_handler($minsleep + $sleeptime, "autohello_enable_speak");
		}
	}
}

# this is the renabler to come back from sleep mode
sub autohello_enable_speak
{
	$allowspeak = 1;
}

sub autohello_dospeak
{
	if (!$forcenospeak)
	{
		GAIM::print_to_chat($queue_gc, $queue_where, $queue_what);
	}
	$forcenospeak="";
}

# i have joined a chat, don't say hi to every freaking person, so wait
sub autohello_chat_join
{
	if ($allowspeak)
	{
		$allowspeak = 0;
		GAIM::add_timeout_handler(10, "autohello_enable_speak");
	}
}

#this is called when the plugin is unloaded
sub autohello_goodbye
{
	#GAIM::print("Unloading AutoHello", "Autohello is unloading.");
}

GAIM::register("AutoHello", "0.0.1", "autohello_goodbye", "");
GAIM::add_event_handler("event_chat_recv", "autohello_chat_recv");
GAIM::add_event_handler("event_chat_buddy_join", "autohello_chat_buddy_join");
GAIM::add_event_handler("event_chat_join", "autohello_chat_join");
GAIM::add_event_handler("event_chat_buddy_leave", "autohello_chat_buddy_leave");
GAIM::add_timeout_handler(10, "autohello_enable_speak",0);

Related Local Pages
GaimStat
Gaimmy

Submit Comment to This Article - Be the first!
Please post a comment if you have something to add, find something wrong, or would like more information on the topic at hand. Do not use the comment form to contact the author about unrelated concerns!

Name: Email (optional):
Enter verification number here: