1 ################################
3 ################################
5 # "uuidgen" should be installed on the path somewhere.
6 # you can get the source of uuidgen from CVS, see:
7 # http://lxr.mozilla.org/mozilla/source/webtools/mozbot/uuidgen/
9 package BotModules::UUIDGen;
11 @ISA = qw(BotModules);
18 '' => 'This module is an interface to the uuidgen application.',
19 'uuid' => 'Generates a UUID.',
20 'cid' => 'Generates a UUID but outputs format suitable for components (CID).',
26 my ($event, $message) = @_;
27 if ($message =~ /^\s*uuid(?:[\s,!?]+please)?[\s,!?]*\s*$/osi) {
28 $self->spawnChild($event, 'uuidgen', [], 'UUID', []);
29 } elsif ($message =~ /^\s*cid(?:[\s,!?]+please)?[\s,!?]*\s*$/osi) {
30 $self->spawnChild($event, 'uuidgen', [], 'CID', []);
32 return $self->SUPER::Told(@_);
34 return 0; # we've dealt with it, no need to do anything else.
37 # ChildCompleted - Called when a child process has quit
40 my ($event, $type, $output, @data) = @_;
41 if ($type eq 'UUID') {
43 $output .= " (/msg $nicks[$nick] cid for CID form)";
44 $self->say($event, $output);
45 } elsif ($type eq 'CID') {
48 my @split = split(/-/, $output);
49 $output = "{0x$split[0], 0x$split[1], 0x$split[2], {";
51 my @rest = $split[3] =~ m/(..)(..)/;
52 push(@rest, $split[4] =~ m/(..)(..)(..)(..)(..)(..)/);
58 # remove the space and comma
63 $self->say($event, $output);
65 return $self->SUPER::ChildCompleted(@_);