summaryrefslogtreecommitdiffstats
path: root/modules/command.pl
diff options
context:
space:
mode:
Diffstat (limited to 'modules/command.pl')
-rw-r--r--modules/command.pl41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/command.pl b/modules/command.pl
new file mode 100644
index 0000000..87c768f
--- /dev/null
+++ b/modules/command.pl
@@ -0,0 +1,41 @@
+use warnings;
+use strict;
+
+sub do_command
+{
+ my ($conn, $event) = @_;
+ my $args = $event->{args}->[0];
+ my $from = $event->{from};
+ my $cmd = $args;
+ my $d1;
+ my $nick = lc $event->{nick};
+ foreach my $command ( @{$::commands->{command}} )
+ {
+ if (defined($command->{flag})) {
+ next unless defined($::xusers->{$nick});
+ next unless defined($::xusers->{$nick}->{flags});
+ next unless defined(grep {$_ eq $command->{flag}} split('', $::xusers->{$nick}->{flags}));
+ if ($::xusers->{$nick}->{host} ne 'IDENTIFY') {
+ next unless leq($::xusers->{$nick}->{host}, $event->{host});
+ }
+ else {
+ if ( $cmd =~ /$command->{cmd}/ ){
+ push (@{$::idqueue{$nick}}, [$cmd, $command, $event]);
+ $conn->sl("whois $nick $nick");
+ next;
+ }
+ }
+ }
+ if ($cmd=~/$command->{cmd}/) {
+ print "$event->{from} told me: $cmd \n";
+ eval $command->{content};
+ warn $@ if $@;
+ }
+ }
+}
+
+sub Command::killsub {
+ undef &do_command;
+}
+
+return 1;