forked from frumiousbandersnatch/RocksBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_test.pl
executable file
·89 lines (64 loc) · 1.8 KB
/
plugin_test.pl
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/perl
## This is just a hack thing for testing plugins at the command line.
## It's not complete, but useful for testing. Pardon my goto.
$channel = "#test";
$nick = "someguy";
$mask = "mask\@/user/mask";
$ConfigFile = "./rocksbot.cfg";
#################################
use modules::CommandHandler;
use Data::Dumper;
print "Enter a command: ";
$filter_applied = 0;
if (@ARGV){
$last_args = join " ", @ARGV;
}
while (<STDIN>){
$args = $_;
chomp ($args);
if ($args){
$last_args = $args;
}else{
$args = $last_args;
}
$filter_applied = 0;
BEGIN:
($cmd, $opts) = split( " ", $args, 2);
my $ch_options = {
ConfigFile => $ConfigFile
};
$ch = modules::CommandHandler->new($ch_options);
$ch->loadPluginInfo();
$ch->setValue("command", $cmd);
$ch->setValue("options", $opts);
$ch->setValue("nick", $nick);
$ch->setValue("channel", $channel);
$ch->setValue("mask", $mask);
$ch->setValue("filter_applied", $filter_applied);
$output = $ch->Execute();
#print Dumper ($output);
$filter_applied = $output->{filter_applied};
if ($output->{output}){
if ($output->{return_type} eq 'action'){
print "RocksBot $output->{output}\n";
}elsif ($output->{return_type} eq 'text'){
if ($output->{suppress_nick}){
print "$output->{output}\n";
}else{
print $output->{'nick'} . ": $output->{output}\n";
}
}elsif($output->{return_type} eq "irc_yield"){
print "-->Doing IRC Yield command $output->{yield_command} \n";
print "Args:\n";
print Dumper($output->{yield_args});
print "$output->{output}\n";
}elsif($output->{return_type} eq "runBotCommand"){
$args = $output->{output};
goto BEGIN;
}
}
if ($output->{reentry_command}){
print "-->Reentry: $output->{reentry_command} Opts: $output->{reentry_options} <--\n";
}
print "\nEnter a command: ";
}