#!/usr/bin/perl # $Id$ use warnings; use strict; $|=1; use Util::Backend; use Util::Common qw(try_uptime); my $last_mod = -1; my $last_chg = -1; svc_run("127.0.0.1", 12345); exit 0; sub OPS_FILE () { "./ops.data" } my %ops; sub on_join { my $msg = shift; if (-e OPS_FILE and ( -M OPS_FILE != $last_mod or -C OPS_FILE != $last_chg ) ) { $last_mod = -M OPS_FILE; $last_chg = -C OPS_FILE; if (open(OPS, "<" . OPS_FILE)) { my %temp_ops; while () { s/\s+$//; next if /^\s*\#/; next if /^\s*$/; my ($network, $mask, @channels) = split; $temp_ops{$network}{$mask} = { map { $_ => 1 } @channels }; } close OPS; %ops = %temp_ops; } } my $hash = $msg->actor() . "/" . $msg->channel(); if (exists $ops{$msg->network()}{$msg->actor()}{$msg->channel()}) { $msg->do("mode", $msg->cschannel(), "+o", $msg->csnick()); msg_send($msg); } } sub on_ctcp_action { goto &read_irc; } sub on_public { goto &read_irc; } sub read_irc { my $msg = shift; my $response = try_uptime( $msg->message(), "public", $msg->nick(), $msg->addressed(), ); if (defined $response) { $msg->say($response); msg_send($msg); } } sub on_msg { my $msg = shift; my $response = try_uptime( $msg->message(), "private", $msg->nick(), $msg->addressed(), ); if (defined $response) { $msg->say($response); msg_send($msg); } }