Created
April 30, 2021 00:26
-
-
Save ecliptik/86e77e0f68b96517a7643e8997e9caef to your computer and use it in GitHub Desktop.
AIM Alerting Perl Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/perl -w | |
####################################################################################################### | |
#Name: aim_notify.pl | |
#Date: 02/21/2006 - mwaltz@ucsd.edu | |
#Purpose: Send an instant message over AOL to a list of screen names and then sign off. | |
#Usage: aim_notify.pl "message you want to send" | |
#Description: This script is for admins who want a server to alert them via AOL IM. A screen name can have message forwarded to a mobile phone number, making it a pager like application. | |
#Requires: NET::Oscar - http://search.cpan.org/~matthewg/Net-OSCAR-1.925/lib/Net/OSCAR.pm | |
####################################################################################################### | |
#Use the AIM Oscar module | |
use Net::OSCAR qw(:standard); | |
#Set some variables, the screenname we sign on with, it's password, and then our buddy list in an array | |
my $screenname = ""; | |
my $password = ""; | |
my @buddies = ("testwatchdog"); | |
#Set a initially to 1, after all messages are sent a is set to 0 which quits the program | |
my $a = 1; | |
#Find out our hostname, then get the message we want to send from the commandline. | |
my $hostname = `hostname`; | |
chomp($hostname); #chomp off the carriage return | |
my $error_message = $ARGV[0]; | |
#Make the message a little more readable and output it | |
my $message = "$hostname: $error_message\n"; | |
#print $message; | |
#This method catches any ims and echos it back to the sender | |
sub im_in { | |
my($oscar, $sender, $message_in, $is_away) = @_; | |
$message_in =~ s/<(.|\n)+?>//g; | |
print "[AWAY] " if $is_away; | |
# print $messagei_in."\n"; | |
if ($message_in eq "restart"){ | |
# print "recieved restart command\n"; | |
} | |
# print "$sender: $message_in\n"; | |
# $oscar->send_im ($sender,$message_in); | |
} | |
#The method sends the messages to each buddy in our array every 3 seconds(to avoid exceeding the rate limit). Signs off and sets a to 0, which kills the while loop at the bottom | |
sub signon_done { | |
foreach $buddy (@buddies) | |
{ | |
$oscar->send_im ($buddy,$message); | |
sleep 3; | |
} | |
#$oscar->signoff(); | |
#$a=0; | |
} | |
#do the actual connections and define our methods | |
$oscar = Net::OSCAR->new(); | |
$oscar->set_callback_im_in(\&im_in); | |
$oscar->set_callback_signon_done(\&signon_done); | |
$oscar->signon($screenname, $password); | |
#continue to remain online unti a is 0, which happens after all messages are sent | |
while($a) | |
{ | |
$oscar->do_one_loop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment