Posted: Wed Aug 22, 2007 4:19 am Post subject: Having Aiden react to other events.....
Hi...
We've been working with the latest version of Aiden, and would like to have the bot monitoring a text file for other events.
A real basic example would be to monitor a text file for text, and send it to a chatroom.
The place to monitor for events would clearly be in active.pl, however whenever we try to send a message out from there... we've been unsuccess. Here's what we've got....
Code:
# active.pl - Keeps the bot active.
sub active {
# Loop each bot.
foreach my $bot (keys %{$aiden->{bots}}) {
unless (length $bot) {
delete $aiden->{bots}->{$bot};
next;
}
if ($aiden->{bots}->{$bot}->{listener} eq 'HTTP') {
&http_request($bot);
next;
}
if (-e "./data/msgs.txt") {
open (MASTER, "./data/msgs.txt");
my @data = <MASTER>;
close (MASTER);
foreach my $line (@data) {
print "Send to chat: $line\n";
$aim->chat_send ("CHATROOMNAME", $line);
}
unlink ("./data/msgs.txt")
}
# Unblock users.
foreach my $client (keys %{$aiden->{clients}}) {
if (exists $aiden->{clients}->{$client}->{blocked} && $aiden->{clients}->{$client}->{blocked} == 1) {
if (time() >= $aiden->{clients}->{$client}->{expires}) {
&userSend ($client,'blocked',0);
&userSend ($client,'expires',0);
print ×tamp . "\n"
. "AidenSYS: $client block time has expired.\n\n";
}
}
}
the rest of the file is standard....
The above attempt errors out, with $AIM not being defined... If we try sending the via the queue, it just never sends...
It's because Aiden doesn't use $aim, the variable you want is inside of $aiden->{bots}->{$bot}->{client}, where $bot is the s/n in lowercase/without spaces of the bot you want to control.
$aiden->{bots}->{"aidencks"}->{client}->send_im (...); _________________ Current Site (2008) http://www.cuvou.com/