-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartemis.pl
More file actions
executable file
·48 lines (48 loc) · 2.15 KB
/
artemis.pl
File metadata and controls
executable file
·48 lines (48 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
use Artemis;
# main::DEBUG was probably a horrible idea, and I should write it out, but it's rather hardcoded.
# undef or false for a slightly quieter artemis.
$main::DEBUG = 1;
# internals can be overriden in new.
# dereferencing an artemis object would in theory clone the running bot with filehandles intact.
# TODO: use this to allow running changes to Artemis.pm
# note that cloning an Artemis object like this and calling Process on both may have unforseen consequences.
open(STDERR,">>","/home/jercos/artemis.log");
my $art = Artemis->new;
$art->load("core");
# A little preperation. if this gets closed, we want to save the user db first.
# Obviously, this will need to be something more robust.
# TODO: make this not suck :P
$SIG{INT}=sub{exit};
END{
open USERDB, ">users.db";
for(keys %{$art->{users}}){
print USERDB pack("Z*Z*n",$_,$art->{pass}{$_},$art->{users}{$_}),"\n" unless lc($_) eq "root";
}
}
# And now, we load the user db. note the simple pack/unpack methodology for the example.
# if one so desired, one could tie a hashref to users and pass instead.
open USERDB, "<users.db";
while(<USERDB>){
my($user,$pass,$level) = unpack("Z*Z*n",$_);
print "adding $user at $level hash of $pass\n";
next if lc $user eq 'root';
$art->{users}{$user} = $level;
$art->{pass}{$user} = $pass;
}
close USERDB;
# example connect line. it is quite important to me that it is simple to connect to multiple hosts,
# so type and host are all that are needed. nick and autojoin, however, are quite useful.
# pass may well serve the bot owner, but since this is publicly accessable, I think I'll leave it off :P
$art->connect(
{type=>"term"},
# {type=>"irc",host=>"irc.foonetic.net",nick=>"artemis2",autojoin=>["#test","#bots","#boats","#xkcd-religion"]},
# {type=>"irc",host=>"10.156.12.4",nick=>"artemis2",autojoin=>["#artemis","#bots","#clueirc"]},
# {type=>"jabber",host=>"jercos.dyndns.org",nick=>"artemis",pass=>"noonebutme"},
);
# a simple loop over Process() is all that is strictly neccisary, however Process() does not block.
# feel free to perform nonblocking or short-blocking tasks at the same time.
while(1){
$art->Process();
select(undef,undef,undef,0.2)
}