Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 93fea36bd4
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (47 sloc) 1.611 kb
package MITBot;
use strict;
use warnings;
use POE;
use POSIX qw(mktime strftime);
use MIT;
use MIT::Session;
use MIT::UserDB;
use TOC::AIMUtils;
use MIT::Common;
sub genderList {
my ($self, $who, $chat, @args) = @_;
my @members;
return "Must be used in a chat." unless $chat;
@members = keys %{$self->{CHATS}->{$chat}->{MEMBERS}};
my $male = scalar grep{$MIT::userDB->gender($_) == GEN_MALE} @members;
my $female = scalar grep{$MIT::userDB->gender($_) == GEN_FEMALE} @members;
my $unk = (scalar grep{$MIT::userDB->gender($_) == GEN_UNKNOWN} @members)
- 1;
return "Gender distribution: $male Males - $female Females - $unk Unknown";
}
sub topic {
my ($self, $who, $chat, $args) = @_;
my $chatname;
my @args = split /\s+/,$args,2;
unless($chat) {
return "Usage: !topic <chatname> [new topic]" unless @args;
$chatname = shift @args;
} else {
$chatname = $self->{CHATS}->{$chat}->{NAME};
}
if (@args) {
return "Error: Permission denied"
unless $MIT::userDB->checkPerm($who, "topic set");
$MIT::userDB->setTopic($chatname, join(" ", @args), $who);
return;
} else {
my ($topic, $sn, $time) = $MIT::userDB->topic($chatname);
return "No topic set" unless $topic;
return "Topic: " . $topic .
" (Set by " . $MIT::userDB->displayName($sn) . " | " .
strftime('%a %b %Y %H:%M:%S %Z',localtime($time)) . ")";
}
}
registerCommand("genders" => \&genderList);
registerCommand("topic" => \&topic, 1);
1;
Jump to Line
Something went wrong with that request. Please try again.