Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7079e203a8 | ||
|
|
727062b14b | ||
|
|
df31622f82 | ||
|
|
76d2c03281 | ||
|
|
303e03f4ee | ||
|
|
99bb0721ba | ||
|
|
6f9e6f0d5d | ||
|
|
ccab5e9ab9 | ||
|
|
03c1616364 | ||
|
|
193461abf4 | ||
|
|
f1a9b91a30 | ||
|
|
f3ad8e0e38 | ||
|
|
81ff64ba4f | ||
|
|
33b50a651a | ||
|
|
fdfc249ba8 | ||
|
|
f68646d155 | ||
|
|
6357c54574 | ||
|
|
a8ea3f0e64 | ||
|
|
3fdf7dcaf5 | ||
|
|
105e83699d | ||
|
|
338551b44c | ||
|
|
412261f478 | ||
|
|
988e93a6f1 | ||
|
|
6c4ff75a03 | ||
|
|
362310b863 | ||
|
|
a2002882d6 | ||
|
|
3ebe82ec28 | ||
|
|
42faabeef5 | ||
|
|
21fb5d4974 | ||
|
|
8147e9e32a | ||
|
|
0864f549d1 | ||
|
|
ba5de67e4a | ||
|
|
3bd8e9369d | ||
|
|
e33fd1df8d | ||
|
|
3ef78078c4 | ||
|
|
a1beabe76a | ||
|
|
f12b7ef527 | ||
|
|
ed56d53f1e | ||
|
|
e590c0dee3 | ||
|
|
9fca160de5 | ||
|
|
28e29f2dba | ||
|
|
c30f300b24 | ||
|
|
0d9a714c4a | ||
|
|
87ff93945f | ||
|
|
c13a4e2ffe | ||
|
|
42fcac5cc0 | ||
|
|
01a432f023 | ||
|
|
a47211763c | ||
|
|
8cddc69209 | ||
|
|
b6eb0c17cc | ||
|
|
38b3e4c3d8 | ||
|
|
503a7ed990 | ||
|
|
579485776d | ||
|
|
f5db549052 | ||
|
|
72006a8e7e | ||
|
|
2ca0885741 | ||
|
|
6c6b8604bc | ||
|
|
da28c54652 | ||
|
|
f0b49acbd0 | ||
|
|
58447eb40a | ||
|
|
363a724ed3 | ||
|
|
a122977644 | ||
|
|
51f30e6346 | ||
|
|
82c0201c34 | ||
|
|
3da9a98feb | ||
|
|
ee1bf65766 | ||
|
|
69927a21de | ||
|
|
bb10d54844 | ||
|
|
1adcd0323b | ||
|
|
743bee7424 | ||
|
|
56b55d8370 | ||
|
|
8ec0a389d5 | ||
|
|
a9d6e3482b | ||
|
|
ae9401bf7d | ||
|
|
c818d13e04 | ||
|
|
cf6a99e170 | ||
|
|
516d11a5f7 | ||
|
|
dc96422598 | ||
|
|
e525af97a7 | ||
|
|
60e9bca86d | ||
|
|
8b3f287a49 | ||
|
|
da15ed72e8 | ||
|
|
76e903bb87 | ||
|
|
36b3761977 | ||
|
|
a6da576144 | ||
|
|
a2975d4859 | ||
|
|
a328fc45cd | ||
|
|
38015434e1 | ||
|
|
fe353984c2 | ||
|
|
d31b16200e | ||
|
|
9a526e1427 | ||
|
|
8ddd4f5bae | ||
|
|
1ef6814e9b | ||
|
|
37030d7a55 | ||
|
|
94db7280ff | ||
|
|
50f577470e | ||
|
|
6dd9ab5322 | ||
|
|
1e45c53d38 | ||
|
|
07d9c19b53 | ||
|
|
a79e6f3801 | ||
|
|
1bcc849083 | ||
|
|
31428c8089 | ||
|
|
8f58cb3c9f | ||
|
|
bc287589bb | ||
|
|
de3e914e3d | ||
|
|
e868892f51 | ||
|
|
ce8ef76363 | ||
|
|
06f22be92b | ||
|
|
d12c139829 | ||
|
|
3a8c2f31ba | ||
|
|
051c189fe8 | ||
|
|
6035a0fdb5 | ||
|
|
6539bd5fed | ||
|
|
8780cf5b93 | ||
|
|
a357eab962 | ||
|
|
e2038ed983 | ||
|
|
2469d636f5 | ||
|
|
176f861d2c | ||
|
|
68e9f59267 | ||
|
|
48864ee9fb | ||
|
|
e833309c4e | ||
|
|
3c81f0587a | ||
|
|
5366855f96 | ||
|
|
caf9b36b8c | ||
|
|
789cec8f80 | ||
|
|
ed72b5e444 | ||
|
|
3cfe22e5c1 | ||
|
|
ea775d4c98 | ||
|
|
153084f808 | ||
|
|
637db6bae4 | ||
|
|
7f4ea8d196 | ||
|
|
8ee16eb39b | ||
|
|
6813a009df | ||
|
|
1d6436b59b | ||
|
|
0e781dde9d | ||
|
|
4021eabcf5 | ||
|
|
79db0a2687 | ||
|
|
05e49c0ba1 | ||
|
|
0cb486191f | ||
|
|
5bbbe224d3 | ||
|
|
d0eeb58c72 | ||
|
|
168266696a | ||
|
|
703f2c2ec8 | ||
|
|
c999bd1372 | ||
|
|
be9932498b | ||
|
|
e033b76a6c | ||
|
|
0315a1f121 | ||
|
|
669561c8a4 | ||
|
|
3e1e2e98be | ||
|
|
f2deae219d | ||
|
|
ab2d404f20 | ||
|
|
8a8166bdb8 | ||
|
|
374b04fddc | ||
|
|
502cda97ed | ||
|
|
908dc13159 | ||
|
|
1eff0e95e9 | ||
|
|
b52b488165 | ||
|
|
1bbcc6feec | ||
|
|
a153045bc3 | ||
|
|
9a61c75772 | ||
|
|
43928f70dc | ||
|
|
9c8687da1c | ||
|
|
61fe399ac6 | ||
|
|
e2afe403c0 | ||
|
|
0dc4f7a2b7 | ||
|
|
dbdb9e0d67 | ||
|
|
6b09c4d818 | ||
|
|
f75618e5ec | ||
|
|
f19838091c | ||
|
|
25a0ec8081 | ||
|
|
9b9997a24d | ||
|
|
618cc6cccb | ||
|
|
ddf2e8bdea | ||
|
|
992bc5affb | ||
|
|
ca0545b000 | ||
|
|
ebf0a78cce | ||
|
|
344ce60f00 | ||
|
|
e2d26e3982 | ||
|
|
98736ebac6 | ||
|
|
59d5c36cba | ||
|
|
a02a3a8728 | ||
|
|
8e1ce1476e | ||
|
|
881fc0d93d | ||
|
|
580770c5b8 | ||
|
|
6033904d0d | ||
|
|
c1960f5837 | ||
|
|
9bd3e5227b | ||
|
|
3efed8bad4 | ||
|
|
7342c70639 | ||
|
|
d0652138a1 | ||
|
|
0480810e59 | ||
|
|
9f223b5b92 | ||
|
|
2836ebc6a3 | ||
|
|
30c9178c4e | ||
|
|
68c4ca7b4a | ||
|
|
9f3a8624c9 | ||
|
|
11ea707bbe | ||
|
|
506921214d | ||
|
|
9de77699f9 | ||
|
|
f0807a8306 | ||
|
|
3ce0003c9e | ||
|
|
51d8bb69dd | ||
|
|
c3ac079e14 | ||
|
|
ad3340d82a | ||
|
|
978a1585c8 | ||
|
|
4337f29d0a | ||
|
|
a587bab1c9 | ||
|
|
1b13f4c39b | ||
|
|
e61fdee14c | ||
|
|
9b0e692a8f | ||
|
|
70723dfe68 | ||
|
|
10fbddd2a6 | ||
|
|
963f55cc01 | ||
|
|
123357c448 | ||
|
|
0b6ed4c0cc | ||
|
|
004c89f416 | ||
|
|
d4ff35a5f9 | ||
|
|
f4448302e2 | ||
|
|
348ee6dc79 | ||
|
|
604097ee1c | ||
|
|
3a7ffb24ee | ||
|
|
60edbba15d | ||
|
|
12ed97b398 | ||
|
|
bd6571bbf5 | ||
|
|
c15c945262 | ||
|
|
5f1bf3785c | ||
|
|
45bb7e668c | ||
|
|
c268f27308 | ||
|
|
62551dc6c9 | ||
|
|
12356984fc | ||
|
|
223cdd7860 | ||
|
|
9e8018c98e | ||
|
|
0e708c5ee3 | ||
|
|
a66d6993cd | ||
|
|
328eac87b0 | ||
|
|
0e46850a65 | ||
|
|
5da0eb0f6e | ||
|
|
8c037a9a35 | ||
|
|
4e0384d645 | ||
|
|
117ef08c23 | ||
|
|
e67b4b265c | ||
|
|
4dbfac1f5e | ||
|
|
956cd12e5b |
No files matched your search
@@ -2,3 +2,5 @@ auto.conf
|
||||
build/*
|
||||
*.swp
|
||||
autodoc/*
|
||||
*.db
|
||||
var/*
|
||||
@@ -7,35 +7,29 @@
|
||||
|
||||
3.0
|
||||
|
||||
|
||||
The future of IRC bots is here! Xelhua gives to you, Auto 3.0, a new version of
|
||||
the popular Auto IRC bot.
|
||||
|
||||
In this alpha6 release, we have added:
|
||||
In this alpha11 release, we have added:
|
||||
|
||||
* Support for Microsoft Windows. See doc/WINDOWS if running on Windows.
|
||||
* Added an UNO module for playing the classic game of UNO.
|
||||
* Added an Eval module for evaluating Perl code.
|
||||
* Added a BotStats module for returning statistics about the bot.
|
||||
* PRIVMSG's and NOTICE's that would create a resulting message of >512 bytes are
|
||||
now divided into multiple messages.
|
||||
* Ping: Speed improvements.
|
||||
* An advanced IRC version of the popular party game Werewolf (AKA Mafia).
|
||||
* Commands with prefixes now work in PM's too.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* Fixed a bug that occurs when our configured nickname is in use.
|
||||
* Fixed a bug with multi-prefix support.
|
||||
* Fixed a bug with SASL timeouts.
|
||||
* Fixed significant state mismatched data bugs.
|
||||
|
||||
Incompatibilities:
|
||||
|
||||
* Module API changes. Minimum version is now 3.0.0a6 from 3.0.0a4.
|
||||
None
|
||||
|
||||
We thank you for choosing Auto. Please remember that he is still in mid-
|
||||
development stages. But we hope we've piqued your interest, as Auto's upcoming
|
||||
module repository will allow modules to be created by anyone and uploaded
|
||||
there for everyone to use.
|
||||
We thank you for choosing Auto. Please remember that he is coming to late
|
||||
development stages soon, and testers are needed! But we hope we've piqued
|
||||
your interest, as Auto's upcoming module repository will allow modules to be
|
||||
created by anyone and uploaded there for everyone to use.
|
||||
|
||||
Auto's goal is to create an efficient, stable and highly customizable IRC bot
|
||||
in Perl. To offer an alternative to other platforms.
|
||||
|
||||
Enjoy Auto 3.0.0 Alpha 6!
|
||||
Enjoy Auto 3.0.0 Alpha 11!
|
||||
@@ -38,7 +38,8 @@ Contributors - Non-developers who contribute to the project greatly.
|
||||
|
||||
3. HOW TO INSTALL
|
||||
|
||||
Installation documentation is at: http://wiki.xelhua.org/index.php/Auto:Install
|
||||
Installation documentation is at:
|
||||
http://wiki.xelhua.org/index.php/Auto:Installation_guide
|
||||
|
||||
|
||||
4. HOW TO UPGRADE
|
||||
|
||||
@@ -42,7 +42,7 @@ greatly.
|
||||
|
||||
## 3. HOW TO INSTALL
|
||||
|
||||
Installation documentation can be found [here](http://wiki.xelhua.org/index.php/Auto:Install).
|
||||
Installation documentation can be found [here](http://wiki.xelhua.org/index.php/Auto:Installation_guide).
|
||||
|
||||
|
||||
## 4. HOW TO UPGRADE
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
:: auto.bat - Launcher for Microsoft Windows.
|
||||
:: Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
:: Released under the terms stated in doc/LICENSE.
|
||||
:: Clone of `auto`, since Windows likes Batch, not sh.
|
||||
|
||||
@echo off
|
||||
|
||||
set pidfile=bin/auto.pid
|
||||
|
||||
if "%1" == "" goto errparams
|
||||
if "%1" == "start" goto start
|
||||
if "%1" == "status" goto status
|
||||
else goto errparams
|
||||
|
||||
:errparams
|
||||
echo.
|
||||
echo Usage: auto.bat (start|status) [force]
|
||||
:end
|
||||
|
||||
:start
|
||||
echo.
|
||||
if exist "%pidfile" (
|
||||
if "%2" == "force" (
|
||||
echo Starting Auto. . .
|
||||
perl bin/auto
|
||||
)
|
||||
else (
|
||||
echo Auto appears to be running already. Run `auto.bat start force` to start anyway.
|
||||
)
|
||||
)
|
||||
else (
|
||||
echo Starting Auto. . .
|
||||
perl bin/auto
|
||||
)
|
||||
:end
|
||||
|
||||
:status
|
||||
echo.
|
||||
if exist "%pidfile" (
|
||||
echo Status: Auto appears to be running.
|
||||
)
|
||||
else (
|
||||
echo Status: Auto appears to not be running.
|
||||
)
|
||||
:end
|
||||
@@ -9,21 +9,56 @@ use strict;
|
||||
use warnings;
|
||||
no feature qw(state);
|
||||
use POSIX;
|
||||
use locale;
|
||||
use English qw(-no_match_vars);
|
||||
use Sys::Hostname;
|
||||
use IO::Socket;
|
||||
use IO::Select;
|
||||
use Getopt::Long;
|
||||
use DBI;
|
||||
use Class::Unload;
|
||||
use FindBin qw($Bin);
|
||||
our $Bin = $Bin; ## no critic qw(NamingConventions::Capitalization Variables::ProhibitPackageVars)
|
||||
our (%bin, $UPREFIX);
|
||||
BEGIN {
|
||||
unshift @INC, "$Bin/../lib";
|
||||
$bin{cwd} = getcwd;
|
||||
if (!-e "$Bin/../build/syswide") {
|
||||
# Must be a custom PREFIX install.
|
||||
$bin{etc} = "$bin{cwd}/etc";
|
||||
$bin{var} = "$bin{cwd}/var";
|
||||
if (!-e "$Bin/lib/Lib/Auto.pm") {
|
||||
# Must be a system wide install.
|
||||
$bin{lib} = "$Bin/../lib/autobot/3.0.0";
|
||||
$bin{bld} = "$bin{lib}/build";
|
||||
$bin{lng} = "$bin{lib}/lang";
|
||||
$bin{mod} = "$bin{lib}/modules";
|
||||
}
|
||||
else {
|
||||
# Or not.
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
}
|
||||
$UPREFIX = 1;
|
||||
}
|
||||
else {
|
||||
# Must be a standard install.
|
||||
$bin{etc} = "$Bin/../etc";
|
||||
$bin{var} = "$Bin/../var";
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
$UPREFIX = 0;
|
||||
}
|
||||
|
||||
unshift @INC, $bin{lib};
|
||||
|
||||
if (-d "$Bin/../.git") {
|
||||
open my $gitfh, '<', "$Bin/../.git/refs/heads/indev";
|
||||
our $VERGITREV = substr readline $gitfh, 0, 7;
|
||||
close $gitfh;
|
||||
}
|
||||
|
||||
# Set version information.
|
||||
use constant { ## no critic qw(ValuesAndExpressions::ProhibitConstantPragma)
|
||||
@@ -41,19 +76,21 @@ use API::Log qw(alog dbug);
|
||||
use Parser::Config;
|
||||
use Parser::Lang;
|
||||
use Proto::IRC;
|
||||
use State::IRC;
|
||||
use Core::IRC;
|
||||
use Core::IRC::Users;
|
||||
use Core::Cmd;
|
||||
|
||||
our $VERSION = 3.0.0;
|
||||
our $VERSION = 3.000000;
|
||||
local $PROGRAM_NAME = 'auto';
|
||||
|
||||
# Check for build files.
|
||||
if (!-e "$Bin/../build/os" or !-e "$Bin/../build/perl" or !-e "$Bin/../build/time" or !-e "$Bin/../build/ver") {
|
||||
if (!-e "$bin{bld}/os" or !-e "$bin{bld}/perl" or !-e "$bin{bld}/time" or !-e "$bin{bld}/ver") {
|
||||
say 'Missing build file(s). Please build Auto before running it.' and exit;
|
||||
}
|
||||
|
||||
# Check build OS.
|
||||
open my $BFOS, '<', "$Bin/../build/os" or say 'Cannot start: Broken build.' and exit;
|
||||
open my $BFOS, '<', "$bin{bld}/os" or say 'Cannot start: Broken build.' and exit;
|
||||
my @BFOS = <$BFOS>;
|
||||
close $BFOS or say 'Cannot start: Broken build.' and exit;
|
||||
if ($BFOS[0] ne $OSNAME."\n") {
|
||||
@@ -63,14 +100,14 @@ undef @BFOS;
|
||||
|
||||
# Check build features.
|
||||
our $ENFEAT;
|
||||
open my $BFFEAT, '<', "$Bin/../build/feat" or say 'Cannot start: Broken build.' and exit;
|
||||
open my $BFFEAT, '<', "$bin{bld}/feat" or say 'Cannot start: Broken build.' and exit;
|
||||
my @BFFEAT = <$BFFEAT>;
|
||||
close $BFFEAT or say 'Cannot start: Broken build.' and exit;
|
||||
$ENFEAT = substr $BFFEAT[0], 0, length($BFFEAT[0]) - 1;
|
||||
undef @BFFEAT;
|
||||
|
||||
# Check build Perl version.
|
||||
open my $BFPERL, '<', "$Bin/../build/perl" or say 'Cannot start: Broken build.' and exit;
|
||||
open my $BFPERL, '<', "$bin{bld}/perl" or say 'Cannot start: Broken build.' and exit;
|
||||
my @BFPERL = <$BFPERL>;
|
||||
close $BFPERL or say 'Cannot start: Broken build.' and exit;
|
||||
if ($BFPERL[0] ne $]."\n") {
|
||||
@@ -79,7 +116,7 @@ if ($BFPERL[0] ne $]."\n") {
|
||||
undef @BFPERL;
|
||||
|
||||
# Check build Auto version.
|
||||
open my $BFVER, '<', "$Bin/../build/ver" or say 'Cannot start: Broken build.' and exit;
|
||||
open my $BFVER, '<', "$bin{bld}/ver" or say 'Cannot start: Broken build.' and exit;
|
||||
my @BFVER = <$BFVER>;
|
||||
close $BFVER or say 'Cannot start: Broken build.' and exit;
|
||||
if ($BFVER[0] ne VER.q{.}.SVER.q{.}.REV.RSTAGE."\n") {
|
||||
@@ -87,6 +124,14 @@ if ($BFVER[0] ne VER.q{.}.SVER.q{.}.REV.RSTAGE."\n") {
|
||||
}
|
||||
undef @BFVER;
|
||||
|
||||
# Check build path setup.
|
||||
our $SYSWIDE;
|
||||
open my $BFPATH, '<', "$bin{bld}/syswide" or say 'Cannot start: Broken build.' and exit;
|
||||
my @BFPATH = <$BFPATH>;
|
||||
close $BFPATH or say 'Cannot start: Broken build.' and exit;
|
||||
if ($BFPATH[0] eq "1\n") { $SYSWIDE = 1 }
|
||||
else { $SYSWIDE = 0 }
|
||||
|
||||
# Set signal handlers.
|
||||
local $SIG{TERM} = \&Lib::Auto::signal_term;
|
||||
local $SIG{INT} = \&Lib::Auto::signal_int;
|
||||
@@ -97,6 +142,59 @@ API::Std::event_add('on_sigterm');
|
||||
API::Std::event_add('on_sigint');
|
||||
API::Std::event_add('on_sighup');
|
||||
|
||||
# Get arguments.
|
||||
our ($DEBUG, $NUC);
|
||||
my ($opt_help, $opt_version, $USECONFIG);
|
||||
GetOptions(
|
||||
'nuc' => \$NUC,
|
||||
'config|c=s' => \$USECONFIG,
|
||||
'h|help' => \$opt_help,
|
||||
'debug|d' => \$DEBUG,
|
||||
'version|v' => \$opt_version,
|
||||
);
|
||||
|
||||
# If we were passed -h, print help.
|
||||
if ($opt_help) {
|
||||
print <<"HELP";
|
||||
|
||||
Usage: $PROGRAM_NAME [options]
|
||||
--help, -h Prints this help.
|
||||
--version, -v Prints the version of this Auto.
|
||||
--debug, -d Runs Auto in debug mode. Debug mode will print out debug
|
||||
messages, including IRC raw data, to screen. This will also
|
||||
stop Auto from forking into the background.
|
||||
|
||||
--config=FILENAME, -c Uses etc/FILENAME for the configuration file.
|
||||
|
||||
HELP
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# If we were passed -v, print version.
|
||||
if ($opt_version) {
|
||||
say q{};
|
||||
say NAME.' version '.VER.', subversion '.SVER.', revision '.REV.' ('.VER.q{.}.SVER.q{.}.REV.RSTAGE.').';
|
||||
print <<'VERINFO';
|
||||
|
||||
Copyright (C) 2010-2011, Xelhua Development Group. All rights reserved.
|
||||
|
||||
Auto is released under the licensing terms of the New (3-Clause) BSD License,
|
||||
which may be found in doc/LICENSE.
|
||||
|
||||
For documentation, you might refer to README, doc/*, and the Xelhua Wiki at
|
||||
http://wiki.xelhua.org. Documentation for modules is stored in Man Page and
|
||||
HTML form in autodoc/.
|
||||
|
||||
For support, visit the Xelhua Forums at http://forums.xelhua.org, or drop by
|
||||
the official IRC chatroom at irc.xelhua.org #xelhua. Please report bugs and
|
||||
request new features at http://rm.xelhua.org.
|
||||
|
||||
VERINFO
|
||||
exit 1;
|
||||
}
|
||||
|
||||
undef $opt_help;
|
||||
undef $opt_version;
|
||||
|
||||
# Print startup message.
|
||||
say <<'EOF';
|
||||
@@ -111,31 +209,23 @@ say '* '.NAME.' (version '.VER.q{.}.SVER.q{.}.REV.RSTAGE.') is starting up...';
|
||||
|
||||
our ($APID, %TIMERS);
|
||||
|
||||
# Get arguments.
|
||||
our $DEBUG = 0;
|
||||
our $NUC = 0;
|
||||
if (defined $ARGV[0]) {
|
||||
foreach (@ARGV) {
|
||||
given ($_) {
|
||||
when ('-d') { $DEBUG = 1; }
|
||||
when ('-nuc') { $NUC = 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check for updates.
|
||||
Lib::Auto::checkver();
|
||||
|
||||
# Include IPv6 if Auto was built for it.
|
||||
if ($ENFEAT =~ /ipv6/) { require IO::Socket::INET6; }
|
||||
if ($ENFEAT =~ /ipv6/) { require IO::Socket::INET6 }
|
||||
# Include SSL if Auto was built for it.
|
||||
if ($ENFEAT =~ /ssl/) { require IO::Socket::SSL; }
|
||||
if ($ENFEAT =~ /ssl/) { require IO::Socket::SSL }
|
||||
|
||||
# Parse configuration file.
|
||||
say '* Parsing configuration file auto.conf...';
|
||||
our $CONF = Parser::Config->new('auto.conf') or err(1, 'Failed to parse configuration file!', 1);
|
||||
my $configfile = 'auto.conf';
|
||||
if ($USECONFIG) { $configfile = $USECONFIG }
|
||||
say "* Parsing configuration file $configfile...";
|
||||
our $CONF = Parser::Config->new($configfile) or err(1, 'Failed to parse configuration file!', 1);
|
||||
our %SETTINGS = $CONF->parse or err(1, 'Failed to parse configuration file!', 1);
|
||||
say ' Success';
|
||||
undef $configfile;
|
||||
undef $USECONFIG;
|
||||
|
||||
if (conf_get('die')) {
|
||||
if ((conf_get('die'))[0][0] == 1) {
|
||||
@@ -174,26 +264,26 @@ our $DB;
|
||||
given (lc((conf_get('database:format'))[0][0])) {
|
||||
when ('sqlite') {
|
||||
# SQLite.
|
||||
if ($ENFEAT !~ /sqlite/) { err(2, 'Auto not built with SQLite support. Aborting.', 1); }
|
||||
if (!conf_get('database:filename')) { err(2, 'Missing required configuration value database:filename. Aborting.', 1); }
|
||||
if ($ENFEAT !~ /sqlite/) { err(2, 'Auto not built with SQLite support. Aborting.', 1) }
|
||||
if (!conf_get('database:filename')) { err(2, 'Missing required configuration value database:filename. Aborting.', 1) }
|
||||
|
||||
# Import DBD::SQLite.
|
||||
require DBD::SQLite;
|
||||
|
||||
if (!-e "$Bin/../etc/".(conf_get('database:filename'))[0][0]) {
|
||||
if (!-e "$bin{etc}/".(conf_get('database:filename'))[0][0]) {
|
||||
# Create <database:filename> if it's missing.
|
||||
open my $dbfh, '>', "$Bin/../etc/".(conf_get('database:filename'))[0][0];
|
||||
open my $dbfh, '>', "$bin{etc}/".(conf_get('database:filename'))[0][0];
|
||||
close $dbfh;
|
||||
chmod 0755, "$Bin/../etc/".(conf_get('database:filename'))[0][0];
|
||||
chmod 0755, "$bin{etc}/".(conf_get('database:filename'))[0][0];
|
||||
}
|
||||
# Connect to database.
|
||||
$DB = DBI->connect("dbi:SQLite:dbname=$Bin/../etc/".(conf_get('database:filename'))[0][0]) or err(2, 'Failed to connect to database!', 1);
|
||||
$DB = DBI->connect("dbi:SQLite:dbname=$bin{etc}/".(conf_get('database:filename'))[0][0]) or err(2, 'Failed to connect to database!', 1);
|
||||
}
|
||||
when ('mysql') {
|
||||
# MySQL.
|
||||
if ($ENFEAT !~ /mysql/) { err(2, 'Auto not built with MySQL support. Aborting.', 1); }
|
||||
if ($ENFEAT !~ /mysql/) { err(2, 'Auto not built with MySQL support. Aborting.', 1) }
|
||||
my @reqcval = qw(database:host database:name database:username database:password);
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1); } }
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1) } }
|
||||
undef @reqcval;
|
||||
|
||||
# Import DBD::mysql.
|
||||
@@ -211,23 +301,11 @@ given (lc((conf_get('database:format'))[0][0])) {
|
||||
(conf_get('database:username'))[0][0], (conf_get('database:password'))[0][0]) or err(2, 'Failed to connect to database!', 1);;
|
||||
}
|
||||
}
|
||||
# CSV no work. :(
|
||||
#when ('csv') {
|
||||
# # CSV.
|
||||
# if ($ENFEAT !~ /csv/) { err(2, 'Auto not built with CSV support.', 1); }
|
||||
# if (!conf_get('database:dir')) { err(2, 'Missing required configuration value database:dir. Aborting.', 1); }
|
||||
#
|
||||
# # Import DBD::CSV.
|
||||
# require DBD::CSV;
|
||||
#
|
||||
# # Connect to database.
|
||||
# $DB = DBI->connect("dbi:CSV:f_dir=$Bin/../etc/".(conf_get('database:dir'))[0][0]) or err(2, 'Failed to connect to database!', 1);
|
||||
#}
|
||||
when ('pgsql') {
|
||||
# PostgreSQL.
|
||||
if ($ENFEAT !~ /pgsql/) { err(2, 'Auto not built with PostgreSQL support. Aborting.', 1); }
|
||||
if ($ENFEAT !~ /pgsql/) { err(2, 'Auto not built with PostgreSQL support. Aborting.', 1) }
|
||||
my @reqcval = qw(database:name database:host database:username database:password);
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1); } }
|
||||
foreach (@reqcval) { if (!conf_get($_)) { err(2, "Missing required configuration value $_. Aborting.", 1) } }
|
||||
undef @reqcval;
|
||||
|
||||
# Import DBD::Pg.
|
||||
@@ -246,7 +324,7 @@ given (lc((conf_get('database:format'))[0][0])) {
|
||||
}
|
||||
}
|
||||
# Unknown database format.
|
||||
default { err(2, 'Unknown database format \''.lc((conf_get('database:format'))[0][0]).'\'. Aborting.', 1); }
|
||||
default { err(2, 'Unknown database format \''.lc((conf_get('database:format'))[0][0]).'\'. Aborting.', 1) }
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +402,11 @@ if (!$DEBUG) {
|
||||
$APID = fork;
|
||||
if ($APID != 0) {
|
||||
alog '* Successfully forked into the background. Process ID: '.$APID;
|
||||
open my $FPID, '>', "$Bin/auto.pid" or exit;
|
||||
# Figure out where to throw auto.pid.
|
||||
my $pidfile;
|
||||
if ($UPREFIX) { $pidfile = "$bin{cwd}/auto.pid" }
|
||||
else { $pidfile = "$Bin/auto.pid" }
|
||||
open my $FPID, '>', $pidfile or exit;
|
||||
print {$FPID} "$APID\n" or exit;
|
||||
close $FPID or exit;
|
||||
exit;
|
||||
@@ -384,11 +466,22 @@ API::Std::cmd_add('SHUTDOWN', 2, 'cmd.shutdown', \%Core::Cmd::HELP_SHUTDOWN, \&C
|
||||
API::Std::cmd_add('RESTART', 2, 'cmd.restart', \%Core::Cmd::HELP_RESTART, \&Core::Cmd::cmd_restart);
|
||||
API::Std::cmd_add('REHASH', 2, 'cmd.rehash', \%Core::Cmd::HELP_REHASH, \&Core::Cmd::cmd_rehash);
|
||||
API::Std::cmd_add('HELP', 2, 0, \%Core::Cmd::HELP_HELP, \&Core::Cmd::cmd_help);
|
||||
# Aliases, if any.
|
||||
if (conf_get('aliases:alias')) {
|
||||
my $aliases = (conf_get('aliases:alias'))[0];
|
||||
foreach (@{$aliases}) {
|
||||
if ($_ =~ m/\s/xsm) {
|
||||
my @data = split /\s/xsm, $_;
|
||||
API::Std::cmd_alias($data[0], join ' ', @data[1..$#data]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Infinite while loop.
|
||||
while (1) {
|
||||
# Timer check.
|
||||
foreach my $tk (keys %TIMERS) {
|
||||
if (exists $TIMERS{$tk}) {
|
||||
if ($TIMERS{$tk}{time} <= time) {
|
||||
&{ $TIMERS{$tk}{sub} }();
|
||||
if ($TIMERS{$tk}{type} == 1) {
|
||||
@@ -405,12 +498,13 @@ while (1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# Socket check.
|
||||
foreach my $sock ($SELECT->can_read(1)) {
|
||||
# Figure out what network is sending us data.
|
||||
my $sockid;
|
||||
foreach (keys %SOCKET) {
|
||||
if ($SOCKET{$_} eq $sock) { $sockid = $_; }
|
||||
if ($SOCKET{$_} eq $sock) { $sockid = $_ }
|
||||
}
|
||||
# Read the data.
|
||||
my $idata;
|
||||
@@ -422,6 +516,7 @@ while (1) {
|
||||
err(2, "Lost connection to $sockid!", 0);
|
||||
$SELECT->remove($sock);
|
||||
delete $SOCKET{$sockid};
|
||||
API::Std::event_run('on_disconnect', $sockid);
|
||||
if (!keys %SOCKET) {
|
||||
# No more connections, stop the program.
|
||||
API::Std::event_run('on_shutdown');
|
||||
@@ -458,12 +553,12 @@ sub socksnd {
|
||||
my ($svr, $data) = @_;
|
||||
|
||||
if (defined $SOCKET{$svr}) {
|
||||
syswrite $SOCKET{$svr}, $data."\r\n", POSIX::BUFSIZ, 0;
|
||||
syswrite $SOCKET{$svr}, "$data\r\n", POSIX::BUFSIZ, 0;
|
||||
dbug "$svr << $data";
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,12 +566,12 @@ sub socksnd {
|
||||
sub mod_load {
|
||||
my ($module) = @_;
|
||||
|
||||
if (-e "$Bin/../modules/$module.pm") {
|
||||
do "$Bin/../modules/$module.pm" and return 1;
|
||||
if (-e "$bin{mod}/$module.pm") {
|
||||
do "$bin{mod}/$module.pm" and return 1;
|
||||
}
|
||||
else {
|
||||
if (-e "$Bin/../modules/$module/main.pm") {
|
||||
do "$Bin/../modules/$module/main.pm" and return 1;
|
||||
if (-e "$bin{mod}/$module/main.pm") {
|
||||
do "$bin{mod}/$module/main.pm" and return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+55
-16
@@ -8,12 +8,45 @@ use strict;
|
||||
use warnings;
|
||||
use English qw(-no_match_vars);
|
||||
use FindBin qw($Bin);
|
||||
use Cwd;
|
||||
use Pod::Html;
|
||||
use Pod::Man;
|
||||
our $Bin = $Bin;
|
||||
|
||||
our $VERSION = 1.00;
|
||||
|
||||
my ($UPREFIX, %bin);
|
||||
$bin{cwd} = getcwd;
|
||||
if (!-e "$Bin/../build/syswide") {
|
||||
# Must be a custom PREFIX install.
|
||||
$bin{etc} = "$bin{cwd}/etc";
|
||||
$bin{var} = "$bin{cwd}/var";
|
||||
if (!-e "$Bin/lib/Lib/Auto.pm") {
|
||||
# Must be a system wide install.
|
||||
$bin{lib} = "$Bin/../lib/autobot/3.0.0";
|
||||
$bin{bld} = "$bin{lib}/build";
|
||||
$bin{lng} = "$bin{lib}/lang";
|
||||
$bin{mod} = "$bin{lib}/modules";
|
||||
}
|
||||
else {
|
||||
# Or not.
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
}
|
||||
$UPREFIX = 1;
|
||||
}
|
||||
else {
|
||||
# Must be a standard install.
|
||||
$bin{etc} = "$Bin/../etc";
|
||||
$bin{var} = "$Bin/../var";
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
$UPREFIX = 0;
|
||||
}
|
||||
|
||||
# Get module parameter.
|
||||
if (!defined $ARGV[0]) {
|
||||
say 'Not enough parameters. Usage: buildmod <module>';
|
||||
@@ -24,13 +57,13 @@ my $module = $ARGV[0];
|
||||
# Set full path.
|
||||
my $type = 0;
|
||||
my $modulep;
|
||||
if (-e "$Bin/../modules/$module.pm") {
|
||||
$modulep = "$Bin/../modules/$module.pm";
|
||||
if (-e "$bin{mod}/$module.pm") {
|
||||
$modulep = "$bin{mod}/$module.pm";
|
||||
$type = 1;
|
||||
}
|
||||
else {
|
||||
if (-e "$Bin/../modules/$module/Buildfile") {
|
||||
$modulep = "$Bin/../modules/$module/Buildfile";
|
||||
if (-e "$bin{mod}/$module/Buildfile") {
|
||||
$modulep = "$bin{mod}/$module/Buildfile";
|
||||
$type = 2;
|
||||
}
|
||||
else {
|
||||
@@ -95,17 +128,17 @@ foreach (@pars) {
|
||||
foreach my $cpanmod (@vals) {
|
||||
$res = eval('require '.$cpanmod.'; 1;');
|
||||
say ' '.$cpanmod.': '.(($res) ? 'Found' : 'Not Found');
|
||||
if (!$res) { $die = 1; }
|
||||
if (!$res) { $die = 1 }
|
||||
}
|
||||
print $RS;
|
||||
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit; }
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit }
|
||||
}
|
||||
when ('perl') {
|
||||
print 'Checking Perl version..... '.$PERL_VERSION.' - ';
|
||||
if ($] < $val) { $die = 1; }
|
||||
if ($] < $val) { $die = 1 }
|
||||
say (($die) ? 'Not OK' : 'OK');
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit; }
|
||||
if ($die) { say 'Failed to build '.$module.'.'; exit }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,33 +152,39 @@ close $FMPH;
|
||||
say 'Generating documentation.....';
|
||||
my $podbuf;
|
||||
foreach my $line (@MPBUF) {
|
||||
if (!defined $line) { $line = ' '; }
|
||||
if (!defined $line) { $line = ' ' }
|
||||
$line =~ s/(\r|\n)//g;
|
||||
|
||||
if ($line eq '__END__') {
|
||||
$got_end = 1;
|
||||
}
|
||||
|
||||
if ($got_end and $line ne '__END__') {
|
||||
if ($got_end and $line ne '__END__' and $line !~ m/^# vim:/sm) {
|
||||
$podbuf .= $line."\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Create the autodoc/ dir if it doesn't exist.
|
||||
if (!-d "$Bin/../autodoc") {
|
||||
mkdir "$Bin/../autodoc";
|
||||
my $docdir;
|
||||
if ($UPREFIX) {
|
||||
$docdir = "$ENV{HOME}/autodoc";
|
||||
if (!-d "$ENV{HOME}/autodoc") { mkdir "$ENV{HOME}/autodoc" }
|
||||
}
|
||||
else {
|
||||
$docdir = "$Bin/../autodoc";
|
||||
if (!-d "$Bin/../autodoc") { mkdir "$Bin/../autodoc" }
|
||||
}
|
||||
|
||||
# Save to POD file in autodoc/
|
||||
open my $FMPNH, '>', "$Bin/../autodoc/$module.pod";
|
||||
open my $FMPNH, '>', "$docdir/$module.pod";
|
||||
print {$FMPNH} $podbuf;
|
||||
close $FMPNH;
|
||||
|
||||
# Create HTML.
|
||||
pod2html("--infile=$Bin/../autodoc/$module.pod", "--outfile=$Bin/../autodoc/$module.html");
|
||||
pod2html("--infile=$docdir/$module.pod", "--outfile=$docdir/$module.html");
|
||||
# Create *roff.
|
||||
my $manifier = Pod::Man->new();
|
||||
$manifier->parse_from_file("$Bin/../autodoc/$module.pod", "$Bin/../autodoc/$module.1");
|
||||
$manifier->parse_from_file("$docdir/$module.pod", "$docdir/$module.1");
|
||||
|
||||
print $RS;
|
||||
say 'Done.';
|
||||
|
||||
+40
-6
@@ -9,8 +9,42 @@ use 5.010_000;
|
||||
use strict;
|
||||
use warnings;
|
||||
use FindBin qw($Bin);
|
||||
use Cwd;
|
||||
our $VERSION = 1.00;
|
||||
my $bin = $Bin;
|
||||
my $Bin = $Bin;
|
||||
|
||||
my ($UPREFIX, %bin);
|
||||
$bin{cwd} = getcwd;
|
||||
if (!-e "$Bin/../build/syswide") {
|
||||
# Must be a custom PREFIX install.
|
||||
$bin{etc} = "$bin{cwd}/etc";
|
||||
$bin{var} = "$bin{cwd}/var";
|
||||
if (!-e "$Bin/lib/Lib/Auto.pm") {
|
||||
# Must be a system wide install.
|
||||
$bin{lib} = "$Bin/../lib/autobot/3.0.0";
|
||||
$bin{bld} = "$bin{lib}/build";
|
||||
$bin{lng} = "$bin{lib}/lang";
|
||||
$bin{mod} = "$bin{lib}/modules";
|
||||
}
|
||||
else {
|
||||
# Or not.
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
}
|
||||
$UPREFIX = 1;
|
||||
}
|
||||
else {
|
||||
# Must be a standard install.
|
||||
$bin{etc} = "$Bin/../etc";
|
||||
$bin{var} = "$Bin/../var";
|
||||
$bin{lib} = "$Bin/../lib";
|
||||
$bin{bld} = "$Bin/../build";
|
||||
$bin{lng} = "$Bin/../lang";
|
||||
$bin{mod} = "$Bin/../modules";
|
||||
$UPREFIX = 0;
|
||||
}
|
||||
|
||||
# Get the name of the network this cert is for.
|
||||
print 'Network Name: ';
|
||||
@@ -19,15 +53,15 @@ $net =~ s/(\r|\n)//gxsm;
|
||||
say q{};
|
||||
|
||||
# Make sure etc/certs/ exists.
|
||||
if (!-d "$bin/../etc") { mkdir "$bin/../etc", 0755; }
|
||||
if (!-d "$bin/../etc/certs") { mkdir "$bin/../etc/certs", 0755; }
|
||||
if (!-d "$bin{etc}") { mkdir "$bin{etc}", 0755 }
|
||||
if (!-d "$bin{etc}/certs") { mkdir "$bin{etc}/certs", 0755 }
|
||||
|
||||
# Generate key and cert.
|
||||
system 'openssl req -nodes -newkey rsa:2048 -keyout '.$bin.'/../etc/certs/'.$net.'.key -x509 -days 3650 -out '.$bin.'/../etc/certs/'.$net.'.cert';
|
||||
chmod 0400, "$bin/../etc/certs/$net.key";
|
||||
system "openssl req -nodes -newkey rsa:2048 -keyout $bin{etc}/certs/$net.key -x509 -days 3650 -out $bin{etc}/certs/$net.cert";
|
||||
chmod 0400, "$bin{etc}/certs/$net.key";
|
||||
|
||||
# Get the fingerprint.
|
||||
my $fpr = `openssl x509 -noout -fingerprint < $bin/../etc/certs/$net.cert`;
|
||||
my $fpr = `openssl x509 -noout -fingerprint < $bin{etc}/certs/$net.cert`;
|
||||
my $fp;
|
||||
while ($fpr =~ s/(.*\n)//) {
|
||||
my $line = $1;
|
||||
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env perl
|
||||
# bin/wizard - Wizard for creating local Auto configuration directories.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
use 5.010_000;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Cwd;
|
||||
use FindBin qw($Bin);
|
||||
use File::Copy;
|
||||
our $VERSION = 1.00;
|
||||
my $Bin = $Bin;
|
||||
|
||||
# Get current working directory.
|
||||
my $cwd = getcwd();
|
||||
|
||||
# One argument required.
|
||||
if (!defined $ARGV[0]) {
|
||||
say 'ERROR: Missing arguments.';
|
||||
say 'Usage: auto-wizard <directory>';
|
||||
exit;
|
||||
}
|
||||
|
||||
# Strip trailing slash.
|
||||
my $installdir = $ARGV[0];
|
||||
$installdir =~ s/\/$//xsm;
|
||||
|
||||
# Create missing directories.
|
||||
if (!-d "$cwd/$installdir") { mkdir "$cwd/$installdir" }
|
||||
if (!-d "$cwd/$installdir/etc") { mkdir "$cwd/$installdir/etc" }
|
||||
if (!-d "$cwd/$installdir/var") { mkdir "$cwd/$installdir/var" }
|
||||
|
||||
# Copy over example.conf.
|
||||
copy("$Bin/../lib/autobot/3.0.0/dist/example.conf", "$cwd/$installdir/etc/example.conf");
|
||||
chmod 0644, "$cwd/$installdir/etc/example.conf";
|
||||
|
||||
# Our work is done.
|
||||
print <<"MSG";
|
||||
Successfully installed to "$cwd/$installdir"!
|
||||
|
||||
I've also created an example.conf for you and left it in etc/, configure it and
|
||||
rename it to auto.conf or any name of your choice.
|
||||
|
||||
See the Xelhua Wiki at http://wiki.xelhua.org for complete documentation.
|
||||
|
||||
After that, change directory to "$cwd/$installdir" and run `$Bin/auto` (or if
|
||||
"$Bin" is in your PATH; just `auto`).
|
||||
|
||||
If you gave your config file a name other than auto.conf, pass -c=FILENAME to
|
||||
`auto`, like so, if your config is etc/foo.conf: $Bin/auto -c=foo.conf
|
||||
|
||||
Enjoy.
|
||||
MSG
|
||||
+111
@@ -3,7 +3,118 @@ Auto IRC Bot 3.0: Change Log
|
||||
|
||||
3.0 Indev
|
||||
===============================================================================
|
||||
* Werewolf 1.07: Various improvements.
|
||||
* Updated Core::IRC::Users to be more efficient.
|
||||
* Added a WerewolfAdmin module for administering the Werewolf IRC game.
|
||||
* Fixed significant state mismatched data bugs.
|
||||
* Added API::IRC::ison for checking if a user is on a channel.
|
||||
* Werewolf: Fixed a bug in harlot staying home.
|
||||
* Werewolf: Various bug fixes.
|
||||
* Werewolf 1.06: Fixed an annoyance and added traitor transformation.
|
||||
* Commands now work with prefixes even in PM.
|
||||
* Ping: Determines end by numeric 315 instead of a 3-second timer now.
|
||||
* Werewolf: Fixed a GUARD issue and made it possible to VISIT yourself.
|
||||
* Possibly fixed a rare fatal error.
|
||||
* Werewolf: Rewrote WAIT to be more decent.
|
||||
* Werewolf: Wounded villagers are now excluded from winning villager count.
|
||||
* Werewolf: Dynamic lynch and no victim messages.
|
||||
* Werewolf 1.05: Added WAIT command.
|
||||
* Werewolf: Improved STATS to be smart.
|
||||
* Werewolf 1.04: Added village drunks and fixed other issues.
|
||||
* Werewolf: Fixed various annoyances. Also raised chance of gun hitting.
|
||||
* Werewolf: Fixed a nasty lynch nick exploit.
|
||||
* Fixed an issue in HELP.
|
||||
* Added a Ping module.
|
||||
* Moved Werewolf back to stable.
|
||||
|
||||
3.0 Alpha 10
|
||||
===============================================================================
|
||||
* Werewolf moved to unstable/ for exclusion from alpha10.
|
||||
* Werewolf: Fixed a bug causing double lynches occasionally.
|
||||
* Werewolf: One bug fix and multiple bullets.
|
||||
* Werewolf: Fixed timeout bug.
|
||||
* Werewolf: Fixed various warnings.
|
||||
* Werewolf: Handful of bugs fixed, timeouts rewritten, wolf assignment
|
||||
rewritten. (see ROLES:Werewolf)
|
||||
* Werewolf: Fixed an annoyance in VOTES.
|
||||
* Werewolf: Fixed another round of bugs.
|
||||
* Werewolf: Fixed a grammatical error. Thanks TAD!
|
||||
* Werewolf: Fixed a bug that occasionally caused a person to get wolf
|
||||
twice in the same game.
|
||||
* Werewolf: Fixed a typo that broke the gun on occasion.
|
||||
* Fixed a minor retract bug in Werewolf.
|
||||
* Fixed two major bugs in Werewolf that messed up game play.
|
||||
* Fixed several bugs and changed around JOIN/START/BEGIN in Werewolf.
|
||||
* Fixed parsing of host masks with / in them. (if it was broken)
|
||||
* Werewolf: Fixed a leave before game begin bug.
|
||||
* Aliases now work in PM's to the bot too.
|
||||
* Added an epic, Werewolf module.
|
||||
* Made slog() saner.
|
||||
* Syntax for mod_init() changed. Package name is no longer required.
|
||||
* Added German translation to Greet help hash. - nridley
|
||||
* Added German translation to FML help hash. - nridley
|
||||
* Added German translation to Eval help hash. - nridley
|
||||
* Added German translation to EightBall help hash. - nridley
|
||||
* Added German translation to Dictionary help hash. - nridley
|
||||
* Added German translation to Calc help hash. - nridley
|
||||
* Added German translation to Bitly help hash. - nridley
|
||||
* Added German translation to AUR help hash. - nridley
|
||||
|
||||
3.0 Alpha 9
|
||||
===============================================================================
|
||||
* Bug fix: Fixed an exploit in QDB RAND.
|
||||
* UNO: Fixed a formatting issue in duration.
|
||||
|
||||
3.0 Alpha 8
|
||||
===============================================================================
|
||||
* Full support for custom PREFIX installs (including global installs) has
|
||||
been completed.
|
||||
* Added fastest/slowest game, most cards and most players records to UNO.
|
||||
* Fixed a bug in UNO that allowed users to join more than once.
|
||||
* Added optional uno:english option. See documentation for UNO.
|
||||
* UNO has a new config option, uno:msg, for setting what method the bot
|
||||
uses for private messages.
|
||||
* Added command aliasing.
|
||||
* Moved botinfo to State::IRC.
|
||||
* Added hook on_selfkick for when we are kicked from a channel.
|
||||
* Moved chanusers to State::IRC.
|
||||
* Created State::IRC.
|
||||
* UNO now keeps game duration and cards played count.
|
||||
* Added a LOLCAT module for translating English to LOLCAT.
|
||||
* EightBall module rewritten.
|
||||
* Fixed a bug in LinkTitle that caused multi-line <title>'s to display
|
||||
wrong.
|
||||
* Added `wizard`, for creating local Auto config directories.
|
||||
* Made Auto respond properly to PRIVMSGs received before connection.
|
||||
* Added an AUR module.
|
||||
* Fixed an exploit in QDB that allowed users to use services fantasy
|
||||
commands with the bot's account.
|
||||
* Heavily improved ./install.
|
||||
|
||||
3.0 Alpha 7
|
||||
===============================================================================
|
||||
* Fixed a bug in UNO where rehashing during a game caused a crash.
|
||||
* Proto::IRC::umodes renamed to Proto::IRC::botinfo{svr}{modes}.
|
||||
* Fixed a bug where incoming PART's from ourselves were not parsed.
|
||||
* Our usermodes are now tracked in Proto::IRC::umodes.
|
||||
* Added an Oper module.
|
||||
* Added events on_cmode and on_umode.
|
||||
* Added event on_myinfo for RPL_MYINFO (numeric 004).
|
||||
* Raw hooks now take hook names and support multiple hooks. This changes
|
||||
rchook_add and rchook_del.
|
||||
* Vim modelines must be at the bottom of files. Modules updated.
|
||||
* Renamed Lib::Users to Core::IRC::Users.
|
||||
* Added Lib::Users, for network-wide user tracking. This brings many new
|
||||
possibilities to modules, including an account system.
|
||||
* Added hook on_namesreply.
|
||||
* All data related to a network is now deleted on disconnect.
|
||||
* Added hook on_disconnect.
|
||||
* Added various options to bin/auto, including support for multiple config
|
||||
files. See bin/auto -h for details.
|
||||
* Changed on_nick, on_quit, on_part, and on_kick source hashrefs to include
|
||||
server, removing svr.
|
||||
* Bumped minimum API version to 3.0.0a7.
|
||||
* Fixed the arguments on_whoreply passes.
|
||||
|
||||
3.0 Alpha 6
|
||||
===============================================================================
|
||||
|
||||
@@ -9,6 +9,10 @@ Chazz "Alexandria" Wolcott <alyx@woomoo.org>
|
||||
|
||||
Matthew "Mab879" Burket <matthew@assignitapp.com>
|
||||
- Spanish translations
|
||||
Noah "nridley" Ridley <nridley44@gmail.com>
|
||||
- Various.
|
||||
Eitan "variable" Adler <lists@eitanadler.com>
|
||||
- Werewolf improvements.
|
||||
|
||||
-----------------------------------------------
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ Legend:
|
||||
|
||||
[ ] Cleanup
|
||||
[ ] Replace println with Perl 5.10's say.
|
||||
[ ] Fix inconsistencies in official modules
|
||||
|
||||
[X] Language
|
||||
[X] Create method of translation.
|
||||
@@ -18,6 +19,7 @@ Legend:
|
||||
[X] Add English strings
|
||||
[X] Add Spanish strings
|
||||
[X] Add French strings
|
||||
[ ] Add Spanish, French and German translations to all official command help hashes.
|
||||
|
||||
[!] API
|
||||
[X] Create basic modular functions
|
||||
@@ -41,18 +43,18 @@ Legend:
|
||||
|
||||
[!] Features
|
||||
[X] Weather module
|
||||
[!] Urban Dictionary module
|
||||
[ ] Urban Dictionary module
|
||||
[X] UNO module
|
||||
[ ] Google Search module
|
||||
[ ] IRC Relay module
|
||||
[ ] (Google?) News module
|
||||
[X] QDB module
|
||||
[ ] Tumblr module
|
||||
[!] Tumblr module
|
||||
[X] Google Calculator module
|
||||
[ ] YouTube Search module
|
||||
[ ] Twitter module
|
||||
[X] Advanced Topics module
|
||||
[ ] Custom Triggers module
|
||||
[!] Custom Triggers module
|
||||
[X] Shorten URL (bit.ly?) module
|
||||
[?] Bot Talk module
|
||||
[O] Minecraft<->IRC module
|
||||
|
||||
@@ -86,6 +86,13 @@ user "#bot-ops" {
|
||||
privs "op";
|
||||
}
|
||||
|
||||
# Command aliases.
|
||||
# These can be used to alias a shortcut to a longer command.
|
||||
# Like so: alias "PL UNO PLAY";
|
||||
aliases {
|
||||
alias "RELOAD REHASH";
|
||||
}
|
||||
|
||||
# Database.
|
||||
database {
|
||||
# Format. This can be one of the following:
|
||||
|
||||
@@ -6,48 +6,77 @@
|
||||
package Install;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Long;
|
||||
use English qw(-no_match_vars);
|
||||
use FindBin qw($Bin);
|
||||
use File::Copy;
|
||||
use File::Path qw(make_path remove_tree);
|
||||
our $Bin = $Bin;
|
||||
BEGIN { unshift(@INC, "$Bin/lib"); }
|
||||
BEGIN { unshift(@INC, "$Bin/lib") }
|
||||
use Lib::Install;
|
||||
|
||||
# Installation script.
|
||||
our $VERSION = 1.00;
|
||||
our $ERROR = 0;
|
||||
|
||||
# Iterate through the arguments passed to us.
|
||||
my $features = 'base ssl sqlite';
|
||||
if (defined $ARGV[0]) {
|
||||
foreach (@ARGV) {
|
||||
if ($_ eq '-h' or $_ eq '--help') {
|
||||
println '*** ./install help ***';
|
||||
println ' --enable-sasl - Enable support for SASL.';
|
||||
println ' --enable-ipv6 - Enable support for IPv6.';
|
||||
println ' --disable-ssl - Disable support for SSL.';
|
||||
println '*** End of Help ***';
|
||||
# Store the arguments passed to us.
|
||||
my ($opt_help, $opt_syswide, $PREFIX, $feature_nossl, $feature_sasl, $feature_ipv6, $feature_mysql, $feature_pgsql);
|
||||
GetOptions(
|
||||
'--disable-ssl' => \$feature_nossl,
|
||||
'--enable-sasl' => \$feature_sasl,
|
||||
'--enable-ipv6' => \$feature_ipv6,
|
||||
'--with-mysql' => \$feature_mysql,
|
||||
'--with-pgsql' => \$feature_pgsql,
|
||||
'--prefix=s' => \$PREFIX,
|
||||
'--syswide' => \$opt_syswide,
|
||||
'--help' => \$opt_help,
|
||||
);
|
||||
|
||||
# If --help was passed.
|
||||
if ($opt_help) {
|
||||
print <<"HELP";
|
||||
|
||||
Auto IRC Bot Installation Wizard (v1.00).
|
||||
Usage: perl install [options]
|
||||
|
||||
Options:
|
||||
--disable-ssl Disables SSL support.
|
||||
--enable-sasl Enables SASL support.
|
||||
--enable-ipv6 Enables IPv6 support.
|
||||
--with-mysql Uses MySQL instead of SQLite.
|
||||
--with-pgsql Uses PostgreSQL instead of SQLite.
|
||||
--syswide Prefixes bin/ files with auto- (excluding `auto` itself), as
|
||||
well as installs build/ to lib/ instead. Always use this
|
||||
when installing to /usr.
|
||||
|
||||
--prefix=PREFIX Installs files to PREFIX
|
||||
[$Bin]
|
||||
|
||||
HELP
|
||||
exit 1;
|
||||
}
|
||||
elsif ($_ eq '--enable-sasl') {
|
||||
$features .= ' sasl';
|
||||
}
|
||||
elsif ($_ eq '--disable-ssl') {
|
||||
$features =~ s/ ssl//g;
|
||||
}
|
||||
elsif ($_ eq '--enable-ipv6') {
|
||||
$features .= ' ipv6';
|
||||
}
|
||||
elsif ($_ eq '--with-mysql') {
|
||||
$features =~ s/(sqlite|pgsql)/mysql/g;
|
||||
}
|
||||
elsif ($_ eq '--with-pgsql') {
|
||||
$features =~ s/(sqlite|mysql)/pgsql/g;
|
||||
}
|
||||
else {
|
||||
println "Warning: Unknown option '$_'";
|
||||
}
|
||||
}
|
||||
|
||||
# Set features.
|
||||
my $features = 'base';
|
||||
$features .= ' ssl' unless $feature_nossl;
|
||||
$features .= ' sasl' if $feature_sasl;
|
||||
$features .= ' ipv6' if $feature_ipv6;
|
||||
if ($feature_mysql) { $features .= ' mysql' }
|
||||
elsif ($feature_pgsql) { $features .= ' pgsql' }
|
||||
else { $features .= ' sqlite' }
|
||||
|
||||
# Where to install.
|
||||
my $upref;
|
||||
if (!$PREFIX) {
|
||||
$PREFIX = $Bin;
|
||||
$upref = 0;
|
||||
}
|
||||
else { $upref = 1 }
|
||||
|
||||
# Adjust installation to be more appropriate for system-wide installs.
|
||||
my $libbuild = 0;
|
||||
if ($opt_syswide) { $libbuild = 1 }
|
||||
|
||||
|
||||
# Check Perl version.
|
||||
println "Checking Perl version..... $^V";
|
||||
@@ -130,15 +159,63 @@ else {
|
||||
# Create build.
|
||||
println "\0";
|
||||
println "Building.....";
|
||||
if (!-d "$Bin/build") {
|
||||
mkdir "$Bin/build";
|
||||
if (!-d $PREFIX) { make_path($PREFIX) }
|
||||
my $libdir;
|
||||
if ($libbuild) { $libdir = "$PREFIX/lib/autobot/3.0.0" }
|
||||
else { $libdir = "$PREFIX/lib" }
|
||||
my $builddir;
|
||||
if ($libbuild) { $builddir = "$libdir/build" }
|
||||
else { $builddir = "$PREFIX/build" }
|
||||
if (!-d $builddir) { make_path($builddir) }
|
||||
build($features, $builddir, $opt_syswide);
|
||||
|
||||
# Install.
|
||||
if ($upref) {
|
||||
require File::Copy::Recursive;
|
||||
File::Copy::Recursive->import('rcopy');
|
||||
my $langdir;
|
||||
if ($libbuild) { $langdir = "$libdir/lang" }
|
||||
else { $langdir = "$PREFIX/lang" }
|
||||
my $moddir;
|
||||
if ($libbuild) { $moddir = "$libdir/modules" }
|
||||
else { $moddir = "$PREFIX/modules" }
|
||||
my $distdir;
|
||||
if ($libbuild) { $distdir = "$libdir/dist" }
|
||||
else { $distdir = "$PREFIX/dist" }
|
||||
println "Installing.....";
|
||||
if (!-d "$PREFIX/bin") { make_path("$PREFIX/bin") }
|
||||
if (!-d $libdir) { make_path($libdir) }
|
||||
if (!-d $langdir) { make_path($langdir) }
|
||||
if (!-d $moddir) { make_path($moddir) }
|
||||
if (!-d $distdir) { make_path($distdir) }
|
||||
|
||||
my $bgenssl = 'genssl';
|
||||
my $bbuildmod = 'buildmod';
|
||||
my $bwizard = 'wizard';
|
||||
if ($libbuild) {
|
||||
$bgenssl = "auto-$bgenssl";
|
||||
$bbuildmod = "auto-$bbuildmod";
|
||||
$bwizard = "auto-$bwizard";
|
||||
}
|
||||
copy("$Bin/bin/auto", "$PREFIX/bin/auto");
|
||||
copy("$Bin/bin/buildmod", "$PREFIX/bin/$bbuildmod");
|
||||
copy("$Bin/bin/genssl", "$PREFIX/bin/$bgenssl");
|
||||
copy("$Bin/bin/wizard", "$PREFIX/bin/$bwizard");
|
||||
chmod 0755, "$PREFIX/bin/auto", "$PREFIX/bin/$bgenssl", "$PREFIX/bin/$bbuildmod", "$PREFIX/bin/$bwizard";
|
||||
rcopy("$Bin/lib/*", "$libdir/");
|
||||
rcopy("$Bin/lang/*", "$langdir/");
|
||||
rcopy("$Bin/modules/*", "$moddir/");
|
||||
copy("$Bin/etc/example.conf", "$distdir/");
|
||||
remove_tree("$libdir/File");
|
||||
}
|
||||
|
||||
build($features);
|
||||
println 'Done.';
|
||||
|
||||
println q{};
|
||||
installmods();
|
||||
if ($libbuild) {
|
||||
println 'To install modules, run the auto-buildmod utility on a module.';
|
||||
}
|
||||
else { installmods($PREFIX) }
|
||||
println q{};
|
||||
|
||||
# Success!
|
||||
|
||||
+62
-54
@@ -6,29 +6,30 @@ use strict;
|
||||
use warnings;
|
||||
use feature qw(switch);
|
||||
use Exporter;
|
||||
use base qw(Exporter);
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(ban cjoin cpart cmode umode kick privmsg notice quit nick names
|
||||
topic who usrc match_mask);
|
||||
topic who whois usrc match_mask ison);
|
||||
|
||||
# Create the on_disconnect event.
|
||||
API::Std::event_add('on_disconnect');
|
||||
|
||||
# Set a ban, based on config bantype value.
|
||||
sub ban
|
||||
{
|
||||
sub ban {
|
||||
my ($svr, $chan, $type, $user) = @_;
|
||||
my $cbt = (API::Std::conf_get('bantype'))[0][0];
|
||||
|
||||
# Prepare the mask we're going to ban.
|
||||
my $mask;
|
||||
given ($cbt) {
|
||||
when (1) { $mask = '*!*@'.$user->{host}; }
|
||||
when (2) { $mask = $user->{nick}.'!*@*'; }
|
||||
when (3) { $mask = '*!'.$user->{user}.'@'.$user->{host}; }
|
||||
when (4) { $mask = $user->{nick}.'!*'.$user->{user}.'@'.$user->{host}; }
|
||||
when (1) { $mask = '*!*@'.$user->{host} }
|
||||
when (2) { $mask = $user->{nick}.'!*@*' }
|
||||
when (3) { $mask = q{*!}.$user->{user}.q{@}.$user->{host} }
|
||||
when (4) { $mask = $user->{nick}.q{!*}.$user->{user}.q{@}.$user->{host} }
|
||||
when (5) {
|
||||
my @hd = split m/[\.]/, $user->{host};
|
||||
shift @hd;
|
||||
$mask = '*!*@*.'.join ' ', @hd;
|
||||
$mask = '*!*@*.'.join q{ }, @hd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,18 +47,16 @@ sub ban
|
||||
}
|
||||
|
||||
# Join a channel.
|
||||
sub cjoin
|
||||
{
|
||||
sub cjoin {
|
||||
my ($svr, $chan, $key) = @_;
|
||||
|
||||
Auto::socksnd($svr, "JOIN ".((defined $key) ? "$chan $key" : "$chan"));
|
||||
Auto::socksnd($svr, 'JOIN '.((defined $key) ? "$chan $key" : $chan));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Part a channel.
|
||||
sub cpart
|
||||
{
|
||||
sub cpart {
|
||||
my ($svr, $chan, $reason) = @_;
|
||||
|
||||
if (defined $reason) {
|
||||
@@ -67,14 +66,11 @@ sub cpart
|
||||
Auto::socksnd($svr, "PART $chan :Leaving");
|
||||
}
|
||||
|
||||
if (defined $Proto::IRC::botchans{$svr}{$chan}) { delete $Proto::IRC::botchans{$svr}{$chan}; }
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Set mode(s) on a channel.
|
||||
sub cmode
|
||||
{
|
||||
sub cmode {
|
||||
my ($svr, $chan, $modes) = @_;
|
||||
|
||||
Auto::socksnd($svr, "MODE $chan $modes");
|
||||
@@ -83,22 +79,20 @@ sub cmode
|
||||
}
|
||||
|
||||
# Set mode(s) on us.
|
||||
sub umode
|
||||
{
|
||||
sub umode {
|
||||
my ($svr, $modes) = @_;
|
||||
|
||||
Auto::socksnd($svr, "MODE ".$Proto::IRC::botinfo{$svr}{nick}." $modes");
|
||||
Auto::socksnd($svr, 'MODE '.$State::IRC::botinfo{$svr}{nick}." $modes");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Send a PRIVMSG.
|
||||
sub privmsg
|
||||
{
|
||||
sub privmsg {
|
||||
my ($svr, $target, $message) = @_;
|
||||
|
||||
# Get maximum length.
|
||||
my $maxlen = 510 - length q{:}.$Proto::IRC::botinfo{$svr}{nick}.q{!}.$Proto::IRC::botinfo{$svr}{user}.q{@}.$Proto::IRC::botinfo{$svr}{mask}." PRIVMSG $target :";
|
||||
my $maxlen = 510 - length q{:}.$State::IRC::botinfo{$svr}{nick}.q{!}.$State::IRC::botinfo{$svr}{user}.q{@}.$State::IRC::botinfo{$svr}{mask}." PRIVMSG $target :";
|
||||
|
||||
# Divide message if it surpasses the maximum length.
|
||||
while (length $message >= $maxlen) {
|
||||
@@ -111,12 +105,11 @@ sub privmsg
|
||||
}
|
||||
|
||||
# Send a NOTICE.
|
||||
sub notice
|
||||
{
|
||||
sub notice {
|
||||
my ($svr, $target, $message) = @_;
|
||||
|
||||
# Get maximum length.
|
||||
my $maxlen = 510 - length q{:}.$Proto::IRC::botinfo{$svr}{nick}.q{!}.$Proto::IRC::botinfo{$svr}{user}.q{@}.$Proto::IRC::botinfo{$svr}{mask}." NOTICE $target :";
|
||||
my $maxlen = 510 - length q{:}.$State::IRC::botinfo{$svr}{nick}.q{!}.$State::IRC::botinfo{$svr}{user}.q{@}.$State::IRC::botinfo{$svr}{mask}." NOTICE $target :";
|
||||
|
||||
# Divide message if it surpasses the maximum length.
|
||||
while (length $message >= $maxlen) {
|
||||
@@ -129,8 +122,7 @@ sub notice
|
||||
}
|
||||
|
||||
# Send an ACTION PRIVMSG.
|
||||
sub act
|
||||
{
|
||||
sub act {
|
||||
my ($svr, $target, $message) = @_;
|
||||
|
||||
Auto::socksnd($svr, "PRIVMSG $target :\001ACTION $message\001");
|
||||
@@ -138,21 +130,31 @@ sub act
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Check if a given nickname is on a channel.
|
||||
sub ison {
|
||||
my ($svr, $chan, $nick) = @_;
|
||||
$chan = lc $chan;
|
||||
|
||||
if (!exists $State::IRC::chanusers{$svr}) { return }
|
||||
if (!exists $State::IRC::chanusers{$svr}{$chan}) { return }
|
||||
if (!exists $State::IRC::chanusers{$svr}{$chan}{lc $nick}) { return }
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Change bot nickname.
|
||||
sub nick
|
||||
{
|
||||
sub nick {
|
||||
my ($svr, $newnick) = @_;
|
||||
|
||||
Auto::socksnd($svr, "NICK $newnick");
|
||||
|
||||
$Proto::IRC::botinfo{$svr}{newnick} = $newnick;
|
||||
$State::IRC::botinfo{$svr}{newnick} = $newnick;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Request the users of a channel.
|
||||
sub names
|
||||
{
|
||||
sub names {
|
||||
my ($svr, $chan) = @_;
|
||||
|
||||
Auto::socksnd($svr, "NAMES $chan");
|
||||
@@ -161,8 +163,7 @@ sub names
|
||||
}
|
||||
|
||||
# Send a topic to the channel.
|
||||
sub topic
|
||||
{
|
||||
sub topic {
|
||||
my ($svr, $chan, $topic) = @_;
|
||||
|
||||
Auto::socksnd($svr, "TOPIC $chan :$topic");
|
||||
@@ -171,8 +172,7 @@ sub topic
|
||||
}
|
||||
|
||||
# Kick a user.
|
||||
sub kick
|
||||
{
|
||||
sub kick {
|
||||
my ($svr, $chan, $nick, $msg) = @_;
|
||||
|
||||
Auto::socksnd($svr, "KICK $chan $nick :".((defined $msg) ? $msg : 'No reason'));
|
||||
@@ -188,11 +188,11 @@ sub quit {
|
||||
Auto::socksnd($svr, "QUIT :$reason");
|
||||
}
|
||||
else {
|
||||
Auto::socksnd($svr, "QUIT :Leaving");
|
||||
Auto::socksnd($svr, 'QUIT :Leaving');
|
||||
}
|
||||
|
||||
delete $Proto::IRC::got_001{$svr} if (defined $Proto::IRC::got_001{$svr});
|
||||
delete $Proto::IRC::botinfo{$svr} if (defined $Proto::IRC::botinfo{$svr});
|
||||
# Trigger on_disconnect.
|
||||
API::Std::event_run('on_disconnect', $svr);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -206,13 +206,21 @@ sub who {
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Send a WHOIS.
|
||||
sub whois {
|
||||
my ($svr, $nick) = @_;
|
||||
|
||||
Auto::socksnd($svr, "WHOIS $nick");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Get nick, ident and host from a <nick>!<ident>@<host>
|
||||
sub usrc
|
||||
{
|
||||
sub usrc {
|
||||
my ($ex) = @_;
|
||||
|
||||
my @si = split('!', $ex);
|
||||
my @sii = split('@', $si[1]);
|
||||
my @si = split m/[!]/xsm, $ex;
|
||||
my @sii = split m/[@]/xsm, $si[1];
|
||||
|
||||
return (
|
||||
nick => $si[0],
|
||||
@@ -222,22 +230,22 @@ sub usrc
|
||||
}
|
||||
|
||||
# Match two IRC masks.
|
||||
sub match_mask
|
||||
{
|
||||
sub match_mask {
|
||||
my ($mu, $mh) = @_;
|
||||
|
||||
# Prepare the regex.
|
||||
$mh =~ s/\./\\\./g;
|
||||
$mh =~ s/\?/\./g;
|
||||
$mh =~ s/\*/\.\*/g;
|
||||
$mh = '^'.$mh.'$';
|
||||
$mh =~ s/\./\\\./gxsm;
|
||||
$mh =~ s/\?/\./gxsm;
|
||||
$mh =~ s/\*/\.\*/gxsm;
|
||||
$mh =~ s/\//\\\//gxsm;
|
||||
$mh = q{^}.$mh.q{$};
|
||||
|
||||
# Let's grep the user's mask.
|
||||
if (grep(/$mh/, $mu)) {
|
||||
# Let's match the user's mask.
|
||||
if ($mu =~ m/$mh/xsm) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-6
@@ -56,12 +56,12 @@ sub alog
|
||||
my $time = POSIX::strftime('%Y-%m-%d %I:%M:%S %p', localtime);
|
||||
|
||||
# Create var/ if it doesn't exist.
|
||||
if (!-d "$Auto::Bin/../var") {
|
||||
mkdir "$Auto::Bin/../var", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
|
||||
if (!-d "$Auto::bin{var}") {
|
||||
mkdir "$Auto::bin{var}", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
|
||||
}
|
||||
|
||||
# Open the logfile, print the log message to it and close it.
|
||||
open my $FLOG, '>>', "$Auto::Bin/../var/$date.log" or return;
|
||||
open my $FLOG, '>>', "$Auto::bin{var}/$date.log" or return;
|
||||
print {$FLOG} "[$time] $lmsg\n" or return;
|
||||
close $FLOG or return;
|
||||
|
||||
@@ -85,7 +85,7 @@ sub expire_logs
|
||||
}
|
||||
|
||||
# Iterate through each logfile.
|
||||
foreach my $file (glob fpfmt("$Auto::Bin/../var/*")) {
|
||||
foreach my $file (glob fpfmt("$Auto::bin{var}/*")) {
|
||||
my (undef, $file) = split 'bin/../var/', $file; ## no critic qw(BuiltinFunctions::ProhibitStringySplit)
|
||||
|
||||
# Convert filename to UNIX time.
|
||||
@@ -97,7 +97,7 @@ sub expire_logs
|
||||
|
||||
# If it's older than <config_value> days, delete it.
|
||||
if (time - $epoch > 86_400 * $celog) { ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
|
||||
unlink "$Auto::Bin/../var/$file";
|
||||
unlink "$Auto::bin{var}/$file";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +113,11 @@ sub slog
|
||||
if (conf_get('logchan')) {
|
||||
# It is, continue.
|
||||
|
||||
# Don't even bother with continuing if there are *NO* connections.
|
||||
if (!keys %Auto::SOCKET) { return }
|
||||
|
||||
# Split the network and channel.
|
||||
my ($net, $chan) = split '/', (conf_get('logchan'))[0][0];
|
||||
my ($net, $chan) = split m/[\/]/xsm, (conf_get('logchan'))[0][0];
|
||||
$chan = lc $chan;
|
||||
|
||||
# Check if we're connected to the network.
|
||||
|
||||
+75
-74
@@ -9,27 +9,27 @@ use Exporter;
|
||||
use base qw(Exporter);
|
||||
|
||||
|
||||
our (%LANGE, %MODULE, %EVENTS, %HOOKS, %CMDS);
|
||||
our (%LANGE, %MODULE, %EVENTS, %HOOKS, %CMDS, %ALIASES, %RAWHOOKS);
|
||||
our @EXPORT_OK = qw(conf_get trans err awarn timer_add timer_del cmd_add
|
||||
cmd_del hook_add hook_del rchook_add rchook_del match_user
|
||||
has_priv mod_exists ratelimit_check fpfmt);
|
||||
|
||||
|
||||
# Initialize a module.
|
||||
sub mod_init
|
||||
{
|
||||
my ($name, $author, $version, $autover, $pkg) = @_;
|
||||
sub mod_init {
|
||||
my ($name, $author, $version, $autover) = @_;
|
||||
my $pkg = caller 0;
|
||||
|
||||
# Log/debug.
|
||||
API::Log::dbug('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...');
|
||||
API::Log::alog('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...');
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...'); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to load '.$name.' (version '.$version.') by '.$author.'...') }
|
||||
|
||||
# Check if this module is compatible with this version of Auto.
|
||||
if ($autover !~ m/^3\.0\.0a(6)$/xsm) {
|
||||
if ($autover !~ m/^3\.0\.0a(7|8|9|10|11)$/xsm) {
|
||||
API::Log::dbug('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.');
|
||||
API::Log::alog('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.');
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.'); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.') }
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ sub mod_init
|
||||
|
||||
API::Log::dbug('MODULES: '.$name.' successfully loaded.');
|
||||
API::Log::alog('MODULES: '.$name.' successfully loaded.');
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: '.$name.' successfully loaded.'); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: '.$name.' successfully loaded.') }
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -53,37 +53,37 @@ sub mod_init
|
||||
# Otherwise, return a failed to load message.
|
||||
API::Log::dbug('MODULES: Failed to load '.$name.q{.});
|
||||
API::Log::alog('MODULES: Failed to load '.$name.q{.});
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.q{.}); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to load '.$name.q{.}) }
|
||||
# Just in case.
|
||||
Class::Unload->unload($pkg);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# Check if a module exists.
|
||||
sub mod_exists
|
||||
{
|
||||
sub mod_exists {
|
||||
my ($name) = @_;
|
||||
|
||||
if (defined $API::Std::MODULE{$name}) { return 1; }
|
||||
if (defined $API::Std::MODULE{$name}) { return 1 }
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# Void a module.
|
||||
sub mod_void
|
||||
{
|
||||
sub mod_void {
|
||||
my ($module) = @_;
|
||||
|
||||
# Log/debug.
|
||||
API::Log::dbug('MODULES: Attempting to unload module: '.$module.'...');
|
||||
API::Log::alog('MODULES: Attempting to unload module: '.$module.'...');
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to unload module: '.$module.'...'); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Attempting to unload module: '.$module.'...') }
|
||||
|
||||
# Check if this module exists.
|
||||
if (!defined $MODULE{$module}) {
|
||||
API::Log::dbug('MODULES: Failed to unload '.$module.'. No such module?');
|
||||
API::Log::alog('MODULES: Failed to unload '.$module.'. No such module?');
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.'. No such module?'); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.'. No such module?') }
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,26 +96,25 @@ sub mod_void
|
||||
delete $MODULE{$module};
|
||||
API::Log::dbug('MODULES: Successfully unloaded '.$module.q{.});
|
||||
API::Log::alog('MODULES: Successfully unloaded '.$module.q{.});
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Successfully unloaded '.$module.q{.}); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Successfully unloaded '.$module.q{.}) }
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
# Otherwise, return a failed to unload message.
|
||||
API::Log::dbug('MODULES: Failed to unload '.$module.q{.});
|
||||
API::Log::alog('MODULES: Failed to unload '.$module.q{.});
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.q{.}); }
|
||||
if (keys %Auto::SOCKET) { API::Log::slog('MODULES: Failed to unload '.$module.q{.}) }
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# Add a command to Auto.
|
||||
sub cmd_add
|
||||
{
|
||||
sub cmd_add {
|
||||
my ($cmd, $lvl, $priv, $help, $sub) = @_;
|
||||
$cmd = uc $cmd;
|
||||
|
||||
if (defined $API::Std::CMDS{$cmd}) { return; }
|
||||
if ($lvl =~ m/[^0-3]/sm) { return; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
if (defined $API::Std::CMDS{$cmd}) { return }
|
||||
if ($lvl =~ m/[^0-3]/sm) { return } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
|
||||
$API::Std::CMDS{$cmd}{lvl} = $lvl;
|
||||
$API::Std::CMDS{$cmd}{help} = $help;
|
||||
@@ -125,10 +124,22 @@ sub cmd_add
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Alias a command to another.
|
||||
sub cmd_alias {
|
||||
my ($alias, $cmd) = @_;
|
||||
|
||||
# Prepare data.
|
||||
$alias = uc $alias;
|
||||
$cmd = uc $cmd;
|
||||
|
||||
# Create alias.
|
||||
$ALIASES{$alias} = $cmd;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Delete a command from Auto.
|
||||
sub cmd_del
|
||||
{
|
||||
sub cmd_del {
|
||||
my ($cmd) = @_;
|
||||
$cmd = uc $cmd;
|
||||
|
||||
@@ -143,8 +154,7 @@ sub cmd_del
|
||||
}
|
||||
|
||||
# Add an event to Auto.
|
||||
sub event_add
|
||||
{
|
||||
sub event_add {
|
||||
my ($name) = @_;
|
||||
|
||||
if (!defined $EVENTS{lc $name}) {
|
||||
@@ -158,8 +168,7 @@ sub event_add
|
||||
}
|
||||
|
||||
# Delete an event from Auto.
|
||||
sub event_del
|
||||
{
|
||||
sub event_del {
|
||||
my ($name) = @_;
|
||||
|
||||
if (defined $EVENTS{lc $name}) {
|
||||
@@ -174,14 +183,13 @@ sub event_del
|
||||
}
|
||||
|
||||
# Trigger an event.
|
||||
sub event_run
|
||||
{
|
||||
sub event_run {
|
||||
my ($event, @args) = @_;
|
||||
|
||||
if (defined $EVENTS{lc $event} and defined $HOOKS{lc $event}) {
|
||||
foreach my $hk (keys %{ $HOOKS{lc $event} }) {
|
||||
my $ri = &{ $HOOKS{lc $event}{$hk} }(@args);
|
||||
if ($ri == -1) { last; }
|
||||
if ($ri == -1) { last }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,8 +197,7 @@ sub event_run
|
||||
}
|
||||
|
||||
# Add a hook to Auto.
|
||||
sub hook_add
|
||||
{
|
||||
sub hook_add {
|
||||
my ($event, $name, $sub) = @_;
|
||||
|
||||
if (!defined $API::Std::HOOKS{lc $name}) {
|
||||
@@ -208,8 +215,7 @@ sub hook_add
|
||||
}
|
||||
|
||||
# Delete a hook from Auto.
|
||||
sub hook_del
|
||||
{
|
||||
sub hook_del {
|
||||
my ($event, $name) = @_;
|
||||
|
||||
if (defined $API::Std::HOOKS{lc $event}{lc $name}) {
|
||||
@@ -222,8 +228,7 @@ sub hook_del
|
||||
}
|
||||
|
||||
# Add a timer to Auto.
|
||||
sub timer_add
|
||||
{
|
||||
sub timer_add {
|
||||
my ($name, $type, $time, $sub) = @_;
|
||||
$name = lc $name;
|
||||
|
||||
@@ -238,7 +243,7 @@ sub timer_add
|
||||
if (!defined $Auto::TIMERS{$name}) {
|
||||
$Auto::TIMERS{$name}{type} = $type;
|
||||
$Auto::TIMERS{$name}{time} = time + $time;
|
||||
if ($type == 2) { $Auto::TIMERS{$name}{secs} = $time; }
|
||||
if ($type == 2) { $Auto::TIMERS{$name}{secs} = $time }
|
||||
$Auto::TIMERS{$name}{sub} = $sub;
|
||||
return 1;
|
||||
}
|
||||
@@ -247,8 +252,7 @@ sub timer_add
|
||||
}
|
||||
|
||||
# Delete a timer from Auto.
|
||||
sub timer_del
|
||||
{
|
||||
sub timer_del {
|
||||
my ($name) = @_;
|
||||
$name = lc $name;
|
||||
|
||||
@@ -261,34 +265,37 @@ sub timer_del
|
||||
}
|
||||
|
||||
# Hook onto a raw command.
|
||||
sub rchook_add
|
||||
{
|
||||
my ($cmd, $sub) = @_;
|
||||
sub rchook_add {
|
||||
my ($cmd, $name, $sub) = @_;
|
||||
$cmd = uc $cmd;
|
||||
|
||||
if (defined $Proto::IRC::RAWC{$cmd}) { return; }
|
||||
# Make sure core doesn't already handle this.
|
||||
if (defined $Proto::IRC::RAWC{$cmd}) { return }
|
||||
# If the hook already exists, ignore it.
|
||||
if (defined $RAWHOOKS{$cmd}{$name}) { return }
|
||||
|
||||
$Proto::IRC::RAWC{$cmd} = $sub;
|
||||
# Create the hook.
|
||||
$RAWHOOKS{$cmd}{$name} = $sub;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Delete a raw command hook.
|
||||
sub rchook_del
|
||||
{
|
||||
my ($cmd) = @_;
|
||||
sub rchook_del {
|
||||
my ($cmd, $name) = @_;
|
||||
$cmd = uc $cmd;
|
||||
|
||||
if (!defined $Proto::IRC::RAWC{$cmd}) { return; }
|
||||
# Make sure the hook exists.
|
||||
if (!defined $RAWHOOKS{$cmd}{$name}) { return }
|
||||
|
||||
delete $Proto::IRC::RAWC{$cmd};
|
||||
# Delete it.
|
||||
delete $RAWHOOKS{$cmd}{$name};
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Configuration value getter.
|
||||
sub conf_get
|
||||
{
|
||||
sub conf_get {
|
||||
my ($value) = @_;
|
||||
|
||||
# Create an array out of the value.
|
||||
@@ -336,8 +343,7 @@ sub conf_get
|
||||
}
|
||||
|
||||
# Translation subroutine.
|
||||
sub trans
|
||||
{
|
||||
sub trans {
|
||||
my $id = shift;
|
||||
$id =~ s/ /_/gsm;
|
||||
|
||||
@@ -351,12 +357,11 @@ sub trans
|
||||
}
|
||||
|
||||
# Match user subroutine.
|
||||
sub match_user
|
||||
{
|
||||
sub match_user {
|
||||
my (%user) = @_;
|
||||
|
||||
# Get data from config.
|
||||
if (!conf_get('user')) { return; }
|
||||
if (!conf_get('user')) { return }
|
||||
my %uhp = conf_get('user');
|
||||
|
||||
foreach my $userkey (keys %uhp) {
|
||||
@@ -386,15 +391,15 @@ sub match_user
|
||||
my $svr = $ulhp{net}[0];
|
||||
if (defined $Auto::SOCKET{$svr}) {
|
||||
if ($ccnm eq 'CURRENT' and defined $user{chan}) {
|
||||
if (defined $Proto::IRC::chanusers{$svr}{$user{chan}}{$user{nick}}) {
|
||||
if ($Proto::IRC::chanusers{$svr}{$user{chan}}{$user{nick}} =~ m/($ccst)/sm) { return $userkey; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
if (defined $State::IRC::chanusers{$svr}{$user{chan}}{$user{nick}}) {
|
||||
if ($State::IRC::chanusers{$svr}{$user{chan}}{$user{nick}} =~ m/($ccst)/sm) { return $userkey } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach my $bcj (keys %{ $Proto::IRC::botchans{$svr} }) {
|
||||
if (API::IRC::match_mask($bcj, $ccnm)) {
|
||||
if (defined $Proto::IRC::chanusers{$svr}{$bcj}{$user{nick}}) {
|
||||
if ($Proto::IRC::chanusers{$svr}{$bcj}{$user{nick}} =~ m/($ccst)/sm) { return $userkey; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
if (defined $State::IRC::chanusers{$svr}{$bcj}{$user{nick}}) {
|
||||
if ($State::IRC::chanusers{$svr}{$bcj}{$user{nick}} =~ m/($ccst)/sm) { return $userkey } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,8 +413,7 @@ sub match_user
|
||||
}
|
||||
|
||||
# Privilege subroutine.
|
||||
sub has_priv
|
||||
{
|
||||
sub has_priv {
|
||||
my ($cuser, $cpriv) = @_;
|
||||
|
||||
if (conf_get("user:$cuser:privs")) {
|
||||
@@ -417,7 +421,7 @@ sub has_priv
|
||||
|
||||
if (defined $Auto::PRIVILEGES{$cups}) {
|
||||
foreach (@{ $Auto::PRIVILEGES{$cups} }) {
|
||||
if ($_ eq $cpriv or $_ eq 'ALL') { return 1; }
|
||||
if ($_ eq $cpriv or $_ eq 'ALL') { return 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -426,8 +430,7 @@ sub has_priv
|
||||
}
|
||||
|
||||
# Ratelimit check subroutine.
|
||||
sub ratelimit_check
|
||||
{
|
||||
sub ratelimit_check {
|
||||
my (%src) = @_;
|
||||
|
||||
# Check if ratelimit is set to on.
|
||||
@@ -445,9 +448,9 @@ sub ratelimit_check
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
# Increment their uses and return 0.
|
||||
# Increment their uses and return false.
|
||||
$Core::IRC::usercmd{$src{nick}.'@'.$src{host}.'/'.$src{svr}}++;
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -459,8 +462,7 @@ sub ratelimit_check
|
||||
}
|
||||
|
||||
# Error subroutine.
|
||||
sub err ## no critic qw(Subroutines::ProhibitBuiltinHomonyms)
|
||||
{
|
||||
sub err { ## no critic qw(Subroutines::ProhibitBuiltinHomonyms)
|
||||
my ($lvl, $msg, $fatal) = @_;
|
||||
|
||||
# Check for an invalid level.
|
||||
@@ -494,8 +496,7 @@ sub err ## no critic qw(Subroutines::ProhibitBuiltinHomonyms)
|
||||
}
|
||||
|
||||
# Warn subroutine.
|
||||
sub awarn
|
||||
{
|
||||
sub awarn {
|
||||
my ($lvl, $msg) = @_;
|
||||
|
||||
# Check for an invalid level.
|
||||
@@ -523,8 +524,8 @@ sub awarn
|
||||
sub fpfmt {
|
||||
my ($path) = @_;
|
||||
|
||||
if ($path =~ m/\s/xsm) { return "\"$path\""; }
|
||||
else { return $path; }
|
||||
if ($path =~ m/\s/xsm) { return "\"$path\"" }
|
||||
else { return $path }
|
||||
}
|
||||
|
||||
|
||||
|
||||
+18
-13
@@ -21,13 +21,13 @@ sub cmd_modload
|
||||
# Check for the needed parameters.
|
||||
if (!defined $argv[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if the module is already loaded.
|
||||
if (API::Std::mod_exists($argv[0])) {
|
||||
notice($src->{svr}, $src->{nick}, "Module \002".$argv[0]."\002 is already loaded.");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
# Go for it!
|
||||
@@ -41,7 +41,7 @@ sub cmd_modload
|
||||
else {
|
||||
# We weren't.
|
||||
notice($src->{svr}, $src->{nick}, "Module \002".$argv[0]."\002 failed to load.");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -59,13 +59,13 @@ sub cmd_modunload
|
||||
# Check for the needed parameters.
|
||||
if (!defined $argv[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if the module exists.
|
||||
if (!API::Std::mod_exists($argv[0])) {
|
||||
notice($src->{svr}, $src->{nick}, "Module \002".$argv[0]."\002 is not loaded.");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
# Go for it!
|
||||
@@ -79,7 +79,7 @@ sub cmd_modunload
|
||||
else {
|
||||
# We weren't.
|
||||
notice($src->{svr}, $src->{nick}, "Module \002".$argv[0]."\002 failed to unload.");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -97,13 +97,13 @@ sub cmd_modreload
|
||||
# Check for the needed parameters.
|
||||
if (!defined $argv[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if the module exists.
|
||||
if (!API::Std::mod_exists($argv[0])) {
|
||||
notice($src->{svr}, $src->{nick}, "Module \002".$argv[0]."\002 is not loaded.");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
# Go for it!
|
||||
@@ -119,7 +119,7 @@ sub cmd_modreload
|
||||
else {
|
||||
# We weren't.
|
||||
notice($src->{svr}, $src->{nick}, "Module \002".$argv[0]."\002 failed to reload.");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -265,9 +265,9 @@ sub cmd_help
|
||||
# Help for a specific command was requested. Lets get it.
|
||||
my $rcm = uc($argv[0]);
|
||||
|
||||
if (defined $API::Std::CMDS{$rcm}{help}) {
|
||||
# If there is help for this command.
|
||||
|
||||
if (exists $API::Std::CMDS{$rcm}) {
|
||||
if (exists $API::Std::CMDS{$rcm}{help}) {
|
||||
# Check for necessary privileges.
|
||||
if ($API::Std::CMDS{$rcm}{priv}) {
|
||||
if (!has_priv(match_user(%$src), $API::Std::CMDS{$rcm}{priv})) {
|
||||
@@ -282,13 +282,13 @@ sub cmd_help
|
||||
# Get the language.
|
||||
my ($lang, undef) = split('_', $Auto::LOCALE);
|
||||
|
||||
if (defined ${ $API::Std::CMDS{$rcm}{help} }{$lang}) {
|
||||
if (exists ${ $API::Std::CMDS{$rcm}{help} }{$lang}) {
|
||||
# If help for this command is available in the configured language.
|
||||
notice($src->{svr}, $src->{nick}, "Help for \002".$rcm."\002: ".${ $API::Std::CMDS{$rcm}{help} }{$lang});
|
||||
}
|
||||
else {
|
||||
# If it isn't, default to English.
|
||||
if (defined ${ $API::Std::CMDS{$rcm}{help} }{en}) {
|
||||
if (exists ${ $API::Std::CMDS{$rcm}{help} }{en}) {
|
||||
# If help for this command is available in English.
|
||||
notice($src->{svr}, $src->{nick}, "Help for \002".$rcm."\002: ".${ $API::Std::CMDS{$rcm}{help} }{en});
|
||||
}
|
||||
@@ -308,6 +308,11 @@ sub cmd_help
|
||||
notice($src->{svr}, $src->{nick}, "No help for \002".$rcm."\002 available.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
# If there is no help, don't give any.
|
||||
notice($src->{svr}, $src->{nick}, "No help for \002".$rcm."\002 available.");
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
+123
-14
@@ -26,14 +26,78 @@ hook_add("on_uprivmsg", "ctcp_version_reply", sub {
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Command alias parsing for channel messages.
|
||||
hook_add('on_cprivmsg', 'irc.commands.aliases', sub {
|
||||
my (($src, $chan, ($cmd, @args))) = @_;
|
||||
|
||||
# Check for valid length.
|
||||
if (length $cmd >= 2) {
|
||||
my $ipref = substr $cmd, 0, 1, q{};
|
||||
my $upref = (conf_get('fantasy_pf'))[0][0];
|
||||
# Check if the prefix is valid.
|
||||
if ($upref eq $ipref) {
|
||||
# It is, check for an alias.
|
||||
if (defined $API::Std::ALIASES{uc $cmd}) {
|
||||
# Get aliased command.
|
||||
my @actual;
|
||||
if ($API::Std::ALIASES{uc $cmd} =~ m/ /xsm) { @actual = split /\s/xsm, $API::Std::ALIASES{uc $cmd} }
|
||||
else { @actual = ($API::Std::ALIASES{uc $cmd}) }
|
||||
# Prepare data.
|
||||
my @msg = (
|
||||
q{:}.$src->{nick}.q{!}.$src->{user}.q{@}.$src->{host},
|
||||
'PRIVMSG',
|
||||
$chan,
|
||||
q{:}.$upref.$actual[0],
|
||||
);
|
||||
# Rest of the data.
|
||||
if (scalar @actual > 1) { for (1..$#actual) { push @msg, $actual[$_] } }
|
||||
if (defined $args[0]) { foreach (@args) { push @msg, $_ } }
|
||||
# Simulate a PRIVMSG.
|
||||
Proto::IRC::privmsg($src->{svr}, @msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Command alias parsing for private messages.
|
||||
hook_add('on_uprivmsg', 'irc.commands.aliases', sub {
|
||||
my (($src, ($cmd, @args))) = @_;
|
||||
my $cprefix = (conf_get('fantasy_pf'))[0][0];
|
||||
if (substr($cmd, 0, 1) eq $cprefix) { $cmd = substr $cmd, 1 }
|
||||
|
||||
# Check for an alias.
|
||||
if (defined $API::Std::ALIASES{uc $cmd}) {
|
||||
# Get aliased command.
|
||||
my @actual;
|
||||
if ($API::Std::ALIASES{uc $cmd} =~ m/ /xsm) { @actual = split /\s/xsm, $API::Std::ALIASES{uc $cmd} }
|
||||
else { @actual = ($API::Std::ALIASES{uc $cmd}) }
|
||||
# Prepare data.
|
||||
my @msg = (
|
||||
q{:}.$src->{nick}.q{!}.$src->{user}.q{@}.$src->{host},
|
||||
'PRIVMSG',
|
||||
$State::IRC::botinfo{$src->{svr}}{nick},
|
||||
q{:}.$actual[0],
|
||||
);
|
||||
# Rest of the data.
|
||||
if (scalar @actual > 1) { for (1..$#actual) { push @msg, $actual[$_] } }
|
||||
if (defined $args[0]) { foreach (@args) { push @msg, $_ } }
|
||||
# Simulate a PRIVMSG.
|
||||
Proto::IRC::privmsg($src->{svr}, @msg);
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# QUIT hook; delete user from chanusers.
|
||||
hook_add("on_quit", "quit_update_chanusers", sub {
|
||||
my (($svr, $src, undef)) = @_;
|
||||
my (($src, undef)) = @_;
|
||||
my %src = %{ $src };
|
||||
|
||||
# Delete the user from all channels.
|
||||
foreach my $ccu (keys %{ $Proto::IRC::chanusers{$svr} }) {
|
||||
if (defined $Proto::IRC::chanusers{$svr}{$ccu}{$src{nick}}) { delete $Proto::IRC::chanusers{$svr}{$ccu}{$src{nick}}; }
|
||||
foreach my $ccu (keys %{ $State::IRC::chanusers{$src{svr}}}) {
|
||||
if (defined $State::IRC::chanusers{$src{svr}}{$ccu}{lc $src{nick}}) { delete $State::IRC::chanusers{$src{svr}}{$ccu}{lc $src{nick}} }
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -55,7 +119,7 @@ hook_add("on_connect", "on_connect_modes", sub {
|
||||
hook_add('on_connect', 'on_connect_selfwho', sub {
|
||||
my ($svr) = @_;
|
||||
|
||||
API::IRC::who($svr, $Proto::IRC::botinfo{$svr}{nick});
|
||||
API::IRC::who($svr, $State::IRC::botinfo{$svr}{nick});
|
||||
|
||||
return 1;
|
||||
});
|
||||
@@ -125,13 +189,13 @@ hook_add("on_connect", "autojoin", sub {
|
||||
|
||||
# WHO reply.
|
||||
hook_add('on_whoreply', 'selfwho.getdata', sub {
|
||||
my (($svr, $nick, undef, $user, $mask, undef, undef, undef, undef, undef)) = @_;
|
||||
my (($svr, $nick, undef, $user, $mask, undef, undef, undef, undef)) = @_;
|
||||
|
||||
# Check if it's for us.
|
||||
if ($nick eq $Proto::IRC::botinfo{$svr}{nick}) {
|
||||
if ($nick eq $State::IRC::botinfo{$svr}{nick}) {
|
||||
# It is. Set data.
|
||||
$Proto::IRC::botinfo{$svr}{user} = $user;
|
||||
$Proto::IRC::botinfo{$svr}{mask} = $mask;
|
||||
$State::IRC::botinfo{$svr}{user} = $user;
|
||||
$State::IRC::botinfo{$svr}{mask} = $mask;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -158,21 +222,20 @@ hook_add('on_isupport', 'core.prefixchanmode.getdata', sub {
|
||||
# Found CHANMODES.
|
||||
my ($mtl, $mtp, $mtpp, $mts) = split m/[,]/xsm, substr($ex, 10);
|
||||
# List modes.
|
||||
foreach (split(//, $mtl)) { $Proto::IRC::chanmodes{$svr}{$_} = 1; }
|
||||
foreach (split(//, $mtl)) { $Proto::IRC::chanmodes{$svr}{$_} = 1 }
|
||||
# Modes with parameter.
|
||||
foreach (split(//, $mtp)) { $Proto::IRC::chanmodes{$svr}{$_} = 2; }
|
||||
foreach (split(//, $mtp)) { $Proto::IRC::chanmodes{$svr}{$_} = 2 }
|
||||
# Modes with parameter when +.
|
||||
foreach (split(//, $mtpp)) { $Proto::IRC::chanmodes{$svr}{$_} = 3; }
|
||||
foreach (split(//, $mtpp)) { $Proto::IRC::chanmodes{$svr}{$_} = 3 }
|
||||
# Modes without parameter.
|
||||
foreach (split(//, $mts)) { $Proto::IRC::chanmodes{$svr}{$_} = 4; }
|
||||
foreach (split(//, $mts)) { $Proto::IRC::chanmodes{$svr}{$_} = 4 }
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
sub clear_usercmd_timer
|
||||
{
|
||||
sub clear_usercmd_timer {
|
||||
# If ratelimit is set to 1 in config, add this timer.
|
||||
if ((conf_get('ratelimit'))[0][0] eq 1) {
|
||||
# Clear usercmd hash every X seconds.
|
||||
@@ -188,6 +251,52 @@ sub clear_usercmd_timer
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Server data deletion on disconnect.
|
||||
hook_add('on_disconnect', 'core.irc.deldata', sub {
|
||||
my ($svr) = @_;
|
||||
|
||||
# Delete all data related to the server.
|
||||
if (defined $Proto::IRC::got_001{$svr}) { delete $Proto::IRC::got_001{$svr} }
|
||||
if (defined $State::IRC::botinfo{$svr}) { delete $State::IRC::botinfo{$svr} }
|
||||
if (defined $Proto::IRC::botchans{$svr}) { delete $Proto::IRC::botchans{$svr} }
|
||||
if (defined $State::IRC::chanusers{$svr}) { delete $State::IRC::chanusers{$svr} }
|
||||
if (defined $Proto::IRC::csprefix{$svr}) { delete $Proto::IRC::csprefix{$svr} }
|
||||
if (defined $Proto::IRC::chanmodes{$svr}) { delete $Proto::IRC::chanmodes{$svr} }
|
||||
if (defined $Proto::IRC::cap{$svr}) { delete $Proto::IRC::cap{$svr} }
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Track our usermodes.
|
||||
hook_add('on_umode', 'core.irc.state.umode', sub {
|
||||
my (($svr, $modes)) = @_;
|
||||
|
||||
# Remove anything after a space.
|
||||
$modes =~ s/(\s.*)//xsm;
|
||||
|
||||
# Split the modes.
|
||||
my @modes = split //, $modes;
|
||||
|
||||
# Set operator to 1.
|
||||
my $op = 1;
|
||||
# Iterate through the modes.
|
||||
foreach (@modes) {
|
||||
if ($_ eq '-') { $op = 0 }
|
||||
elsif ($_ eq '+') { $op = 1 }
|
||||
else {
|
||||
# Adjust our modes.
|
||||
if ($op) {
|
||||
$State::IRC::botinfo{$svr}{modes} .= $_;
|
||||
}
|
||||
else {
|
||||
$State::IRC::botinfo{$svr}{modes} =~ s/($_)//xsm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
1;
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
@@ -0,0 +1,126 @@
|
||||
# lib/Core/IRC/Users.pm - IRC user tracking.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
package Core::IRC::Users;
|
||||
use strict;
|
||||
use warnings;
|
||||
use API::Std qw(hook_add);
|
||||
our %users;
|
||||
|
||||
# Initialize the ircusers_create and ircusers_delete events.
|
||||
API::Std::event_add('ircusers_create');
|
||||
API::Std::event_add('ircusers_delete');
|
||||
|
||||
# Create the on_rcjoin hook.
|
||||
hook_add('on_rcjoin', 'ircusers.onjoin', sub {
|
||||
my ($src, $chan) = @_;
|
||||
|
||||
# Add the user to the users hash, if not already defined.
|
||||
if (!$users{$src->{svr}}{lc $src->{nick}}) {
|
||||
$users{$src->{svr}}{lc $src->{nick}} = $src->{nick};
|
||||
API::Std::event_run('ircusers_create', ($src->{svr}, $src->{nick}));
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Create the on_namesreply hook.
|
||||
hook_add('on_namesreply', 'ircusers.names', sub {
|
||||
my ($svr, $chan, undef) = @_;
|
||||
|
||||
# WHO the channel.
|
||||
API::IRC::who($svr, $chan);
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Create the on_whoreply hook.
|
||||
hook_add('on_whoreply', 'ircusers.who', sub {
|
||||
my ($svr, $nick, undef) = @_;
|
||||
|
||||
# Ensure it is not us.
|
||||
if (lc $nick ne lc $State::IRC::botinfo{$svr}{nick}) {
|
||||
# It is not. Check if they're already in the users hash.
|
||||
if (!$users{$svr}{lc $nick}) {
|
||||
# They are not; add them.
|
||||
$users{$svr}{lc $nick} = $nick;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Create the on_nick hook.
|
||||
hook_add('on_nick', 'ircusers.onnick', sub {
|
||||
my ($src, $newnick) = @_;
|
||||
|
||||
# Modify the user's entry in the users hash.
|
||||
if ($users{$src->{svr}}{lc $src->{nick}}) {
|
||||
$users{$src->{svr}}{lc $newnick} = $newnick;
|
||||
delete $users{$src->{svr}}{lc $src->{nick}};
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Create the on_kick hook.
|
||||
hook_add('on_kick', 'ircusers.onkick', sub {
|
||||
my ($src, $kchan, $user, undef) = @_;
|
||||
|
||||
# Ensure there is a users hash entry for this user.
|
||||
if ($users{$src->{svr}}{lc $user}) {
|
||||
# Figure out if the user is in any other channel we're in.
|
||||
my $ri = 0;
|
||||
foreach my $chan (keys %{$State::IRC::chanusers{$src->{svr}}}) {
|
||||
if ($chan ne $kchan) {
|
||||
if (defined $State::IRC::chanusers{$src->{svr}}{$chan}{lc $user}) { $ri++; last }
|
||||
}
|
||||
}
|
||||
if (!$ri) {
|
||||
# They are not, delete them.
|
||||
delete $users{$src->{svr}}{lc $user};
|
||||
API::Std::event_run('ircusers_delete', ($src->{svr}, $user));
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Create the on_part hook.
|
||||
hook_add('on_part', 'ircusers.onpart', sub {
|
||||
my ($src, $pchan, undef) = @_;
|
||||
|
||||
# Ensure there is a users hash entry for this user.
|
||||
if ($users{$src->{svr}}{lc $src->{nick}}) {
|
||||
# Figure out if the user is in any other channel we're in.
|
||||
my $ri = 0;
|
||||
foreach my $chan (keys %{$State::IRC::chanusers{$src->{svr}}}) {
|
||||
if ($chan ne $pchan) {
|
||||
if (defined $State::IRC::chanusers{$src->{svr}}{$chan}{lc $src->{nick}}) { $ri++; last }
|
||||
}
|
||||
}
|
||||
if (!$ri) {
|
||||
# They are not, delete them.
|
||||
delete $users{$src->{svr}}{lc $src->{nick}};
|
||||
API::Std::event_run('ircusers_delete', ($src->{svr}, $src->{nick}));
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
# Create the on_quit hook.
|
||||
hook_add('on_quit', 'ircusers.onquit', sub {
|
||||
my ($src, undef) = @_;
|
||||
|
||||
# Delete the user's entry from the users hash.
|
||||
if ($users{$src->{svr}}{lc $src->{nick}}) {
|
||||
delete $users{$src->{svr}}{lc $src->{nick}};
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
|
||||
1;
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
@@ -0,0 +1,708 @@
|
||||
package File::Copy::Recursive;
|
||||
|
||||
use strict;
|
||||
BEGIN {
|
||||
# Keep older versions of Perl from trying to use lexical warnings
|
||||
$INC{'warnings.pm'} = "fake warnings entry for < 5.6 perl ($])" if $] < 5.006;
|
||||
}
|
||||
use warnings;
|
||||
|
||||
use Carp;
|
||||
use File::Copy;
|
||||
use File::Spec; #not really needed because File::Copy already gets it, but for good measure :)
|
||||
|
||||
use vars qw(
|
||||
@ISA @EXPORT_OK $VERSION $MaxDepth $KeepMode $CPRFComp $CopyLink
|
||||
$PFSCheck $RemvBase $NoFtlPth $ForcePth $CopyLoop $RMTrgFil $RMTrgDir
|
||||
$CondCopy $BdTrgWrn $SkipFlop $DirPerms
|
||||
);
|
||||
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT_OK = qw(fcopy rcopy dircopy fmove rmove dirmove pathmk pathrm pathempty pathrmdir);
|
||||
$VERSION = '0.38';
|
||||
|
||||
$MaxDepth = 0;
|
||||
$KeepMode = 1;
|
||||
$CPRFComp = 0;
|
||||
$CopyLink = eval { local $SIG{'__DIE__'};symlink '',''; 1 } || 0;
|
||||
$PFSCheck = 1;
|
||||
$RemvBase = 0;
|
||||
$NoFtlPth = 0;
|
||||
$ForcePth = 0;
|
||||
$CopyLoop = 0;
|
||||
$RMTrgFil = 0;
|
||||
$RMTrgDir = 0;
|
||||
$CondCopy = {};
|
||||
$BdTrgWrn = 0;
|
||||
$SkipFlop = 0;
|
||||
$DirPerms = 0777;
|
||||
|
||||
my $samecheck = sub {
|
||||
return 1 if $^O eq 'MSWin32'; # need better way to check for this on winders...
|
||||
return if @_ != 2 || !defined $_[0] || !defined $_[1];
|
||||
return if $_[0] eq $_[1];
|
||||
|
||||
my $one = '';
|
||||
if($PFSCheck) {
|
||||
$one = join( '-', ( stat $_[0] )[0,1] ) || '';
|
||||
my $two = join( '-', ( stat $_[1] )[0,1] ) || '';
|
||||
if ( $one eq $two && $one ) {
|
||||
carp "$_[0] and $_[1] are identical";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(-d $_[0] && !$CopyLoop) {
|
||||
$one = join( '-', ( stat $_[0] )[0,1] ) if !$one;
|
||||
my $abs = File::Spec->rel2abs($_[1]);
|
||||
my @pth = File::Spec->splitdir( $abs );
|
||||
while(@pth) {
|
||||
my $cur = File::Spec->catdir(@pth);
|
||||
last if !$cur; # probably not necessary, but nice to have just in case :)
|
||||
my $two = join( '-', ( stat $cur )[0,1] ) || '';
|
||||
if ( $one eq $two && $one ) {
|
||||
# $! = 62; # Too many levels of symbolic links
|
||||
carp "Caught Deep Recursion Condition: $_[0] contains $_[1]";
|
||||
return;
|
||||
}
|
||||
|
||||
pop @pth;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
my $glob = sub {
|
||||
my ($do, $src_glob, @args) = @_;
|
||||
|
||||
local $CPRFComp = 1;
|
||||
|
||||
my @rt;
|
||||
for my $path ( glob($src_glob) ) {
|
||||
my @call = [$do->($path, @args)] or return;
|
||||
push @rt, \@call;
|
||||
}
|
||||
|
||||
return @rt;
|
||||
};
|
||||
|
||||
my $move = sub {
|
||||
my $fl = shift;
|
||||
my @x;
|
||||
if($fl) {
|
||||
@x = fcopy(@_) or return;
|
||||
} else {
|
||||
@x = dircopy(@_) or return;
|
||||
}
|
||||
if(@x) {
|
||||
if($fl) {
|
||||
unlink $_[0] or return;
|
||||
} else {
|
||||
pathrmdir($_[0]) or return;
|
||||
}
|
||||
if($RemvBase) {
|
||||
my ($volm, $path) = File::Spec->splitpath($_[0]);
|
||||
pathrm(File::Spec->catpath($volm,$path,''), $ForcePth, $NoFtlPth) or return;
|
||||
}
|
||||
}
|
||||
return wantarray ? @x : $x[0];
|
||||
};
|
||||
|
||||
my $ok_todo_asper_condcopy = sub {
|
||||
my $org = shift;
|
||||
my $copy = 1;
|
||||
if(exists $CondCopy->{$org}) {
|
||||
if($CondCopy->{$org}{'md5'}) {
|
||||
|
||||
}
|
||||
if($copy) {
|
||||
|
||||
}
|
||||
}
|
||||
return $copy;
|
||||
};
|
||||
|
||||
sub fcopy {
|
||||
$samecheck->(@_) or return;
|
||||
if($RMTrgFil && (-d $_[1] || -e $_[1]) ) {
|
||||
my $trg = $_[1];
|
||||
if( -d $trg ) {
|
||||
my @trgx = File::Spec->splitpath( $_[0] );
|
||||
$trg = File::Spec->catfile( $_[1], $trgx[ $#trgx ] );
|
||||
}
|
||||
$samecheck->($_[0], $trg) or return;
|
||||
if(-e $trg) {
|
||||
if($RMTrgFil == 1) {
|
||||
unlink $trg or carp "\$RMTrgFil failed: $!";
|
||||
} else {
|
||||
unlink $trg or return;
|
||||
}
|
||||
}
|
||||
}
|
||||
my ($volm, $path) = File::Spec->splitpath($_[1]);
|
||||
if($path && !-d $path) {
|
||||
pathmk(File::Spec->catpath($volm,$path,''), $NoFtlPth);
|
||||
}
|
||||
if( -l $_[0] && $CopyLink ) {
|
||||
carp "Copying a symlink ($_[0]) whose target does not exist"
|
||||
if !-e readlink($_[0]) && $BdTrgWrn;
|
||||
symlink readlink(shift()), shift() or return;
|
||||
} else {
|
||||
copy(@_) or return;
|
||||
|
||||
my @base_file = File::Spec->splitpath($_[0]);
|
||||
my $mode_trg = -d $_[1] ? File::Spec->catfile($_[1], $base_file[ $#base_file ]) : $_[1];
|
||||
|
||||
chmod scalar((stat($_[0]))[2]), $mode_trg if $KeepMode;
|
||||
}
|
||||
return wantarray ? (1,0,0) : 1; # use 0's incase they do math on them and in case rcopy() is called in list context = no uninit val warnings
|
||||
}
|
||||
|
||||
sub rcopy {
|
||||
if (-l $_[0] && $CopyLink) {
|
||||
goto &fcopy;
|
||||
}
|
||||
|
||||
goto &dircopy if -d $_[0] || substr( $_[0], ( 1 * -1), 1) eq '*';
|
||||
goto &fcopy;
|
||||
}
|
||||
|
||||
sub rcopy_glob {
|
||||
$glob->(\&rcopy, @_);
|
||||
}
|
||||
|
||||
sub dircopy {
|
||||
if($RMTrgDir && -d $_[1]) {
|
||||
if($RMTrgDir == 1) {
|
||||
pathrmdir($_[1]) or carp "\$RMTrgDir failed: $!";
|
||||
} else {
|
||||
pathrmdir($_[1]) or return;
|
||||
}
|
||||
}
|
||||
my $globstar = 0;
|
||||
my $_zero = $_[0];
|
||||
my $_one = $_[1];
|
||||
if ( substr( $_zero, ( 1 * -1 ), 1 ) eq '*') {
|
||||
$globstar = 1;
|
||||
$_zero = substr( $_zero, 0, ( length( $_zero ) - 1 ) );
|
||||
}
|
||||
|
||||
$samecheck->( $_zero, $_[1] ) or return;
|
||||
if ( !-d $_zero || ( -e $_[1] && !-d $_[1] ) ) {
|
||||
$! = 20;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!-d $_[1]) {
|
||||
pathmk($_[1], $NoFtlPth) or return;
|
||||
} else {
|
||||
if($CPRFComp && !$globstar) {
|
||||
my @parts = File::Spec->splitdir($_zero);
|
||||
while($parts[ $#parts ] eq '') { pop @parts; }
|
||||
$_one = File::Spec->catdir($_[1], $parts[$#parts]);
|
||||
}
|
||||
}
|
||||
my $baseend = $_one;
|
||||
my $level = 0;
|
||||
my $filen = 0;
|
||||
my $dirn = 0;
|
||||
|
||||
my $recurs; #must be my()ed before sub {} since it calls itself
|
||||
$recurs = sub {
|
||||
my ($str,$end,$buf) = @_;
|
||||
$filen++ if $end eq $baseend;
|
||||
$dirn++ if $end eq $baseend;
|
||||
|
||||
$DirPerms = oct($DirPerms) if substr($DirPerms,0,1) eq '0';
|
||||
mkdir($end,$DirPerms) or return if !-d $end;
|
||||
chmod scalar((stat($str))[2]), $end if $KeepMode;
|
||||
if($MaxDepth && $MaxDepth =~ m/^\d+$/ && $level >= $MaxDepth) {
|
||||
return ($filen,$dirn,$level) if wantarray;
|
||||
return $filen;
|
||||
}
|
||||
$level++;
|
||||
|
||||
|
||||
my @files;
|
||||
if ( $] < 5.006 ) {
|
||||
opendir(STR_DH, $str) or return;
|
||||
@files = grep( $_ ne '.' && $_ ne '..', readdir(STR_DH));
|
||||
closedir STR_DH;
|
||||
}
|
||||
else {
|
||||
opendir(my $str_dh, $str) or return;
|
||||
@files = grep( $_ ne '.' && $_ ne '..', readdir($str_dh));
|
||||
closedir $str_dh;
|
||||
}
|
||||
|
||||
for my $file (@files) {
|
||||
my ($file_ut) = $file =~ m{ (.*) }xms;
|
||||
my $org = File::Spec->catfile($str, $file_ut);
|
||||
my $new = File::Spec->catfile($end, $file_ut);
|
||||
if( -l $org && $CopyLink ) {
|
||||
carp "Copying a symlink ($org) whose target does not exist"
|
||||
if !-e readlink($org) && $BdTrgWrn;
|
||||
symlink readlink($org), $new or return;
|
||||
}
|
||||
elsif(-d $org) {
|
||||
$recurs->($org,$new,$buf) if defined $buf;
|
||||
$recurs->($org,$new) if !defined $buf;
|
||||
$filen++;
|
||||
$dirn++;
|
||||
}
|
||||
else {
|
||||
if($ok_todo_asper_condcopy->($org)) {
|
||||
if($SkipFlop) {
|
||||
fcopy($org,$new,$buf) or next if defined $buf;
|
||||
fcopy($org,$new) or next if !defined $buf;
|
||||
}
|
||||
else {
|
||||
fcopy($org,$new,$buf) or return if defined $buf;
|
||||
fcopy($org,$new) or return if !defined $buf;
|
||||
}
|
||||
chmod scalar((stat($org))[2]), $new if $KeepMode;
|
||||
$filen++;
|
||||
}
|
||||
}
|
||||
}
|
||||
1;
|
||||
};
|
||||
|
||||
$recurs->($_zero, $_one, $_[2]) or return;
|
||||
return wantarray ? ($filen,$dirn,$level) : $filen;
|
||||
}
|
||||
|
||||
sub fmove { $move->(1, @_) }
|
||||
|
||||
sub rmove {
|
||||
if (-l $_[0] && $CopyLink) {
|
||||
goto &fmove;
|
||||
}
|
||||
|
||||
goto &dirmove if -d $_[0] || substr( $_[0], ( 1 * -1), 1) eq '*';
|
||||
goto &fmove;
|
||||
}
|
||||
|
||||
sub rmove_glob {
|
||||
$glob->(\&rmove, @_);
|
||||
}
|
||||
|
||||
sub dirmove { $move->(0, @_) }
|
||||
|
||||
sub pathmk {
|
||||
my @parts = File::Spec->splitdir( shift() );
|
||||
my $nofatal = shift;
|
||||
my $pth = $parts[0];
|
||||
my $zer = 0;
|
||||
if(!$pth) {
|
||||
$pth = File::Spec->catdir($parts[0],$parts[1]);
|
||||
$zer = 1;
|
||||
}
|
||||
for($zer..$#parts) {
|
||||
$DirPerms = oct($DirPerms) if substr($DirPerms,0,1) eq '0';
|
||||
mkdir($pth,$DirPerms) or return if !-d $pth && !$nofatal;
|
||||
mkdir($pth,$DirPerms) if !-d $pth && $nofatal;
|
||||
$pth = File::Spec->catdir($pth, $parts[$_ + 1]) unless $_ == $#parts;
|
||||
}
|
||||
1;
|
||||
}
|
||||
|
||||
sub pathempty {
|
||||
my $pth = shift;
|
||||
|
||||
return 2 if !-d $pth;
|
||||
|
||||
my @names;
|
||||
my $pth_dh;
|
||||
if ( $] < 5.006 ) {
|
||||
opendir(PTH_DH, $pth) or return;
|
||||
@names = grep !/^\.+$/, readdir(PTH_DH);
|
||||
}
|
||||
else {
|
||||
opendir($pth_dh, $pth) or return;
|
||||
@names = grep !/^\.+$/, readdir($pth_dh);
|
||||
}
|
||||
|
||||
for my $name (@names) {
|
||||
my ($name_ut) = $name =~ m{ (.*) }xms;
|
||||
my $flpth = File::Spec->catdir($pth, $name_ut);
|
||||
|
||||
if( -l $flpth ) {
|
||||
unlink $flpth or return;
|
||||
}
|
||||
elsif(-d $flpth) {
|
||||
pathrmdir($flpth) or return;
|
||||
}
|
||||
else {
|
||||
unlink $flpth or return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $] < 5.006 ) {
|
||||
closedir PTH_DH;
|
||||
}
|
||||
else {
|
||||
closedir $pth_dh;
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
|
||||
sub pathrm {
|
||||
my $path = shift;
|
||||
return 2 if !-d $path;
|
||||
my @pth = File::Spec->splitdir( $path );
|
||||
my $force = shift;
|
||||
|
||||
while(@pth) {
|
||||
my $cur = File::Spec->catdir(@pth);
|
||||
last if !$cur; # necessary ???
|
||||
if(!shift()) {
|
||||
pathempty($cur) or return if $force;
|
||||
rmdir $cur or return;
|
||||
}
|
||||
else {
|
||||
pathempty($cur) if $force;
|
||||
rmdir $cur;
|
||||
}
|
||||
pop @pth;
|
||||
}
|
||||
1;
|
||||
}
|
||||
|
||||
sub pathrmdir {
|
||||
my $dir = shift;
|
||||
if( -e $dir ) {
|
||||
return if !-d $dir;
|
||||
}
|
||||
else {
|
||||
return 2;
|
||||
}
|
||||
|
||||
pathempty($dir) or return;
|
||||
|
||||
rmdir $dir or return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
File::Copy::Recursive - Perl extension for recursively copying files and directories
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove);
|
||||
|
||||
fcopy($orig,$new[,$buf]) or die $!;
|
||||
rcopy($orig,$new[,$buf]) or die $!;
|
||||
dircopy($orig,$new[,$buf]) or die $!;
|
||||
|
||||
fmove($orig,$new[,$buf]) or die $!;
|
||||
rmove($orig,$new[,$buf]) or die $!;
|
||||
dirmove($orig,$new[,$buf]) or die $!;
|
||||
|
||||
rcopy_glob("orig/stuff-*", $trg [, $buf]) or die $!;
|
||||
rmove_glob("orig/stuff-*", $trg [,$buf]) or die $!;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module copies and moves directories recursively (or single files, well... singley) to an optional depth and attempts to preserve each file or directory's
|
||||
mode.
|
||||
|
||||
=head1 EXPORT
|
||||
|
||||
None by default. But you can export all the functions as in the example above and the path* functions if you wish.
|
||||
|
||||
=head2 fcopy()
|
||||
|
||||
This function uses File::Copy's copy() function to copy a file but not a directory. Any directories are recursively created if need be.
|
||||
One difference to File::Copy::copy() is that fcopy attempts to preserve the mode (see Preserving Mode below)
|
||||
The optional $buf in the synopsis if the same as File::Copy::copy()'s 3rd argument
|
||||
returns the same as File::Copy::copy() in scalar context and 1,0,0 in list context to accomidate rcopy()'s list context on regular files. (See below for more
|
||||
info)
|
||||
|
||||
=head2 dircopy()
|
||||
|
||||
This function recursively traverses the $orig directory's structure and recursively copies it to the $new directory.
|
||||
$new is created if necessary (multiple non existant directories is ok (IE foo/bar/baz). The script logically and portably creates all of them if necessary).
|
||||
It attempts to preserve the mode (see Preserving Mode below) and
|
||||
by default it copies all the way down into the directory, (see Managing Depth) below.
|
||||
If a directory is not specified it croaks just like fcopy croaks if its not a file that is specified.
|
||||
|
||||
returns true or false, for true in scalar context it returns the number of files and directories copied,
|
||||
In list context it returns the number of files and directories, number of directories only, depth level traversed.
|
||||
|
||||
my $num_of_files_and_dirs = dircopy($orig,$new);
|
||||
my($num_of_files_and_dirs,$num_of_dirs,$depth_traversed) = dircopy($orig,$new);
|
||||
|
||||
Normally it stops and return's if a copy fails, to continue on regardless set $File::Copy::Recursive::SkipFlop to true.
|
||||
|
||||
local $File::Copy::Recursive::SkipFlop = 1;
|
||||
|
||||
That way it will copy everythgingit can ina directory and won't stop because of permissions, etc...
|
||||
|
||||
=head2 rcopy()
|
||||
|
||||
This function will allow you to specify a file *or* directory. It calls fcopy() if its a file and dircopy() if its a directory.
|
||||
If you call rcopy() (or fcopy() for that matter) on a file in list context, the values will be 1,0,0 since no directories and no depth are used.
|
||||
This is important becasue if its a directory in list context and there is only the initial directory the return value is 1,1,1.
|
||||
|
||||
=head2 rcopy_glob()
|
||||
|
||||
This function lets you specify a pattern suitable for perl's glob() as the first argument. Subsequently each path returned by perl's glob() gets rcopy()ied.
|
||||
|
||||
It returns and array whose items are array refs that contain the return value of each rcopy() call.
|
||||
|
||||
It forces behavior as if $File::Copy::Recursive::CPRFComp is true.
|
||||
|
||||
=head2 fmove()
|
||||
|
||||
Copies the file then removes the original. You can manage the path the original file is in according to $RemvBase.
|
||||
|
||||
=head2 dirmove()
|
||||
|
||||
Uses dircopy() to copy the directory then removes the original. You can manage the path the original directory is in according to $RemvBase.
|
||||
|
||||
=head2 rmove()
|
||||
|
||||
Like rcopy() but calls fmove() or dirmove() instead.
|
||||
|
||||
=head2 rmove_glob()
|
||||
|
||||
Like rcopy_glob() but calls rmove() instead of rcopy()
|
||||
|
||||
=head3 $RemvBase
|
||||
|
||||
Default is false. When set to true the *move() functions will not only attempt to remove the original file or directory but will remove the given path it is in.
|
||||
|
||||
So if you:
|
||||
|
||||
rmove('foo/bar/baz', '/etc/');
|
||||
# "baz" is removed from foo/bar after it is successfully copied to /etc/
|
||||
|
||||
local $File::Copy::Recursive::Remvbase = 1;
|
||||
rmove('foo/bar/baz','/etc/');
|
||||
# if baz is successfully copied to /etc/ :
|
||||
# first "baz" is removed from foo/bar
|
||||
# then "foo/bar is removed via pathrm()
|
||||
|
||||
=head4 $ForcePth
|
||||
|
||||
Default is false. When set to true it calls pathempty() before any directories are removed to empty the directory so it can be rmdir()'ed when $RemvBase is in
|
||||
effect.
|
||||
|
||||
=head2 Creating and Removing Paths
|
||||
|
||||
=head3 $NoFtlPth
|
||||
|
||||
Default is false. If set to true rmdir(), mkdir(), and pathempty() calls in pathrm() and pathmk() do not return() on failure.
|
||||
|
||||
If its set to true they just silently go about their business regardless. This isn't a good idea but its there if you want it.
|
||||
|
||||
=head3 $DirPerms
|
||||
|
||||
Mode to pass to any mkdir() calls. Defaults to 0777 as per umask()'s POD. Explicitly having this allows older perls to be able to use FCR and might add a bit of
|
||||
flexibility for you.
|
||||
|
||||
Any value you set it to should be suitable for oct()
|
||||
|
||||
=head3 Path functions
|
||||
|
||||
These functions exist soley because they were necessary for the move and copy functions to have the features they do and not because they are of themselves the
|
||||
purpose of this module. That being said, here is how they work so you can understand how the copy and move funtions work and use them by themselves if you wish.
|
||||
|
||||
=head4 pathrm()
|
||||
|
||||
Removes a given path recursively. It removes the *entire* path so be carefull!!!
|
||||
|
||||
Returns 2 if the given path is not a directory.
|
||||
|
||||
File::Copy::Recursive::pathrm('foo/bar/baz') or die $!;
|
||||
# foo no longer exists
|
||||
|
||||
Same as:
|
||||
|
||||
rmdir 'foo/bar/baz' or die $!;
|
||||
rmdir 'foo/bar' or die $!;
|
||||
rmdir 'foo' or die $!;
|
||||
|
||||
An optional second argument makes it call pathempty() before any rmdir()'s when set to true.
|
||||
|
||||
File::Copy::Recursive::pathrm('foo/bar/baz', 1) or die $!;
|
||||
# foo no longer exists
|
||||
|
||||
Same as:PFSCheck
|
||||
|
||||
File::Copy::Recursive::pathempty('foo/bar/baz') or die $!;
|
||||
rmdir 'foo/bar/baz' or die $!;
|
||||
File::Copy::Recursive::pathempty('foo/bar/') or die $!;
|
||||
rmdir 'foo/bar' or die $!;
|
||||
File::Copy::Recursive::pathempty('foo/') or die $!;
|
||||
rmdir 'foo' or die $!;
|
||||
|
||||
An optional third argument acts like $File::Copy::Recursive::NoFtlPth, again probably not a good idea.
|
||||
|
||||
=head4 pathempty()
|
||||
|
||||
Recursively removes the given directory's contents so it is empty. returns 2 if argument is not a directory, 1 on successfully emptying the directory.
|
||||
|
||||
File::Copy::Recursive::pathempty($pth) or die $!;
|
||||
# $pth is now an empty directory
|
||||
|
||||
=head4 pathmk()
|
||||
|
||||
Creates a given path recursively. Creates foo/bar/baz even if foo does not exist.
|
||||
|
||||
File::Copy::Recursive::pathmk('foo/bar/baz') or die $!;
|
||||
|
||||
An optional second argument if true acts just like $File::Copy::Recursive::NoFtlPth, which means you'd never get your die() if something went wrong. Again,
|
||||
probably a *bad* idea.
|
||||
|
||||
=head4 pathrmdir()
|
||||
|
||||
Same as rmdir() but it calls pathempty() first to recursively empty it first since rmdir can not remove a directory with contents.
|
||||
Just removes the top directory the path given instead of the entire path like pathrm(). Return 2 if given argument does not exist (IE its already gone). Return
|
||||
false if it exists but is not a directory.
|
||||
|
||||
=head2 Preserving Mode
|
||||
|
||||
By default a quiet attempt is made to change the new file or directory to the mode of the old one.
|
||||
To turn this behavior off set
|
||||
$File::Copy::Recursive::KeepMode
|
||||
to false;
|
||||
|
||||
=head2 Managing Depth
|
||||
|
||||
You can set the maximum depth a directory structure is recursed by setting:
|
||||
$File::Copy::Recursive::MaxDepth
|
||||
to a whole number greater than 0.
|
||||
|
||||
=head2 SymLinks
|
||||
|
||||
If your system supports symlinks then symlinks will be copied as symlinks instead of as the target file.
|
||||
Perl's symlink() is used instead of File::Copy's copy()
|
||||
You can customize this behavior by setting $File::Copy::Recursive::CopyLink to a true or false value.
|
||||
It is already set to true or false dending on your system's support of symlinks so you can check it with an if statement to see how it will behave:
|
||||
|
||||
if($File::Copy::Recursive::CopyLink) {
|
||||
print "Symlinks will be preserved\n";
|
||||
} else {
|
||||
print "Symlinks will not be preserved because your system does not support it\n";
|
||||
}
|
||||
|
||||
If symlinks are being copied you can set $File::Copy::Recursive::BdTrgWrn to true to make it carp when it copies a link whose target does not exist. Its false
|
||||
by default.
|
||||
|
||||
local $File::Copy::Recursive::BdTrgWrn = 1;
|
||||
|
||||
=head2 Removing existing target file or directory before copying.
|
||||
|
||||
This can be done by setting $File::Copy::Recursive::RMTrgFil or $File::Copy::Recursive::RMTrgDir for file or directory behavior respectively.
|
||||
|
||||
0 = off (This is the default)
|
||||
|
||||
1 = carp() $! if removal fails
|
||||
|
||||
2 = return if removal fails
|
||||
|
||||
local $File::Copy::Recursive::RMTrgFil = 1;
|
||||
fcopy($orig, $target) or die $!;
|
||||
# if it fails it does warn() and keeps going
|
||||
|
||||
local $File::Copy::Recursive::RMTrgDir = 2;
|
||||
dircopy($orig, $target) or die $!;
|
||||
# if it fails it does your "or die"
|
||||
|
||||
This should be unnecessary most of the time but its there if you need it :)
|
||||
|
||||
=head2 Turning off stat() check
|
||||
|
||||
By default the files or directories are checked to see if they are the same (IE linked, or two paths (absolute/relative or different relative paths) to the same
|
||||
file) by comparing the file's stat() info.
|
||||
It's a very efficient check that croaks if they are and shouldn't be turned off but if you must for some weird reason just set $File::Copy::Recursive::PFSCheck
|
||||
to a false value. ("PFS" stands for "Physical File System")
|
||||
|
||||
=head2 Emulating cp -rf dir1/ dir2/
|
||||
|
||||
By default dircopy($dir1,$dir2) will put $dir1's contents right into $dir2 whether $dir2 exists or not.
|
||||
|
||||
You can make dircopy() emulate cp -rf by setting $File::Copy::Recursive::CPRFComp to true.
|
||||
|
||||
NOTE: This only emulates -f in the sense that it does not prompt. It does not remove the target file or directory if it exists.
|
||||
If you need to do that then use the variables $RMTrgFil and $RMTrgDir described in "Removing existing target file or directory before copying" above.
|
||||
|
||||
That means that if $dir2 exists it puts the contents into $dir2/$dir1 instead of $dir2 just like cp -rf.
|
||||
If $dir2 does not exist then the contents go into $dir2 like normal (also like cp -rf)
|
||||
|
||||
So assuming 'foo/file':
|
||||
|
||||
dircopy('foo', 'bar') or die $!;
|
||||
# if bar does not exist the result is bar/file
|
||||
# if bar does exist the result is bar/file
|
||||
|
||||
$File::Copy::Recursive::CPRFComp = 1;
|
||||
dircopy('foo', 'bar') or die $!;
|
||||
# if bar does not exist the result is bar/file
|
||||
# if bar does exist the result is bar/foo/file
|
||||
|
||||
You can also specify a star for cp -rf glob type behavior:
|
||||
|
||||
dircopy('foo/*', 'bar') or die $!;
|
||||
# if bar does not exist the result is bar/file
|
||||
# if bar does exist the result is bar/file
|
||||
|
||||
$File::Copy::Recursive::CPRFComp = 1;
|
||||
dircopy('foo/*', 'bar') or die $!;
|
||||
# if bar does not exist the result is bar/file
|
||||
# if bar does exist the result is bar/file
|
||||
|
||||
NOTE: The '*' is only like cp -rf foo/* and *DOES NOT EXPAND PARTIAL DIRECTORY NAMES LIKE YOUR SHELL DOES* (IE not like cp -rf fo* to copy foo/*)
|
||||
|
||||
=head2 Allowing Copy Loops
|
||||
|
||||
If you want to allow:
|
||||
|
||||
cp -rf . foo/
|
||||
|
||||
type behavior set $File::Copy::Recursive::CopyLoop to true.
|
||||
|
||||
This is false by default so that a check is done to see if the source directory will contain the target directory and croaks to avoid this problem.
|
||||
|
||||
If you ever find a situation where $CopyLoop = 1 is desirable let me know (IE its a bad bad idea but is there if you want it)
|
||||
|
||||
(Note: On Windows this was necessary since it uses stat() to detemine samedness and stat() is essencially useless for this on Windows.
|
||||
The test is now simply skipped on Windows but I'd rather have an actual reliable check if anyone in Microsoft land would care to share)
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<File::Copy> L<File::Spec>
|
||||
|
||||
=head1 TO DO
|
||||
|
||||
I am currently working on and reviewing some other modules to use in the new interface so we can lose the horrid globals as well as some other undesirable
|
||||
traits and also more easily make available some long standing requests.
|
||||
|
||||
Tests will be easier to do with the new interface and hence the testing focus will shift to the new interface and aim to be comprehensive.
|
||||
|
||||
The old interface will work, it just won't be brought in until it is used, so it will add no overhead for users of the new interface.
|
||||
|
||||
I'll add this after the latest verision has been out for a while with no new features or issues found :)
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Daniel Muey, L<http://drmuey.com/cpan_contact.pl>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright 2004 by Daniel Muey
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
||||
+18
-14
@@ -123,7 +123,7 @@ sub rehash
|
||||
if (conf_get('module')) {
|
||||
alog '* Loading modules...';
|
||||
foreach (@{ (conf_get('module'))[0] }) {
|
||||
if (!API::Std::mod_exists($_)) { Auto::mod_load($_); }
|
||||
if (!API::Std::mod_exists($_)) { Auto::mod_load($_) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,15 +166,15 @@ sub ircsock {
|
||||
# Set IPv6/SSL data.
|
||||
my $use6 = 0;
|
||||
my $usessl = 0;
|
||||
if (defined $cdata->{'ipv6'}[0]) { $use6 = $cdata->{'ipv6'}[0]; }
|
||||
if (defined $cdata->{'ssl'}[0]) { $usessl = $cdata->{'ssl'}[0]; }
|
||||
if (defined $cdata->{'ipv6'}[0]) { $use6 = $cdata->{'ipv6'}[0] }
|
||||
if (defined $cdata->{'ssl'}[0]) { $usessl = $cdata->{'ssl'}[0] }
|
||||
|
||||
# Check for appropriate build data.
|
||||
if ($usessl) {
|
||||
if ($Auto::ENFEAT !~ m/ssl/ixsm) { err(2, '** Auto not built with SSL support: Aborting connection to '.$svrname, 0); return; }
|
||||
if ($Auto::ENFEAT !~ m/ssl/ixsm) { err(2, '** Auto not built with SSL support: Aborting connection to '.$svrname, 0); return }
|
||||
}
|
||||
if ($use6) {
|
||||
if ($Auto::ENFEAT !~ m/ipv6/ixsm) { err(2, '** Auto not built with IPv6 support: Aborting connection to '.$svrname, 0); return; }
|
||||
if ($Auto::ENFEAT !~ m/ipv6/ixsm) { err(2, '** Auto not built with IPv6 support: Aborting connection to '.$svrname, 0); return }
|
||||
}
|
||||
|
||||
# CertFP.
|
||||
@@ -183,13 +183,13 @@ sub ircsock {
|
||||
if ($cdata->{'certfp'}[0] eq 1) {
|
||||
$conndata{'SSL_use_cert'} = 1;
|
||||
if (defined $cdata->{'certfp_cert'}[0]) {
|
||||
$conndata{'SSL_cert_file'} = "$Auto::Bin/../etc/certs/".$cdata->{'certfp_cert'}[0];
|
||||
$conndata{'SSL_cert_file'} = "$Auto::bin{etc}/certs/".$cdata->{'certfp_cert'}[0];
|
||||
}
|
||||
if (defined $cdata->{'certfp_key'}[0]) {
|
||||
$conndata{'SSL_key_file'} = "$Auto::Bin/../etc/certs/".$cdata->{'certfp_key'}[0];
|
||||
$conndata{'SSL_key_file'} = "$Auto::bin{etc}/certs/".$cdata->{'certfp_key'}[0];
|
||||
}
|
||||
if (defined $cdata->{'certfp_pass'}[0]) {
|
||||
$conndata{'SSL_passwd_cb'} = sub { return $cdata->{'certfp_pass'}[0]; };
|
||||
$conndata{'SSL_passwd_cb'} = sub { return $cdata->{'certfp_pass'}[0] };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,9 +211,12 @@ sub ircsock {
|
||||
$Auto::SOCKET{$svrname} = IO::Socket::INET->new(%conndata) or # Or error.
|
||||
err(2, 'Failed to connect to server ('.$ERRNO.'): '.$svrname.' ['.$cdata->{'host'}[0].q{:}.$cdata->{'port'}[0].']', 0)
|
||||
and delete $Auto::SOCKET{$svrname} and next;
|
||||
binmode($Auto::SOCKET{$svrname}, ':encoding(UTF-8)');
|
||||
}
|
||||
}
|
||||
|
||||
# Create a CAP entry if it doesn't already exist.
|
||||
if (!$Proto::IRC::cap{$svrname}) { $Proto::IRC::cap{$svrname} = 'multi-prefix' }
|
||||
# Send PASS if we have one.
|
||||
if (defined $cdata->{'pass'}[0]) {
|
||||
Auto::socksnd($svrname, 'PASS :'.$cdata->{'pass'}[0]) or return;
|
||||
@@ -236,8 +239,9 @@ sub ircsock {
|
||||
|
||||
# Shutdown.
|
||||
hook_add('on_shutdown', 'shutdown.core_cleanup', sub {
|
||||
if (defined $Auto::DB) { $Auto::DB->disconnect; }
|
||||
if (-e "$Auto::Bin/auto.pid") { unlink "$Auto::Bin/auto.pid"; }
|
||||
if (defined $Auto::DB) { $Auto::DB->disconnect }
|
||||
if ($Auto::UPREFIX) { if (-e "$Auto::bin{cwd}/auto.pid") { unlink "$Auto::bin{cwd}/auto.pid" } }
|
||||
else { if (-e "$Auto::Bin/auto.pid") { unlink "$Auto::Bin/auto.pid" } }
|
||||
return 1;
|
||||
});
|
||||
|
||||
@@ -250,7 +254,7 @@ sub signal_term
|
||||
{
|
||||
API::Std::event_run('on_sigterm');
|
||||
API::Std::event_run('on_shutdown');
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGTERM'); }
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGTERM') }
|
||||
dbug '!!! Caught SIGTERM; terminating...';
|
||||
alog '!!! Caught SIGTERM; terminating...';
|
||||
sleep 1;
|
||||
@@ -262,7 +266,7 @@ sub signal_int
|
||||
{
|
||||
API::Std::event_run('on_sigint');
|
||||
API::Std::event_run('on_shutdown');
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGINT'); }
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'Caught SIGINT') }
|
||||
dbug '!!! Caught SIGINT; terminating...';
|
||||
alog '!!! Caught SIGINT; terminating...';
|
||||
sleep 1;
|
||||
@@ -285,7 +289,7 @@ sub signal_perlwarn
|
||||
my ($warnmsg) = @_;
|
||||
$warnmsg =~ s/(\n|\r)//xsmg;
|
||||
alog 'Perl Warning: '.$warnmsg;
|
||||
if ($Auto::DEBUG) { say 'Perl Warning: '.$warnmsg; }
|
||||
if ($Auto::DEBUG) { say 'Perl Warning: '.$warnmsg }
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -297,7 +301,7 @@ sub signal_perldie
|
||||
|
||||
return if $EXCEPTIONS_BEING_CAUGHT;
|
||||
alog 'Perl Fatal: '.$diemsg.' -- Terminating program!';
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'A fatal error occurred!'); }
|
||||
foreach (keys %Auto::SOCKET) { API::IRC::quit($_, 'A fatal error occurred!') }
|
||||
API::Std::event_run('on_shutdown');
|
||||
sleep 1;
|
||||
say 'FATAL: '.$diemsg;
|
||||
|
||||
+14
-10
@@ -6,8 +6,6 @@ use strict;
|
||||
use warnings;
|
||||
use Exporter;
|
||||
use English qw(-no_match_vars);
|
||||
use FindBin qw($Bin);
|
||||
our $Bin = $Bin;
|
||||
|
||||
our $VERSION = 1.00;
|
||||
our @ISA = qw(Exporter);
|
||||
@@ -39,28 +37,33 @@ sub modfind
|
||||
|
||||
sub build
|
||||
{
|
||||
my ($features) = @_;
|
||||
my ($features, $Bin, $syswide) = @_;
|
||||
if (!defined $syswide) { $syswide = 0 }
|
||||
|
||||
open(my $FTIME, q{>}, "$Bin/build/time") or println "Failed to install." and exit;
|
||||
open(my $FTIME, q{>}, "$Bin/time") or println "Failed to install." and exit;
|
||||
print $FTIME time."\n" or println "Failed to install." and exit;
|
||||
close $FTIME or println "Failed to install." and exit;
|
||||
|
||||
open(my $FOS, q{>}, "$Bin/build/os") or println "Failed to install." and exit;
|
||||
open(my $FOS, q{>}, "$Bin/os") or println "Failed to install." and exit;
|
||||
print $FOS $OSNAME."\n" or println "Failed to install." and exit;
|
||||
close $FOS or println "Failed to install." and exit;
|
||||
|
||||
open(my $FFEAT, q{>}, "$Bin/build/feat") or println "Failed to install." and exit;
|
||||
open(my $FFEAT, q{>}, "$Bin/feat") or println "Failed to install." and exit;
|
||||
print $FFEAT $features."\n" or println "Failed to install." and exit;
|
||||
close $FFEAT or println "Failed to install." and exit;
|
||||
|
||||
open(my $FPERL, q{>}, "$Bin/build/perl") or println "Failed to install." and exit;
|
||||
open(my $FPERL, q{>}, "$Bin/perl") or println "Failed to install." and exit;
|
||||
print $FPERL "$]\n" or println "Failed to install." and exit;
|
||||
close $FPERL or println "Failed to install." and exit;
|
||||
|
||||
open(my $FVER, q{>}, "$Bin/build/ver") or println "Failed to install." and exit;
|
||||
open(my $FVER, q{>}, "$Bin/ver") or println "Failed to install." and exit;
|
||||
print $FVER "3.0.0d\n" or println "Failed to install." and exit;
|
||||
close $FVER or println "Failed to install." and exit;
|
||||
|
||||
open my $FSYS, '>', "$Bin/syswide" or println "Failed to install." and exit;
|
||||
print {$FSYS} "$syswide\n" or println "Failed to install." and exit;
|
||||
close $FSYS or println "Failed to install." and exit;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -114,18 +117,19 @@ sub checkcore
|
||||
|
||||
sub installmods
|
||||
{
|
||||
my ($prefix) = @_;
|
||||
print 'Would you like to install any official modules? [y/n] ';
|
||||
my $response = <STDIN>;
|
||||
chomp $response;
|
||||
if (lc $response eq 'y') {
|
||||
println 'What modules would you like to install? (separate by commas)';
|
||||
println 'Available modules: Badwords, Bitly, BotStats, Calc, ChanTopics, Dictionary, EightBall, Eval, FML, Greet, HelloChan, IsItUp, LinkTitle, QDB, SASLAuth, Weather';
|
||||
println 'Available modules: AUR, Badwords, Bitly, BotStats, Calc, ChanTopics, Dictionary, EightBall, Eval, FML, Greet, HelloChan, IsItUp, LinkTitle, LOLCAT, Oper, QDB, SASLAuth, UNO, Weather, Werewolf';
|
||||
print '> ';
|
||||
my $modules = <STDIN>; chomp $modules;
|
||||
$modules =~ s/ //g;
|
||||
my @modst = split ',', $modules;
|
||||
foreach (@modst) {
|
||||
system "perl \"$Bin/bin/buildmod\" $_";
|
||||
system "perl \"$prefix/bin/buildmod\" $_";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,17 +13,17 @@ sub new
|
||||
my $self = bless {}, $class;
|
||||
|
||||
# Check to see if the configuration file exists.
|
||||
if (!-e "$Auto::Bin/../etc/$file") {
|
||||
return 0;
|
||||
if (!-e "$Auto::bin{etc}/$file") {
|
||||
return;
|
||||
}
|
||||
|
||||
# Open, read and close the config.
|
||||
open(my $FCONF, q{<}, "$Auto::Bin/../etc/$file") or return 0;
|
||||
my @cosfl = <$FCONF> or return 0;
|
||||
close $FCONF or return 0;
|
||||
open(my $FCONF, q{<}, "$Auto::bin{etc}/$file") or return;
|
||||
my @cosfl = <$FCONF> or return;
|
||||
close $FCONF or return;
|
||||
|
||||
# Save it to self variable.
|
||||
$self->{'config'}->{'path'} = "$Auto::Bin/../etc/$file";
|
||||
$self->{'config'}->{'path'} = "$Auto::bin{etc}/$file";
|
||||
|
||||
return $self;
|
||||
}
|
||||
@@ -38,9 +38,9 @@ sub parse
|
||||
my (%rs);
|
||||
|
||||
# Open, read and close it.
|
||||
open(my $FCONF, q{<}, "$file") or return 0;
|
||||
my @fbuf = <$FCONF> or return 0;
|
||||
close $FCONF or return 0;
|
||||
open(my $FCONF, q{<}, "$file") or return;
|
||||
my @fbuf = <$FCONF> or return;
|
||||
close $FCONF or return;
|
||||
|
||||
# Iterate the file.
|
||||
foreach my $buff (@fbuf) {
|
||||
|
||||
+3
-3
@@ -13,15 +13,15 @@ sub parse
|
||||
my ($lang) = @_;
|
||||
|
||||
# Check that the language file exists.
|
||||
unless (-e "$Auto::Bin/../lang/$lang.alf") {
|
||||
if (!-e "$Auto::bin{lng}/$lang.alf") {
|
||||
# Otherwise, use English.
|
||||
dbug "Language '$lang' not found. Using English.";
|
||||
alog "Language '$lang' not found. Using English.";
|
||||
$lang = "en";
|
||||
$lang = 'en';
|
||||
}
|
||||
|
||||
# Open, read and close the file.
|
||||
open(my $FALF, q{<}, "$Auto::Bin/../lang/$lang.alf") or return 0;
|
||||
open(my $FALF, '<', "$Auto::bin{lng}/$lang.alf") or return;
|
||||
my @fbuf = <$FALF>;
|
||||
close $FALF;
|
||||
|
||||
|
||||
+126
-105
@@ -38,18 +38,24 @@ our %RAWC = (
|
||||
);
|
||||
|
||||
# Variables for various functions.
|
||||
our (%got_001, %botinfo, %botchans, %csprefix, %chanusers, %chanmodes, %cap);
|
||||
our (%got_001, %botchans, %csprefix, %chanmodes, %cap);
|
||||
|
||||
# Events.
|
||||
API::Std::event_add('on_capack');
|
||||
API::Std::event_add('on_cmode');
|
||||
API::Std::event_add('on_umode');
|
||||
API::Std::event_add('on_connect');
|
||||
API::Std::event_add('on_rcjoin');
|
||||
API::Std::event_add('on_ucjoin');
|
||||
API::Std::event_add('on_isupport');
|
||||
API::Std::event_add('on_kick');
|
||||
API::Std::event_add('on_selfkick');
|
||||
API::Std::event_add('on_myinfo');
|
||||
API::Std::event_add('on_namesreply');
|
||||
API::Std::event_add('on_nick');
|
||||
API::Std::event_add('on_notice');
|
||||
API::Std::event_add('on_part');
|
||||
API::Std::event_add('on_upart');
|
||||
API::Std::event_add('on_cprivmsg');
|
||||
API::Std::event_add('on_uprivmsg');
|
||||
API::Std::event_add('on_quit');
|
||||
@@ -69,19 +75,25 @@ sub ircparse
|
||||
# If it's a ping...
|
||||
if ($ex[0] eq 'PING') {
|
||||
# send a PONG.
|
||||
Auto::socksnd($svr, "PONG ".$ex[1]);
|
||||
Auto::socksnd($svr, "PONG $ex[1]");
|
||||
}
|
||||
# If it's AUTHENTICATE
|
||||
elsif ($ex[0] eq 'AUTHENTICATE') {
|
||||
if (API::Std::mod_exists("SASLAuth")) {
|
||||
if (API::Std::mod_exists('SASLAuth')) {
|
||||
M::SASLAuth::handle_authenticate($svr, @ex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
# otherwise, check %RAWC for ex[1].
|
||||
if (defined $RAWC{$ex[1]}) {
|
||||
# Check if it's handled by core.
|
||||
elsif (defined $RAWC{$ex[1]}) {
|
||||
&{ $RAWC{$ex[1]} }($svr, @ex);
|
||||
}
|
||||
else {
|
||||
# otherwise, check for a raw hook.
|
||||
if (defined $API::Std::RAWHOOKS{$ex[1]}) {
|
||||
foreach (keys %{$API::Std::RAWHOOKS{$ex[1]}}) {
|
||||
&{ $API::Std::RAWHOOKS{$ex[1]}{$_} }($svr, @ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,14 +112,14 @@ sub num001 {
|
||||
$got_001{$svr} = 1;
|
||||
|
||||
# In case we don't get NICK from the server.
|
||||
if (!defined $botinfo{$svr}{nick}) {
|
||||
$botinfo{$svr}{nick} = $botinfo{$svr}{newnick};
|
||||
delete $botinfo{$svr}{newnick};
|
||||
if (!defined $State::IRC::botinfo{$svr}{nick}) {
|
||||
$State::IRC::botinfo{$svr}{nick} = $State::IRC::botinfo{$svr}{newnick};
|
||||
delete $State::IRC::botinfo{$svr}{newnick};
|
||||
}
|
||||
|
||||
# Log.
|
||||
API::Log::alog "! Successfully connected to $svr as $botinfo{$svr}{nick}";
|
||||
API::Log::dbug "! Successfully connected to $svr as $botinfo{$svr}{nick}";
|
||||
API::Log::alog "! Successfully connected to $svr as $State::IRC::botinfo{$svr}{nick}";
|
||||
API::Log::dbug "! Successfully connected to $svr as $State::IRC::botinfo{$svr}{nick}";
|
||||
|
||||
# Trigger on_connect.
|
||||
API::Std::event_run('on_connect', $svr);
|
||||
@@ -124,6 +136,9 @@ sub num004 {
|
||||
API::Log::alog "! $svr: $ex[3] running version $ex[4]";
|
||||
API::Log::dbug "! $svr: $ex[3] running version $ex[4]";
|
||||
|
||||
# Trigger on_myinfo.
|
||||
API::Std::event_run('on_myinfo', ($svr, @ex[3..$#ex]));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -144,7 +159,8 @@ sub num352 {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
# Trigger on_whoreply.
|
||||
API::Std::event_run('on_whoreply', ($svr, $ex[2], $ex[3], $ex[4], $ex[5], $ex[6], @ex[7..$#ex]));
|
||||
$ex[9] =~ s/^://xsm;
|
||||
API::Std::event_run('on_whoreply', ($svr, $ex[7], $ex[3], $ex[4], $ex[5], $ex[6], $ex[8], $ex[9], @ex[10..$#ex]));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -155,40 +171,9 @@ sub num353 {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
# Get rid of the colon.
|
||||
$ex[5] = substr($ex[5], 1);
|
||||
# Delete the old chanusers hash if it exists.
|
||||
delete $chanusers{$svr}{$ex[4]} if (defined $chanusers{$svr}{$ex[4]});
|
||||
# Iterate through each user.
|
||||
for (my $i = 5; $i < scalar(@ex); $i++) {
|
||||
my $fi = 0;
|
||||
PFITER: foreach (keys %{ $csprefix{$svr} }) {
|
||||
# Check if the user has status in the channel.
|
||||
if (substr($ex[$i], 0, 1) eq $csprefix{$svr}{$_}) {
|
||||
# He/she does. Lets set that.
|
||||
if (defined $chanusers{$svr}{$ex[4]}{lc $ex[$i]}) {
|
||||
# If the user has multiple statuses.
|
||||
$chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} = $chanusers{$svr}{$ex[4]}{lc $ex[$i]}.$_;
|
||||
delete $chanusers{$svr}{$ex[4]}{lc $ex[$i]};
|
||||
}
|
||||
else {
|
||||
# Or not.
|
||||
$chanusers{$svr}{$ex[4]}{lc(substr($ex[$i], 1))} = $_;
|
||||
}
|
||||
$fi = 1;
|
||||
$ex[$i] = substr $ex[$i], 1;
|
||||
}
|
||||
}
|
||||
# Check if there's still a prefix.
|
||||
foreach (keys %{$csprefix{$svr}}) {
|
||||
if (substr($ex[$i], 0, 1) eq $csprefix{$svr}{$_}) { goto 'PFITER' }
|
||||
}
|
||||
# They had status, so go to the next user.
|
||||
next if $fi;
|
||||
# They didn't, set them as a normal user.
|
||||
if (!defined $chanusers{$svr}{$ex[4]}{lc($ex[$i])}) {
|
||||
$chanusers{$svr}{$ex[4]}{lc($ex[$i])} = 1;
|
||||
}
|
||||
}
|
||||
$ex[5] =~ s/^://xsm;
|
||||
# Trigger on_namesreply.
|
||||
API::Std::event_run('on_namesreply', ($svr, $ex[4], @ex[5..$#ex]));
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -199,7 +184,7 @@ sub num396 {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
# Update our mask.
|
||||
$botinfo{$svr}{mask} = $ex[3];
|
||||
$State::IRC::botinfo{$svr}{mask} = $ex[3];
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -210,14 +195,14 @@ sub num432 {
|
||||
my ($svr, undef) = @_;
|
||||
|
||||
if ($got_001{$svr}) {
|
||||
err(3, "Got error from server[".$svr."]: Erroneous nickname.", 0);
|
||||
err(3, "Got error from server[$svr]: Erroneous nickname.", 0);
|
||||
}
|
||||
else {
|
||||
err(2, "Got error from server[".$svr."] before 001: Erroneous nickname. Closing connection.", 0);
|
||||
API::IRC::quit($svr, "An error occurred.");
|
||||
err(2, "Got error from server[$svr] before connection complete: Erroneous nickname. Closing connection.", 0);
|
||||
API::IRC::quit($svr, 'An error occurred.');
|
||||
}
|
||||
|
||||
delete $botinfo{$svr}{newnick} if (defined $botinfo{$svr}{newnick});
|
||||
if (defined $State::IRC::botinfo{$svr}{newnick}) { delete $State::IRC::botinfo{$svr}{newnick} }
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -227,8 +212,8 @@ sub num432 {
|
||||
sub num433 {
|
||||
my ($svr, undef) = @_;
|
||||
|
||||
if (defined $botinfo{$svr}{newnick}) {
|
||||
API::IRC::nick($svr, $botinfo{$svr}{newnick}."_");
|
||||
if (defined $State::IRC::botinfo{$svr}{newnick}) {
|
||||
API::IRC::nick($svr, $State::IRC::botinfo{$svr}{newnick}.'_');
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -239,10 +224,10 @@ sub num433 {
|
||||
sub num438 {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
if (defined $botinfo{$svr}{newnick}) {
|
||||
API::Std::timer_add("num438_".$botinfo{$svr}{newnick}, 1, $ex[11], sub {
|
||||
API::IRC::nick($Proto::IRC::botinfo{$svr}{newnick});
|
||||
delete $botinfo{$svr}{newnick} if (defined $botinfo{$svr}{newnick});
|
||||
if (defined $State::IRC::botinfo{$svr}{newnick}) {
|
||||
API::Std::timer_add('num438_'.$State::IRC::botinfo{$svr}{newnick}, 1, $ex[11], sub {
|
||||
API::IRC::nick($State::IRC::botinfo{$svr}{newnick});
|
||||
if (defined $State::IRC::botinfo{$svr}{newnick}) { delete $State::IRC::botinfo{$svr}{newnick} }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -254,7 +239,7 @@ sub num438 {
|
||||
sub num465 {
|
||||
my ($svr, undef) = @_;
|
||||
|
||||
err(3, "Banned from ".$svr."! Closing link...", 0);
|
||||
err(3, "Banned from $svr.! Closing link...", 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -264,7 +249,7 @@ sub num465 {
|
||||
sub num471 {
|
||||
my ($svr, (undef, undef, undef, $chan)) = @_;
|
||||
|
||||
err(3, "Cannot join channel ".$chan." on ".$svr.": Channel is full.", 0);
|
||||
err(3, "Cannot join channel $chan on $svr: Channel is full.", 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -274,7 +259,7 @@ sub num471 {
|
||||
sub num473 {
|
||||
my ($svr, (undef, undef, undef, $chan)) = @_;
|
||||
|
||||
err(3, "Cannot join channel ".$chan." on ".$svr.": Channel is invite-only.", 0);
|
||||
err(3, "Cannot join channel $chan on $svr: Channel is invite-only.", 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -284,7 +269,7 @@ sub num473 {
|
||||
sub num474 {
|
||||
my ($svr, (undef, undef, undef, $chan)) = @_;
|
||||
|
||||
err(3, "Cannot join channel ".$chan." on ".$svr.": Banned from channel.", 0);
|
||||
err(3, "Cannot join channel $chan on $svr: Banned from channel.", 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -294,7 +279,7 @@ sub num474 {
|
||||
sub num475 {
|
||||
my ($svr, (undef, undef, undef, $chan)) = @_;
|
||||
|
||||
err(3, "Cannot join channel ".$chan." on ".$svr.": Bad key.", 0);
|
||||
err(3, "Cannot join channel $chan on $svr: Bad key.", 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -304,7 +289,7 @@ sub num475 {
|
||||
sub num477 {
|
||||
my ($svr, (undef, undef, undef, $chan)) = @_;
|
||||
|
||||
err(3, "Cannot join channel ".$chan." on ".$svr.": Need registered nickname.", 0);
|
||||
err(3, "Cannot join channel $chan on $svr: Need registered nickname.", 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -334,7 +319,7 @@ sub cap {
|
||||
}
|
||||
|
||||
# Send CAP REQ/CAP END based on what both we and the server support.
|
||||
if (!$capout) { Auto::socksnd($svr, 'CAP END'); }
|
||||
if (!$capout) { Auto::socksnd($svr, 'CAP END') }
|
||||
else {
|
||||
$capout = substr $capout, 1;
|
||||
Auto::socksnd($svr, "CAP REQ :$capout");
|
||||
@@ -368,13 +353,13 @@ sub cjoin {
|
||||
$chan =~ s/^://gxsm;
|
||||
|
||||
# Check if this is coming from ourselves.
|
||||
if ($src{nick} eq $botinfo{$svr}{nick}) {
|
||||
if ($src{nick} eq $State::IRC::botinfo{$svr}{nick}) {
|
||||
$botchans{$svr}{lc $chan} = 1;
|
||||
API::Std::event_run("on_ucjoin", ($svr, $chan));
|
||||
}
|
||||
else {
|
||||
# It isn't. Update chanusers and trigger on_rcjoin.
|
||||
$chanusers{$svr}{lc $chan}{$src{nick}} = 1;
|
||||
$State::IRC::chanusers{$svr}{lc $chan}{lc $src{nick}} = 1;
|
||||
$src{svr} = $svr;
|
||||
API::Std::event_run("on_rcjoin", (\%src, $chan));
|
||||
}
|
||||
@@ -385,10 +370,9 @@ sub cjoin {
|
||||
# Parse: KICK
|
||||
sub kick {
|
||||
my ($svr, @ex) = @_;
|
||||
my %src = API::IRC::usrc(substr($ex[0], 1));
|
||||
|
||||
# Update chanusers.
|
||||
delete $chanusers{$svr}{$ex[2]}{$ex[3]} if defined $chanusers{$svr}{$ex[2]}{$ex[3]};
|
||||
my %src = API::IRC::usrc(substr($ex[0], 1));
|
||||
$src{svr} = $svr;
|
||||
|
||||
# Set $msg to the kick message.
|
||||
my $msg = 0;
|
||||
@@ -402,11 +386,11 @@ sub kick {
|
||||
}
|
||||
|
||||
# Check if we were the ones kicked.
|
||||
if (lc($ex[3]) eq lc($botinfo{$svr}{nick})) {
|
||||
if (lc($ex[3]) eq lc($State::IRC::botinfo{$svr}{nick})) {
|
||||
# We were kicked!
|
||||
|
||||
# Delete channel from botchans.
|
||||
delete $botchans{$svr}{$ex[2]};
|
||||
delete $botchans{$svr}{lc $ex[2]};
|
||||
|
||||
# Log this horrible act.
|
||||
API::Log::alog("I was kicked from ".$svr."/".$ex[2]." by ".$src{nick}."! Reason: ".$msg);
|
||||
@@ -417,11 +401,14 @@ sub kick {
|
||||
API::IRC::cjoin($svr, $ex[2]);
|
||||
}
|
||||
}
|
||||
|
||||
# Trigger on_selfkick.
|
||||
API::Std::event_run('on_selfkick', (\%src, $ex[2], $msg));
|
||||
}
|
||||
else {
|
||||
# We weren't. Update chanusers and trigger on_kick.
|
||||
if (defined $chanusers{$svr}{$ex[2]}{$ex[3]}) { delete $chanusers{$svr}{$ex[2]}{$ex[3]}; }
|
||||
API::Std::event_run("on_kick", ($svr, \%src, $ex[2], $ex[3], $msg));
|
||||
if (defined $State::IRC::chanusers{$svr}{lc $ex[2]}{lc $ex[3]}) { delete $State::IRC::chanusers{$svr}{lc $ex[2]}{lc $ex[3]} }
|
||||
API::Std::event_run("on_kick", (\%src, $ex[2], $ex[3], $msg));
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -431,10 +418,12 @@ sub kick {
|
||||
sub mode {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
if ($ex[2] ne $botinfo{$svr}{nick}) {
|
||||
if ($ex[2] ne $State::IRC::botinfo{$svr}{nick}) {
|
||||
# Set data we'll need later.
|
||||
my $chan = $ex[2];
|
||||
my $chan = lc $ex[2];
|
||||
$ex[3] =~ s/^://xsm;
|
||||
my $modes = $ex[3];
|
||||
my $fmodes = join ' ', @ex[3..$#ex];
|
||||
$modes =~ s/^://xsm;
|
||||
# Get rid of the useless data, so the mode parser will work smoothly.
|
||||
shift @ex; shift @ex; shift @ex; shift @ex;
|
||||
@@ -475,44 +464,51 @@ sub mode {
|
||||
|
||||
if ($nnt) {
|
||||
# It is a status mode, lets parse changes.
|
||||
my $user = shift(@ex);
|
||||
my $user = lc shift @ex;
|
||||
|
||||
if (defined $chanusers{$svr}{$chan}{$user}) {
|
||||
if (defined $State::IRC::chanusers{$svr}{$chan}{$user}) {
|
||||
if ($op == 1) {
|
||||
if ($chanusers{$svr}{$chan}{$user} eq 1) {
|
||||
$chanusers{$svr}{$chan}{$user} = $maf;
|
||||
return if $State::IRC::chanusers{$svr}{$chan}{$user} =~ m/$maf/xsm;
|
||||
if ($State::IRC::chanusers{$svr}{$chan}{$user} eq 1) {
|
||||
$State::IRC::chanusers{$svr}{$chan}{$user} = $maf;
|
||||
}
|
||||
else {
|
||||
$chanusers{$svr}{$chan}{$user} .= $maf;
|
||||
$State::IRC::chanusers{$svr}{$chan}{$user} .= $maf;
|
||||
}
|
||||
}
|
||||
elsif ($op == 2) {
|
||||
if (length($chanusers{$svr}{$chan}{$user}) == 1) {
|
||||
$chanusers{$svr}{$chan}{$user} = 1;
|
||||
if (length($State::IRC::chanusers{$svr}{$chan}{$user}) == 1) {
|
||||
$State::IRC::chanusers{$svr}{$chan}{$user} = 1;
|
||||
}
|
||||
else {
|
||||
$chanusers{$svr}{$chan}{$user} =~ s/($maf)//gxsm;
|
||||
$State::IRC::chanusers{$svr}{$chan}{$user} =~ s/($maf)//gxsm;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$chanusers{$svr}{$chan}{$user} = $maf;
|
||||
$State::IRC::chanusers{$svr}{$chan}{$user} = $maf;
|
||||
}
|
||||
}
|
||||
else {
|
||||
# It is not. Lets adjust arguments accordingly.
|
||||
if (defined $chanmodes{$svr}{$maf}) {
|
||||
if ($chanmodes{$svr}{$maf} == 1 || $chanmodes{$svr}{$maf} == 2) { shift @ex; }
|
||||
if ($chanmodes{$svr}{$maf} == 1 || $chanmodes{$svr}{$maf} == 2) { shift @ex }
|
||||
if ($chanmodes{$svr}{$maf} == 3) {
|
||||
if ($op == 1) { shift @ex; }
|
||||
if ($op == 1) { shift @ex }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# Trigger on_cmode.
|
||||
API::Std::event_run('on_cmode', ($svr, $chan, $fmodes));
|
||||
}
|
||||
else {
|
||||
# User mode change; trigger on_umode.
|
||||
$ex[3] =~ s/^://xsm;
|
||||
API::Std::event_run('on_umode', ($svr, @ex[3..$#ex]));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -522,22 +518,23 @@ sub nick {
|
||||
$nex =~ s/^://gxsm;
|
||||
|
||||
my %src = API::IRC::usrc(substr($uex, 1));
|
||||
$src{svr} = $svr;
|
||||
|
||||
# Check if this is coming from ourselves.
|
||||
if ($src{nick} eq $botinfo{$svr}{nick}) {
|
||||
if ($src{nick} eq $State::IRC::botinfo{$svr}{nick}) {
|
||||
# It is. Update bot nick hash.
|
||||
$botinfo{$svr}{nick} = $nex;
|
||||
delete $botinfo{$svr}{newnick} if (defined $botinfo{$svr}{newnick});
|
||||
$State::IRC::botinfo{$svr}{nick} = $nex;
|
||||
delete $State::IRC::botinfo{$svr}{newnick} if (defined $State::IRC::botinfo{$svr}{newnick});
|
||||
}
|
||||
else {
|
||||
# It isn't. Update chanusers and trigger on_nick.
|
||||
foreach my $chk (keys %{ $chanusers{$svr} }) {
|
||||
if (defined $chanusers{$svr}{$chk}{$src{nick}}) {
|
||||
$chanusers{$svr}{$chk}{$nex} = $chanusers{$svr}{$chk}{$src{nick}};
|
||||
delete $chanusers{$svr}{$chk}{$src{nick}};
|
||||
foreach my $chk (keys %{ $State::IRC::chanusers{$svr} }) {
|
||||
if (defined $State::IRC::chanusers{$svr}{$chk}{lc $src{nick}}) {
|
||||
$State::IRC::chanusers{$svr}{$chk}{lc $nex} = $State::IRC::chanusers{$svr}{$chk}{lc $src{nick}};
|
||||
delete $State::IRC::chanusers{$svr}{$chk}{lc $src{nick}};
|
||||
}
|
||||
}
|
||||
API::Std::event_run("on_nick", ($svr, \%src, $nex));
|
||||
API::Std::event_run("on_nick", (\%src, $nex));
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -548,7 +545,7 @@ sub notice {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
# Ensure this is coming from a user rather than a server.
|
||||
if ($ex[0] !~ m/!/xsm) { return; }
|
||||
if ($ex[0] !~ m/!/xsm) { return }
|
||||
|
||||
# Prepare all the data.
|
||||
my %src = API::IRC::usrc(substr $ex[0], 1);
|
||||
@@ -566,10 +563,20 @@ sub notice {
|
||||
# Parse: PART
|
||||
sub part {
|
||||
my ($svr, @ex) = @_;
|
||||
my %src = API::IRC::usrc(substr($ex[0], 1));
|
||||
|
||||
my %src = API::IRC::usrc(substr($ex[0], 1));
|
||||
$src{svr} = $svr;
|
||||
|
||||
# Check if it's from us or someone else.
|
||||
if ($src{nick} eq $State::IRC::botinfo{$svr}{nick}) {
|
||||
# Delete this channel from botchans.
|
||||
if ($botchans{$svr}{lc $ex[2]}) { delete $botchans{$svr}{lc $ex[2]} }
|
||||
# Trigger on_upart.
|
||||
API::Std::event_run('on_upart', ($svr, $ex[2]));
|
||||
}
|
||||
else {
|
||||
# Delete them from chanusers.
|
||||
delete $chanusers{$svr}{$ex[2]}{$src{nick}} if defined $chanusers{$svr}{$ex[2]}{$src{nick}};
|
||||
delete $State::IRC::chanusers{$svr}{lc $ex[2]}{lc $src{nick}} if defined $State::IRC::chanusers{$svr}{lc $ex[2]}{lc $src{nick}};
|
||||
|
||||
# Set $msg to the part message.
|
||||
my $msg = 0;
|
||||
@@ -583,7 +590,8 @@ sub part {
|
||||
}
|
||||
|
||||
# Trigger on_part.
|
||||
API::Std::event_run("on_part", ($svr, \%src, $ex[2], $msg));
|
||||
API::Std::event_run("on_part", (\%src, $ex[2], $msg));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -591,10 +599,17 @@ sub part {
|
||||
# Parse: PRIVMSG
|
||||
sub privmsg {
|
||||
my ($svr, @ex) = @_;
|
||||
my %data = API::IRC::usrc(substr($ex[0], 1));
|
||||
my %data;
|
||||
|
||||
# Ensure this is coming from a user rather than a server.
|
||||
if ($ex[0] !~ m/!/xsm) { return; }
|
||||
if ($ex[0] !~ m/!/xsm) {
|
||||
%data = (
|
||||
'nick' => substr($ex[0], 1),
|
||||
'user' => '*',
|
||||
'host' => '*'
|
||||
);
|
||||
}
|
||||
else { %data = API::IRC::usrc(substr($ex[0], 1)) }
|
||||
|
||||
my @argv;
|
||||
for (my $i = 4; $i < scalar(@ex); $i++) {
|
||||
@@ -604,12 +619,16 @@ sub privmsg {
|
||||
|
||||
my ($cmd, $cprefix, $rprefix);
|
||||
# Check if it's to a channel or to us.
|
||||
if (lc($ex[2]) eq lc($botinfo{$svr}{nick})) {
|
||||
if (lc($ex[2]) eq lc($State::IRC::botinfo{$svr}{nick})) {
|
||||
# It is coming to us in a private message.
|
||||
|
||||
# Check for a prefix.
|
||||
$cprefix = (conf_get('fantasy_pf'))[0][0];
|
||||
|
||||
# Ensure it's a valid length.
|
||||
if (length($ex[3]) > 1) {
|
||||
$cmd = uc(substr($ex[3], 1));
|
||||
if (length($ex[3]) > 2) {
|
||||
$cmd = uc substr $ex[3], 1;
|
||||
if (substr($cmd, 0, 1) eq $cprefix) { $cmd = substr $cmd, 1 }
|
||||
if (defined $API::Std::CMDS{$cmd}) {
|
||||
# If this is indeed a command, continue.
|
||||
if ($API::Std::CMDS{$cmd}{lvl} == 1 or $API::Std::CMDS{$cmd}{lvl} == 2) {
|
||||
@@ -718,7 +737,9 @@ sub privmsg {
|
||||
# Parse: QUIT
|
||||
sub quit {
|
||||
my ($svr, @ex) = @_;
|
||||
|
||||
my %src = API::IRC::usrc(substr($ex[0], 1));
|
||||
$src{svr} = $svr;
|
||||
|
||||
# Set $msg to the quit message.
|
||||
my $msg = 0;
|
||||
@@ -732,7 +753,7 @@ sub quit {
|
||||
}
|
||||
|
||||
# Trigger on_quit.
|
||||
API::Std::event_run("on_quit", ($svr, \%src, $msg));
|
||||
API::Std::event_run("on_quit", (\%src, $msg));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# lib/State/IRC.pm - IRC state data.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
package State::IRC;
|
||||
use strict;
|
||||
use warnings;
|
||||
use API::Std qw(hook_add);
|
||||
our (%chanusers, %botinfo);
|
||||
|
||||
# Create on_namesreply hook.
|
||||
hook_add('on_namesreply', 'state.irc.names', sub {
|
||||
my ($svr, $chan, @data) = @_;
|
||||
$chan = lc $chan;
|
||||
|
||||
# Delete the old chanusers hash if it exists.
|
||||
if (defined $chanusers{$svr}{$chan}) { delete $chanusers{$svr}{$chan} }
|
||||
# Iterate through each user.
|
||||
for (1..$#data) {
|
||||
my $fi = 0;
|
||||
PFITER: foreach my $spfx (keys %{ $Proto::IRC::csprefix{$svr} }) {
|
||||
# Check if the user has status in the channel.
|
||||
if (substr($data[$_], 0, 1) eq $Proto::IRC::csprefix{$svr}{$spfx}) {
|
||||
# He/she does. Lets set that.
|
||||
if (defined $chanusers{$svr}{$chan}{lc $data[$_]}) {
|
||||
# If the user has multiple statuses.
|
||||
$chanusers{$svr}{$chan}{lc substr $data[$_], 1} = $chanusers{$svr}{$chan}{lc $data[$_]}.$spfx;
|
||||
delete $chanusers{$svr}{$chan}{lc $data[$_]};
|
||||
}
|
||||
else {
|
||||
# Or not.
|
||||
$chanusers{$svr}{$chan}{lc substr $data[$_], 1} = $spfx;
|
||||
}
|
||||
$fi = 1;
|
||||
$data[$_] = substr $data[$_], 1;
|
||||
}
|
||||
}
|
||||
# Check if there's still a prefix.
|
||||
foreach my $spfx (keys %{$Proto::IRC::csprefix{$svr}}) {
|
||||
if (substr($data[$_], 0, 1) eq $Proto::IRC::csprefix{$svr}{$spfx}) { goto 'PFITER' }
|
||||
}
|
||||
# They had status, so go to the next user.
|
||||
next if $fi;
|
||||
# They didn't, set them as a normal user.
|
||||
if (!defined $chanusers{$svr}{$chan}{lc $data[$_]}) {
|
||||
$chanusers{$svr}{$chan}{lc $data[$_]} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
# Module: AUR. See below for documentation.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
package M::AUR;
|
||||
use strict;
|
||||
use warnings;
|
||||
use WWW::AUR;
|
||||
use API::Std qw(cmd_add cmd_del trans);
|
||||
use API::IRC qw(notice privmsg);
|
||||
|
||||
# Initialization subroutine.
|
||||
sub _init {
|
||||
# Create the AUR command.
|
||||
cmd_add('AUR', 0, 0, \%M::AUR::HELP_AUR, \&M::AUR::cmd_aur) or return;
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Void subroutine.
|
||||
sub _void {
|
||||
# Delete the AUR command.
|
||||
cmd_del('AUR') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
# Help hash for AUR. Spanish and French translations needed.
|
||||
our %HELP_AUR = (
|
||||
en => "This command allows you to lookup a module in the Arch Linux AUR. \2Syntax:\2 AUR <module>",
|
||||
de => "Dieser Befehl ermoeglicht du auf nachschlagst ein Modul in der Arch Linux AUR. \2Syntax:\2 AUR <module>",
|
||||
fr => "Cette commande vous permet de rechercher un module dans le Arch Linux AUR. \2Syntaxe:\2 AUR <module>",
|
||||
);
|
||||
|
||||
# Callback for AUR command.
|
||||
sub cmd_aur {
|
||||
my ($src, ($mod)) = @_;
|
||||
|
||||
# Check for needed parameters.
|
||||
if (!defined $mod) {
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return;
|
||||
}
|
||||
|
||||
# Create an instance of WWW::AUR.
|
||||
my $aur = WWW::AUR->new;
|
||||
# Create an instance of WWW::AUR::Package.
|
||||
my $pkg = $aur->find($mod);
|
||||
|
||||
# Check if there was a result.
|
||||
if (defined $pkg) {
|
||||
# Return the results.
|
||||
privmsg($src->{svr}, $src->{chan}, "Results for \2$mod\2:");
|
||||
privmsg($src->{svr}, $src->{chan}, 'ID: '.$pkg->id.' | Name: '.$pkg->name.' | Version: '.$pkg->version);
|
||||
privmsg($src->{svr}, $src->{chan}, 'Maintainer: '.$pkg->maintainer->name);
|
||||
privmsg($src->{svr}, $src->{chan}, 'URL: https://aur.archlinux.org/packages.php?ID='.$pkg->id);
|
||||
}
|
||||
else {
|
||||
# Else return no results.
|
||||
privmsg($src->{svr}, $src->{chan}, "No results for \2$mod\2.");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('AUR', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: cpan=WWW::AUR perl=5.010000
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
AUR - AUR package information module.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.00
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
<JohnSmith> !aur autobot-git
|
||||
<Auto> Results for autobot-git:
|
||||
<Auto> ID: 47329 Name: autobot-git Version: 20110311-1
|
||||
<Auto> Maintainer: iElijah101
|
||||
<Auto> URL: https://aur.archlinux.org/packages.php?ID=47329
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module adds a command to allow getting information on a package in the
|
||||
Arch User Repository at https://aur.archlinux.org.
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
This module is dependent on the following modules from CPAN:
|
||||
|
||||
=over
|
||||
|
||||
=item L<WWW::AUR>
|
||||
|
||||
Interface to the Arch User Repository.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by Matthew Barksdale.
|
||||
|
||||
This module is maintained by Xelhua Development Group.
|
||||
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
|
||||
Released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+5
-4
@@ -27,7 +27,7 @@ sub _init
|
||||
sub _void
|
||||
{
|
||||
# Delete the act_on_badword hook.
|
||||
hook_del('act_on_badword') or return 0;
|
||||
hook_del('act_on_badword') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -70,8 +70,7 @@ sub actonbadword
|
||||
}
|
||||
|
||||
|
||||
API::Std::mod_init('Badwords', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('Badwords', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -122,6 +121,8 @@ Changing the obvious to your wish.
|
||||
|
||||
=over
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
This module is compatible with Auto version 3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+22
-19
@@ -13,13 +13,13 @@ use URI::Escape;
|
||||
sub _init
|
||||
{
|
||||
# Check for required configuration values.
|
||||
if (!(conf_get('bitly:user'))[0][0] or !(conf_get('bitly:key'))[0][0]) {
|
||||
err(2, "Please verify that you have bitly_user and bitly_key defined in your configuration file.", 0);
|
||||
return 0;
|
||||
if (!conf_get('bitly:user') or !conf_get('bitly:key')) {
|
||||
err(2, 'Bitly: Please verify that you have bitly_user and bitly_key defined in your configuration file.', 0);
|
||||
return;
|
||||
}
|
||||
# Create the SHORTEN and REVERSE commands.
|
||||
cmd_add("SHORTEN", 0, 0, \%M::Bitly::HELP_SHORTEN, \&M::Bitly::shorten) or return 0;
|
||||
cmd_add("REVERSE", 0, 0, \%M::Bitly::HELP_REVERSE, \&M::Bitly::reverse) or return 0;
|
||||
cmd_add('SHORTEN', 0, 0, \%M::Bitly::HELP_SHORTEN, \&M::Bitly::shorten) or return;
|
||||
cmd_add('REVERSE', 0, 0, \%M::Bitly::HELP_REVERSE, \&M::Bitly::reverse) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -29,8 +29,8 @@ sub _init
|
||||
sub _void
|
||||
{
|
||||
# Delete the SHORTEN and REVERSE commands.
|
||||
cmd_del("SHORTEN") or return 0;
|
||||
cmd_del("REVERSE") or return 0;
|
||||
cmd_del('SHORTEN') or return;
|
||||
cmd_del('REVERSE') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -38,10 +38,12 @@ sub _void
|
||||
|
||||
# Help hashes.
|
||||
our %HELP_SHORTEN = (
|
||||
'en' => "This command will shorten an URL using Bit.ly. \002Syntax:\002 SHORTEN <url>",
|
||||
en => "This command will shorten an URL using Bit.ly. \2Syntax:\2 SHORTEN <url>",
|
||||
de => "Dieser Befehl wird eine URL verkuerzen. \2Syntax:\2 SHORTEN <url>",
|
||||
);
|
||||
our %HELP_REVERSE = (
|
||||
'en' => "This command will expand a Bit.ly URL. \002Syntax:\002 REVERSE <url>",
|
||||
en => "This command will expand a Bit.ly URL. \2Syntax:\2 REVERSE <url>",
|
||||
de => "Dieser Befehl wird eine URL erweitern. \2Syntax:\2 REVERSE <url>",
|
||||
);
|
||||
|
||||
# Callback for SHORTEN command.
|
||||
@@ -56,8 +58,8 @@ sub shorten
|
||||
|
||||
# Put together the call to the Bit.ly API.
|
||||
if (!defined $args[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').".");
|
||||
return;
|
||||
}
|
||||
my ($surl, $user, $key) = ($args[0], (conf_get('bitly:user'))[0][0], (conf_get('bitly:key'))[0][0]);
|
||||
$surl = uri_escape($surl);
|
||||
@@ -74,7 +76,7 @@ sub shorten
|
||||
}
|
||||
else {
|
||||
# Otherwise, send an error message.
|
||||
privmsg($src->{svr}, $src->{chan}, "An error occurred while shortening your URL.");
|
||||
privmsg($src->{svr}, $src->{chan}, 'An error occurred while shortening your URL.');
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -92,8 +94,8 @@ sub reverse
|
||||
|
||||
# Put together the call to the Bit.ly API.
|
||||
if (!defined $args[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').".");
|
||||
return;
|
||||
}
|
||||
my ($surl, $user, $key) = ($args[0], (conf_get('bitly:user'))[0][0], (conf_get('bitly:key'))[0][0]);
|
||||
$surl = uri_escape($surl);
|
||||
@@ -110,7 +112,7 @@ sub reverse
|
||||
}
|
||||
else {
|
||||
# Otherwise, send an error message.
|
||||
privmsg($src->{svr}, $src->{chan}, "An error occurred while reversing your URL.");
|
||||
privmsg($src->{svr}, $src->{chan}, 'An error occurred while reversing your URL.');
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -118,8 +120,7 @@ sub reverse
|
||||
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Bitly', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('Bitly', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: cpan=LWP::UserAgent,URI::Escape perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -168,7 +169,7 @@ Add Bitly to module auto-load and the following to your configuration file:
|
||||
|
||||
=over
|
||||
|
||||
* Add Spanish, French and German translations for the help hashes.
|
||||
* Add Spanish and German translations for the help hashes.
|
||||
|
||||
=back
|
||||
|
||||
@@ -179,6 +180,8 @@ Add Bitly to module auto-load and the following to your configuration file:
|
||||
This module adds extra dependencies: LWP::UserAgent and URI::Escape. You can
|
||||
get it from the CPAN <http://www.cpan.org>.
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
This module is compatible with Auto version 3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+10
-9
@@ -47,10 +47,10 @@ sub stats {
|
||||
# Get uptime data.
|
||||
my $uptime = time - $Auto::STARTTIME;
|
||||
my $days = my $hours = my $mins = my $secs = 0;
|
||||
while ($uptime >= 86_400) { $days++; $uptime -= 86_400; }
|
||||
while ($uptime >= 3_600) { $hours++; $uptime -= 3_600; }
|
||||
while ($uptime >= 60) { $mins++; $uptime -= 60; }
|
||||
while ($uptime >= 1) { $secs++; $uptime--; }
|
||||
while ($uptime >= 86_400) { $days++; $uptime -= 86_400 }
|
||||
while ($uptime >= 3_600) { $hours++; $uptime -= 3_600 }
|
||||
while ($uptime >= 60) { $mins++; $uptime -= 60 }
|
||||
while ($uptime >= 1) { $secs++; $uptime-- }
|
||||
|
||||
# Return it.
|
||||
privmsg($src->{svr}, $target, "I have been running for \2$days\2 days, \2$hours\2 hours, \2$mins\2 minutes, and \2$secs\2 seconds.");
|
||||
@@ -62,7 +62,7 @@ sub stats {
|
||||
my $nets = keys %Auto::SOCKET;
|
||||
my $chans;
|
||||
foreach my $net (keys %Auto::SOCKET) {
|
||||
foreach (keys %{$Proto::IRC::botchans{$net}}) { $chans++; }
|
||||
foreach (keys %{$Proto::IRC::botchans{$net}}) { $chans++ }
|
||||
}
|
||||
|
||||
# Return network/channel data.
|
||||
@@ -72,8 +72,7 @@ sub stats {
|
||||
}
|
||||
|
||||
|
||||
API::Std::mod_init('BotStats', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('BotStats', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -90,7 +89,7 @@ BotStats - General information about the bot
|
||||
|
||||
<starcoder> !stats
|
||||
<blue> I have been running for 0 days, 0 hours, 1 minutes, and 5 seconds.
|
||||
<blue> I am running Auto IRC Bot (version 3.0.0a6) for Perl v5.12.3 on linux.
|
||||
<blue> I am running Auto IRC Bot (version 3.0.0a10) for Perl v5.12.3 on linux.
|
||||
<blue> I am on 2 channels, across 1 networks.
|
||||
|
||||
=head1 DESCRIPTION
|
||||
@@ -98,7 +97,7 @@ BotStats - General information about the bot
|
||||
This module creates the STATS command, for returning general information about
|
||||
the bot such as uptime, version, etc.
|
||||
|
||||
This module is compatible with Auto v3.0.0a6+.
|
||||
This module is compatible with Auto v3.0.0a10+.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -113,3 +112,5 @@ This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
This module is released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+10
-8
@@ -14,7 +14,7 @@ use JSON -support_by_pp;
|
||||
sub _init
|
||||
{
|
||||
# Create the CALC command.
|
||||
cmd_add("CALC", 0, 0, \%M::Calc::HELP_CALC, \&M::Calc::calc) or return 0;
|
||||
cmd_add("CALC", 0, 0, \%M::Calc::HELP_CALC, \&M::Calc::calc) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -24,7 +24,7 @@ sub _init
|
||||
sub _void
|
||||
{
|
||||
# Delete the CALC command.
|
||||
cmd_del("CALC") or return 0;
|
||||
cmd_del("CALC") or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -32,7 +32,8 @@ sub _void
|
||||
|
||||
# Help hash.
|
||||
our %FHELP_CALC = (
|
||||
'en' => "This command will calculate an expression using Google Calculator. \002Syntax:\002 CALC <expression>",
|
||||
en => "This command will calculate an expression using Google Calculator. \2Syntax:\2 CALC <expression>",
|
||||
de => "Dieser Befehl berechnet einen Ausdruck mit den Google Rechner. \2Syntax:\2 CALC <expression>",
|
||||
);
|
||||
|
||||
# Callback for CALC command.
|
||||
@@ -49,7 +50,7 @@ sub calc
|
||||
# Put together the call to the Google Calculator API.
|
||||
if (!defined $args[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
my $expr = join(' ', @args);
|
||||
my $url = "http://www.google.com/ig/calculator?q=".uri_escape($expr);
|
||||
@@ -78,8 +79,7 @@ sub calc
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Calc', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('Calc', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: cpan=LWP::UserAgent,URI::Escape,JSON,JSON::PP perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -108,7 +108,7 @@ Google Calculator.
|
||||
|
||||
=over
|
||||
|
||||
* Add Spanish, French and German translations for the help hash.
|
||||
* Add Spanish and French translations for the help hash.
|
||||
|
||||
=back
|
||||
|
||||
@@ -119,6 +119,8 @@ Google Calculator.
|
||||
This module requires LWP::UserAgent, URI::Escape and JSON/JSON::PP.
|
||||
All are obtainable from the CPAN <http://www.cpan.org>.
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
This module is compatible with Auto version 3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
@@ -11,7 +11,7 @@ use API::IRC qw(notice topic);
|
||||
sub _init
|
||||
{
|
||||
# PostgreSQL is not supported.
|
||||
if ($Auto::ENFEAT =~ /pgsql/) { err(3, 'Unable to load ChanTopics: PostgreSQL is not supported.', 0); return; }
|
||||
if ($Auto::ENFEAT =~ /pgsql/) { err(3, 'Unable to load ChanTopics: PostgreSQL is not supported.', 0); return }
|
||||
|
||||
# Create database table if it's missing.
|
||||
$Auto::DB->do('CREATE TABLE IF NOT EXISTS topics (net TEXT, chan TEXT, topic TEXT, divider TEXT, owner TEXT, verb TEXT, status TEXT, other TEXT, static TEXT)') or print "$!\n" and return;
|
||||
@@ -282,8 +282,7 @@ sub _getdata
|
||||
}
|
||||
|
||||
|
||||
API::Std::mod_init('ChanTopics', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('ChanTopics', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -338,8 +337,10 @@ This module adds no extra dependencies.
|
||||
|
||||
This module is not compatible with PostgreSQL, yet.
|
||||
|
||||
This module is compatible with Auto v3.0.0a6+.
|
||||
This module is compatible with Auto v3.0.0a10+.
|
||||
|
||||
Ported from v1.0.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
@@ -31,7 +31,8 @@ sub _void
|
||||
|
||||
# Help hash for DICT. Spanish, French and German translations needed.
|
||||
our %HELP_DICT = (
|
||||
'en' => "This command allows you to lookup a word through Dict.org. \002Syntax:\002 DICT <word>",
|
||||
en => "This command allows you to lookup a word through Dict.org. \2Syntax:\2 DICT <word>",
|
||||
de => "Dieser Befehl ermoeglicht du auf nachschlagst ein Wort durch Dict.org. \2Syntax:\2 DICT <word>",
|
||||
);
|
||||
|
||||
# Callback for DICT command.
|
||||
@@ -75,8 +76,7 @@ sub cmd_dict
|
||||
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Dictionary', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('Dictionary', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: cpan=Net::Dict perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -99,6 +99,8 @@ DICT command.
|
||||
This module adds an extra dependency: Net::Dict. You can get it from the CPAN
|
||||
<http://www.cpan.org>.
|
||||
|
||||
This module is compatible with Auto v3.0.0a6+.
|
||||
This module is compatible with Auto v3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+58
-62
@@ -4,28 +4,40 @@
|
||||
package M::EightBall;
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature qw(switch);
|
||||
use API::Std qw(cmd_add cmd_del trans);
|
||||
use API::IRC qw(privmsg notice);
|
||||
our $ANSWER = 0;
|
||||
my @responses = (
|
||||
'Yes!',
|
||||
'No!',
|
||||
'Yes... No... Yes... No... Hmm... No.',
|
||||
'Hmm... it seems likely.',
|
||||
'Very unlikely.',
|
||||
'Heck no!',
|
||||
'Definite yes!',
|
||||
'Magic unavailable. Try again later.',
|
||||
'Possibly, I wouldn\'t count on it though.',
|
||||
'Outcome looks bad.',
|
||||
'Outcome looks good.',
|
||||
'Can\'t tell now. Maybe another time.',
|
||||
'Sorry, but no.',
|
||||
);
|
||||
|
||||
# Initialization subroutine.
|
||||
sub _init
|
||||
{
|
||||
sub _init {
|
||||
# Create the 8BALL and RIGBALL commands.
|
||||
cmd_add('8BALL', 0, 0, \%M::EightBall::HELP_8BALL, \&M::EightBall::c_8ball) or return 0;
|
||||
cmd_add('RIGBALL', 1, 'cmd.rigball', \%M::EightBall::HELP_RIGBALL, \&M::EightBall::rigball) or return 0;
|
||||
cmd_add('8BALL', 0, 0, \%M::EightBall::HELP_8BALL, \&M::EightBall::c_8ball) or return;
|
||||
cmd_add('RIGBALL', 1, 'cmd.rigball', \%M::EightBall::HELP_RIGBALL, \&M::EightBall::rigball) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Void subroutine.
|
||||
sub _void
|
||||
{
|
||||
sub _void {
|
||||
# Delete the 8BALL and RIGBALL commands.
|
||||
cmd_del('8BALL') or return 0;
|
||||
cmd_del('RIGBALL') or return 0;
|
||||
cmd_del('8BALL') or return;
|
||||
cmd_del('RIGBALL') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -33,93 +45,75 @@ sub _void
|
||||
|
||||
# Help hashes.
|
||||
our %HELP_8BALL = (
|
||||
'en' => "This command will ask the magic 8-Ball your question. \002Syntax:\002 8BALL <question>",
|
||||
en => "This command will ask the magic 8-Ball your question. \2Syntax:\2 8BALL <question>",
|
||||
de => "Dieser Befehl fragt die magische 8-Kugel eine Frage. \2Syntax:\2 8BALL <question>",
|
||||
);
|
||||
our %HELP_RIGBALL = (
|
||||
'en' => "This command will \"rig\" (set) the answer of the next 8-Ball question. \002Syntax:\002 RIGBALL <answer>",
|
||||
en => "This command will \"rig\" (set) the answer of the next 8-Ball question. \2Syntax:\2 RIGBALL <answer>",
|
||||
de => "Dieser Befehl wird festgelegt die Antwort der naechsten 8-Kugel Frage. \2Syntax:\2 RIGBALL <answer>",
|
||||
);
|
||||
|
||||
# Callback for 8BALL command.
|
||||
sub c_8ball
|
||||
{
|
||||
sub c_8ball {
|
||||
my ($src, @argv) = @_;
|
||||
|
||||
if (!defined $argv[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return;
|
||||
}
|
||||
|
||||
privmsg($src->{svr}, $src->{chan}, "\002Question:\002 ".join(" ", @argv));
|
||||
# Return the question.
|
||||
privmsg($src->{svr}, $src->{chan}, "\2Question:\2 ".join q{ }, @argv);
|
||||
|
||||
my $a = '';
|
||||
# Set answer.
|
||||
my $answer;
|
||||
if (!$ANSWER) {
|
||||
my $rn = int(rand(12));
|
||||
given ($rn) {
|
||||
when (1) { $a = "Yes!"; }
|
||||
when (2) { $a = "No!"; }
|
||||
when (3) { $a = "Yes... No... Yes... No... No."; }
|
||||
when (4) { $a = "Hmm... it seems likely."; }
|
||||
when (5) { $a = "Very unlikely."; }
|
||||
when (6) { $a = "Heck no!"; }
|
||||
when (7) { $a = "Definite yes!"; }
|
||||
when (8) { $a = "Magic unavailable. Try again later."; }
|
||||
when (9) { $a = "Possibly, I wouldn't count on it though."; }
|
||||
when (10) { $a = "Outcome looks bad."; }
|
||||
when (11) { $a = "Outcome looks good."; }
|
||||
when (12) { $a = "Can't tell now. Maybe another time."; }
|
||||
default { $a = "Sorry, but no."; }
|
||||
}
|
||||
$answer = $responses[int rand scalar @responses];
|
||||
}
|
||||
else {
|
||||
$a = $ANSWER;
|
||||
$answer = $ANSWER;
|
||||
$ANSWER = 0;
|
||||
}
|
||||
|
||||
privmsg($src->{svr}, $src->{chan}, "\002Answer:\002 ".$a);
|
||||
# Return it.
|
||||
privmsg($src->{svr}, $src->{chan}, "\2Answer:\2 $answer");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Callback for RIGBALL command.
|
||||
sub rigball
|
||||
{
|
||||
sub rigball {
|
||||
my ($src, @argv) = @_;
|
||||
|
||||
# Check for necessary parameters.
|
||||
if (!defined $argv[0]) {
|
||||
privmsg($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
privmsg($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return;
|
||||
}
|
||||
|
||||
$ANSWER = join(" ", @argv);
|
||||
privmsg($src->{svr}, $src->{nick}, "Answer set to: ".$ANSWER);
|
||||
# Return result.
|
||||
$ANSWER = join q{ }, @argv;
|
||||
privmsg($src->{svr}, $src->{nick}, "Answer set to: $ANSWER");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('EightBall', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('EightBall', 'Xelhua', '2.00', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
|
||||
=head1 EightBall
|
||||
=head1 NAME
|
||||
|
||||
=head2 Description
|
||||
EightBall - A magic eightball module.
|
||||
|
||||
=over
|
||||
=head1 VERSION
|
||||
|
||||
This module adds the 8BALL and RIGBALL commands, 8BALL is a channel
|
||||
command for asking the magic 8-Ball a question, RIGBALL is a private
|
||||
command for setting ("rigging") the 8-Ball's next answer.
|
||||
2.00
|
||||
|
||||
=back
|
||||
|
||||
=head2 Examples
|
||||
|
||||
=over
|
||||
=head1 SYNOPSIS
|
||||
|
||||
<JohnSmith> !8ball Will I be rich?
|
||||
<Auto> Question: Will I be rich?
|
||||
@@ -129,22 +123,24 @@ command for setting ("rigging") the 8-Ball's next answer.
|
||||
<Auto> Question: Will I be famous?
|
||||
<Auto> Answer: Of course!
|
||||
|
||||
=back
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=head2 To Do
|
||||
This module adds the 8BALL and RIGBALL commands, 8BALL is a channel command for
|
||||
asking the magic 8-Ball a question, RIGBALL is a private command for setting
|
||||
("rigging") the 8-Ball's next answer.
|
||||
|
||||
=over
|
||||
=head1 AUTHOR
|
||||
|
||||
* Add Spanish, French and German translations for the help hashes.
|
||||
This module was written by Elijah Perrault.
|
||||
|
||||
=back
|
||||
This module is maintained by Xelhua Development Group.
|
||||
|
||||
=head2 Technical
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
=over
|
||||
This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
Released under the same licensing terms as Auto itself.
|
||||
|
||||
Ported from Auto 1.0.
|
||||
=cut
|
||||
|
||||
=back
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+9
-6
@@ -26,9 +26,11 @@ sub _void {
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Help hash for EVAL command. Spanish, German and French translations are needed.
|
||||
# Help hash for EVAL command. Spanish and French translations are needed.
|
||||
our %HELP_EVAL = (
|
||||
'en' => "This command allows you to eval Perl code. USE WITH CAUTION. \2Syntax:\2 EVAL <expression>",
|
||||
en => "This command allows you to eval Perl code. USE WITH CAUTION. \2Syntax:\2 EVAL <expression>",
|
||||
de => "Dieser Befehl ermoeglicht du auf bewertst Perl Code. GEBRAUCH MIT VORSICHT. \2Syntax:\2 EVAL <expression>",
|
||||
fr => "Cette commande vous permet d'évaluer du code Perl. UTILISER AVEC PRUDENCE. \2Syntaxe:\2 EVAL <expression>",
|
||||
);
|
||||
|
||||
# Callback for EVAL command.
|
||||
@@ -44,7 +46,7 @@ sub cmd_eval {
|
||||
# Evaluate the expression and return the result.
|
||||
my $expr = join ' ', @argv;
|
||||
my $result = eval($expr);
|
||||
if (!defined $result) { $result = 'None'; }
|
||||
if (!defined $result) { $result = 'None' }
|
||||
if ($EVAL_ERROR) {
|
||||
$result = $EVAL_ERROR;
|
||||
$result =~ s/(\r|\n)//gxsm;
|
||||
@@ -63,8 +65,7 @@ sub cmd_eval {
|
||||
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Eval', 'Xelhua', '1.01', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('Eval', 'Xelhua', '1.01', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -89,7 +90,7 @@ IRC, returning the output via notice.
|
||||
|
||||
This command requires the cmd.eval privilege.
|
||||
|
||||
This module is compatible with Auto v3.0.0a6+.
|
||||
This module is compatible with Auto v3.0.0a10+.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
@@ -104,3 +105,5 @@ This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
This module is released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+9
-7
@@ -12,7 +12,7 @@ use LWP::UserAgent;
|
||||
sub _init
|
||||
{
|
||||
# Create the FML command.
|
||||
cmd_add('FML', 0, 0, \%M::FML::HELP_FML, \&M::FML::fml) or return 0;
|
||||
cmd_add('FML', 0, 0, \%M::FML::HELP_FML, \&M::FML::fml) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -22,7 +22,7 @@ sub _init
|
||||
sub _void
|
||||
{
|
||||
# Delete the FML command.
|
||||
cmd_del('FML') or return 0;
|
||||
cmd_del('FML') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -30,7 +30,8 @@ sub _void
|
||||
|
||||
# Help hash.
|
||||
our %HELP_FML = (
|
||||
'en' => "This command will return a random FML quote. \002Syntax:\002 FML",
|
||||
en => "This command will return a random FML quote. \2Syntax:\2 FML",
|
||||
de => "Dieser Befehl liefert eine zufaellige Zitat von FML. \2Syntax:\2 FML",
|
||||
);
|
||||
|
||||
# Callback for FML command.
|
||||
@@ -67,8 +68,7 @@ sub fml
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('FML', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('FML', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: cpan=LWP::UserAgent perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -99,7 +99,7 @@ have my hand back?" FML
|
||||
|
||||
=over
|
||||
|
||||
* Add Spanish, French and German translations for the help hash.
|
||||
* Add Spanish and French translations for the help hash.
|
||||
|
||||
=back
|
||||
|
||||
@@ -110,8 +110,10 @@ have my hand back?" FML
|
||||
This module adds an extra dependency: LWP::UserAgent. You can get it from
|
||||
the CPAN <http://www.cpan.org>.
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
This module is compatible with Auto version 3.0.0a10+.
|
||||
|
||||
Ported from Auto 2.0.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+10
-8
@@ -12,7 +12,7 @@ use API::IRC qw(privmsg notice);
|
||||
sub _init
|
||||
{
|
||||
# Not compatible with PostgreSQL.
|
||||
if ($Auto::ENFEAT =~ /pgsql/) { err(2, 'Unable to load Greet: PostgreSQL is not supported.', 0); return; }
|
||||
if ($Auto::ENFEAT =~ /pgsql/) { err(2, 'Unable to load Greet: PostgreSQL is not supported.', 0); return }
|
||||
|
||||
# Create the `greets` table.
|
||||
$Auto::DB->do('CREATE TABLE IF NOT EXISTS greets (nick TEXT, greet TEXT)') or return;
|
||||
@@ -37,9 +37,10 @@ sub _void
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Help hash for GREET. Spanish, French and German translation needed.
|
||||
# Help hash for GREET. Spanish and French translation needed.
|
||||
our %HELP_GREET = (
|
||||
'en' => "This command allows management of greets. \002Syntax:\002 GREET (ADD|DEL) [nick] [greet]",
|
||||
en => "This command allows management of greets. \2Syntax:\2 GREET (ADD|DEL) [nick] [greet]",
|
||||
de => "Dieser Befehl ermoeglicht die Verwaltung von Gruesse. \2Syntax:\2 GREET (ADD|DEL) [nick] [greet]",
|
||||
);
|
||||
# Callback for GREET.
|
||||
sub cmd_greet
|
||||
@@ -100,7 +101,7 @@ sub cmd_greet
|
||||
$Auto::DB->do('DELETE FROM greets WHERE nick = "'.$nick.'"') or notice($src->{svr}, $src->{nick}, trans('An error occurred').q{.}) and return;
|
||||
notice($src->{svr}, $src->{nick}, "Greet for \002$nick\002 successfully deleted.");
|
||||
}
|
||||
default { notice($src->{svr}, $src->{nick}, "Unknown action \002$argv[0]\002. \002Syntax:\002 GREET (ADD|DEL)"); return; }
|
||||
default { notice($src->{svr}, $src->{nick}, "Unknown action \002$argv[0]\002. \002Syntax:\002 GREET (ADD|DEL)"); return }
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -125,8 +126,7 @@ sub hook_rcjoin
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Greet', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('Greet', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -146,7 +146,7 @@ user that has a greet in the database joins a channel the bot is in.
|
||||
|
||||
=over
|
||||
|
||||
* Add Spanish, French and German translations for the help hash.
|
||||
* Add Spanish and French translations for the help hash.
|
||||
|
||||
=back
|
||||
|
||||
@@ -154,6 +154,8 @@ user that has a greet in the database joins a channel the bot is in.
|
||||
|
||||
=over
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
This module is compatible with Auto version 3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+38
-9
@@ -11,7 +11,7 @@ use API::IRC qw(privmsg);
|
||||
sub _init
|
||||
{
|
||||
# Add a hook for when we join a channel.
|
||||
hook_add("on_ucjoin", "HelloChan", \&M::HelloChan::hello) or return 0;
|
||||
hook_add('on_ucjoin', 'HelloChan', \&M::HelloChan::hello) or return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ sub _init
|
||||
sub _void
|
||||
{
|
||||
# Delete the hook.
|
||||
hook_del("on_ucjoin", "HelloChan") or return 0;
|
||||
hook_del('on_ucjoin', 'HelloChan') or return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -29,23 +29,52 @@ sub hello
|
||||
my (($svr, $chan)) = @_;
|
||||
|
||||
# Send a PRIVMSG.
|
||||
privmsg($svr, $chan, "Hello channel! I am a bot!");
|
||||
privmsg($svr, $chan, 'Hello channel! I am a bot!');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('HelloChan', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('HelloChan', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
|
||||
=head1 HelloChan
|
||||
=head1 NAME
|
||||
|
||||
=over
|
||||
HelloChan - An example module. Also, cows go moo.
|
||||
|
||||
This is an example module. Also, cows go moo.
|
||||
=head1 VERSION
|
||||
|
||||
=back
|
||||
1.00
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
* Auto has joined #moocows
|
||||
<Auto> Hello channel! I am a bot!
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module sends "Hello channel! I am a bot!" whenever it
|
||||
joins a channel.
|
||||
|
||||
=head1 INSTALL
|
||||
|
||||
No additonal steps need to be taking to use this module.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by Elijah Perrault.
|
||||
|
||||
This module is maintained by Xelhua Development Group.
|
||||
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
|
||||
Released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+8
-6
@@ -12,7 +12,7 @@ use LWP::UserAgent;
|
||||
sub _init
|
||||
{
|
||||
# Create the ISITUP command.
|
||||
cmd_add('ISITUP', 0, 0, \%M::IsItUp::HELP_ISITUP, \&M::IsItUp::check) or return 0;
|
||||
cmd_add('ISITUP', 0, 0, \%M::IsItUp::HELP_ISITUP, \&M::IsItUp::check) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -22,7 +22,7 @@ sub _init
|
||||
sub _void
|
||||
{
|
||||
# Delete the ISITUP command.
|
||||
cmd_del('ISITUP') or return 0;
|
||||
cmd_del('ISITUP') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -31,6 +31,7 @@ sub _void
|
||||
# Help hashes.
|
||||
our %HELP_ISITUP = (
|
||||
'en' => "This command will check if a website appears up or down to the bot. \002Syntax:\002 ISITUP <url>",
|
||||
'fr' => "Cette commande va vérifier si un site Web semble être vers le haut ou vers le bas pour le bot. \002Syntaxe:\002 ISITUP <url>",
|
||||
);
|
||||
|
||||
# Callback for ISITUP command.
|
||||
@@ -45,7 +46,7 @@ sub check
|
||||
# Do we have enough parameters?
|
||||
if (!defined $argv[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
my $curl = $argv[0];
|
||||
# Does the URL start with http(s)?
|
||||
@@ -69,8 +70,7 @@ sub check
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('IsItUp', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('IsItUp', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: cpan=LWP::UserAgent perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -110,6 +110,8 @@ appears up or down to Auto.
|
||||
This module requires LWP::UserAgent. You can get it from
|
||||
the CPAN <http://www.cpan.org>.
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
This module is compatible with Auto version 3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
@@ -0,0 +1,101 @@
|
||||
# Module: LOLCAT. See below for documentation.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
package M::LOLCAT;
|
||||
use strict;
|
||||
use warnings;
|
||||
use API::Std qw(cmd_add cmd_del trans);
|
||||
use API::IRC qw(privmsg notice);
|
||||
use Acme::LOLCAT;
|
||||
|
||||
# Initialization subroutine.
|
||||
sub _init {
|
||||
# Create LOLCAT command.
|
||||
cmd_add('LOLCAT', 0, 0, \%M::LOLCAT::HELP_LOLCAT, \&M::LOLCAT::cmd_lolcat) or return;
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Void subroutine.
|
||||
sub _void {
|
||||
# Delete LOLCAT command.
|
||||
cmd_del('LOLCAT') or return;
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Help for LOLCAT.
|
||||
our %HELP_LOLCAT = (
|
||||
en => "This command will translate English to LOLCAT speak. \2Syntax:\2 LOLCAT <text>",
|
||||
fr => "Cette commande va traduire l'anglais vers LOLCAT parler. \2Syntaxe:\2 LOLCAT <texte",
|
||||
);
|
||||
|
||||
# Callback for LOLCAT command.
|
||||
sub cmd_lolcat {
|
||||
my ($src, @argv) = @_;
|
||||
|
||||
# At least one parameter is required.
|
||||
if (!defined $argv[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return;
|
||||
}
|
||||
|
||||
# Return LOLCAT translation.
|
||||
privmsg($src->{svr}, $src->{chan}, 'Result: '.translate(join q{ }, @argv));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('LOLCAT', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: perl=5.010000 cpan=Acme::LOLCAT
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
LOLCAT - Translates English into LOLCAT.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.00
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
<starcoder> !lolcat You too can speak like a lolcat!
|
||||
<Auto> Result: YU T CAN SPEKK LIEK LOLCAT! KTHXBYE!
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This will create the LOLCAT command which allows you to translate English text
|
||||
into LOLCAT speak.
|
||||
|
||||
See also: http://en.wikipedia.org/wiki/Lolcat
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
This module is dependent on the following modules from CPAN:
|
||||
|
||||
=over
|
||||
|
||||
=item L<Acme::LOLCAT>
|
||||
|
||||
This is what the module uses to translate English into LOLCAT.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by Elijah Perrault.
|
||||
|
||||
This module is maintained by Xelhua Development Group.
|
||||
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
|
||||
Released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et ts=4 sw=4:
|
||||
@@ -51,6 +51,9 @@ sub gettitle
|
||||
# We were, decode the data.
|
||||
my $data = $res->decoded_content;
|
||||
|
||||
# Strip newlines.
|
||||
$data =~ s/(\n|\r)//gxsm;
|
||||
|
||||
# Check for <title>
|
||||
if ($data =~ m{<title>(.*)</title>}ixsm) {
|
||||
# Found. Decode it.
|
||||
@@ -66,8 +69,7 @@ sub gettitle
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('LinkTitle', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('LinkTitle', 'Xelhua', '1.01', '3.0.0a10');
|
||||
# build: cpan=LWP::UserAgent,HTML::Entities perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -78,7 +80,7 @@ LinkTitle - A module for returning the page title of links.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.00
|
||||
1.01
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
@@ -120,3 +122,7 @@ This module is Copyright 2010-2011 Xelhua Development Group. All rights
|
||||
reserved.
|
||||
|
||||
This module is released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
# Module: Oper.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
package M::Oper;
|
||||
use strict;
|
||||
use warnings;
|
||||
use API::Std qw(hook_add hook_del rchook_add rchook_del conf_get);
|
||||
use API::Log qw(alog);
|
||||
|
||||
# Initialization subroutine.
|
||||
sub _init
|
||||
{
|
||||
# Add a hook for when we join a channel.
|
||||
hook_add('on_connect', 'Oper.onconnect', \&M::Oper::on_connect) or return;
|
||||
# Add a hook for when we get numeric 491 (ERR_NOOPERHOST)
|
||||
rchook_add('491', 'Oper.on491', \&M::Oper::on_num491) or return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Void subroutine.
|
||||
sub _void
|
||||
{
|
||||
# Delete the hooks.
|
||||
hook_del('on_connect', 'Oper.onconnect') or return;
|
||||
rchook_del('381', 'Oper.on381') or return;
|
||||
rchook_del('313', 'Oper.on313') or return;
|
||||
rchook_del('491', 'Oper.on491') or return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
# On connect subroutine.
|
||||
sub on_connect
|
||||
{
|
||||
my ($svr) = @_;
|
||||
# Get the configuration values.
|
||||
my $u = (conf_get("server:$svr:oper_username"))[0][0] if conf_get("server:$svr:oper_username");
|
||||
my $p = (conf_get("server:$svr:oper_password"))[0][0] if conf_get("server:$svr:oper_password");
|
||||
# They don't exist - don't continue.
|
||||
return if !$u or !$p;
|
||||
# Send the OPER command.
|
||||
oper($svr, $u, $p);
|
||||
return 1;
|
||||
}
|
||||
|
||||
# On 491 subroutine
|
||||
sub on_num491 {
|
||||
my ($svr, @ex) = @_;
|
||||
my $reason = join ' ', @ex[3 .. $#ex];
|
||||
$reason =~ s/://xsm;
|
||||
alog("FAILED OPER on ".$svr.": ".$reason);
|
||||
return 1;
|
||||
}
|
||||
|
||||
# A subroutine to check if we are opered on a server
|
||||
sub is_opered {
|
||||
my ($svr) = @_;
|
||||
# Auto is not opered.
|
||||
return if $State::IRC::botinfo{$svr}{modes} !~ m/o/xsm;
|
||||
# Auto is opered.
|
||||
return 1 if $State::IRC::botinfo{$svr}{modes} =~ m/o/xsm;
|
||||
return;
|
||||
}
|
||||
|
||||
# Start of the API
|
||||
|
||||
# Sends the OPER command to the specified server.
|
||||
sub oper {
|
||||
my ($svr, $user, $pass) = @_;
|
||||
Auto::socksnd($svr, "OPER $user $pass");
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Deopers Auto on the specified server.
|
||||
sub deoper {
|
||||
my ($svr) = @_;
|
||||
Auto::socksnd($svr, "MODE $State::IRC::botinfo{$svr}{nick} -o");
|
||||
return 1;
|
||||
}
|
||||
|
||||
# End of the API
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Oper', 'Xelhua', '1.01', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Oper - Auto oper-on-connect module.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.01
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
No commands are currently associated with Oper.
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module adds the ability for Auto to oper on networks he is
|
||||
configured to do so on.
|
||||
|
||||
=head1 INSTALL
|
||||
|
||||
Before using Oper, add the following to the server block in your
|
||||
configuration file, only for servers you wish for Auto to oper on
|
||||
though:
|
||||
|
||||
oper_username <username>;
|
||||
oper_password <password>;
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by Matthew Barksdale.
|
||||
|
||||
This module is maintained by Xelhua Development Group.
|
||||
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
|
||||
Released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
# Module: Ping. See below for documentation.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
package M::Ping;
|
||||
use strict;
|
||||
use warnings;
|
||||
use API::Std qw(cmd_add cmd_del hook_add hook_del rchook_add rchook_del);
|
||||
use API::IRC qw(privmsg notice who);
|
||||
my (@PING, $STATE);
|
||||
my $LAST = 0;
|
||||
|
||||
# Initialization subroutine.
|
||||
sub _init {
|
||||
# Create the PING command.
|
||||
cmd_add('PING', 0, 'cmd.ping', \%M::Ping::HELP_PING, \&M::Ping::cmd_ping) or return;
|
||||
# Create the on_whoreply hook.
|
||||
hook_add('on_whoreply', 'ping.who', \&M::Ping::on_whoreply) or return;
|
||||
# Hook onto numeric 315.
|
||||
rchook_add('315', 'ping.eow', \&M::Ping::ping) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Void subroutine.
|
||||
sub _void {
|
||||
# Delete the PING command.
|
||||
cmd_del('PING') or return;
|
||||
# Delete the on_whoreply hook.
|
||||
hook_del('on_whoreply', 'ping.who') or return;
|
||||
# Delete 315 hook.
|
||||
rchook_del('315', 'ping.eow') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Help for PING.
|
||||
our %HELP_PING = (
|
||||
en => "This command will ping all non-/away users in the channel. \2Syntax:\2 PING",
|
||||
);
|
||||
|
||||
# Callback for PING command.
|
||||
sub cmd_ping {
|
||||
my ($src, @argv) = @_;
|
||||
|
||||
# Check ratelimit (once every five minutes).
|
||||
if ((time - $LAST) < 300) {
|
||||
notice($src->{svr}, $src->{nick}, 'This command is ratelimited. Please wait a while before using it again.');
|
||||
return;
|
||||
}
|
||||
|
||||
# Set last used time to current time.
|
||||
$LAST = time;
|
||||
# Set state.
|
||||
$STATE = $src->{svr}.'::'.$src->{chan};
|
||||
|
||||
# Ship off a WHO.
|
||||
who($src->{svr}, $src->{chan});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Callback for WHO reply.
|
||||
sub on_whoreply {
|
||||
my ($svr, $nick, $target, undef, undef, undef, $status, undef, undef) = @_;
|
||||
|
||||
# If it's us, just return.
|
||||
if ($nick eq $State::IRC::botinfo{$svr}{nick}) { return 1 }
|
||||
|
||||
# Check if we're doing a ping right now.
|
||||
if ($STATE) {
|
||||
# Check if this is the target channel.
|
||||
if ($STATE eq $svr.'::'.$target) {
|
||||
# If their status is not away, push to ping array.
|
||||
if ($status !~ m/G/xsm) {
|
||||
push @PING, $nick;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Ping!
|
||||
sub ping {
|
||||
if ($STATE) {
|
||||
my ($svr, $chan) = split '::', $STATE, 2;
|
||||
privmsg($svr, $chan, 'PING! '.join(' ', @PING));
|
||||
@PING = ();
|
||||
$STATE = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Ping', 'Xelhua', '1.01', '3.0.0a11');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Ping - A module for pinging a channel.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.01
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
<Hermione> .ping
|
||||
<howlbot> PING! `A` tdubellz Hermione Oakfeather LightToagac shadowm_goat kitten starcoder2 Suiseiseki metabill theknife Trashlord Cam HardDisk_WP nerdshark2 MJ94 JonathanD Julius2 CensoredBiscuit LordVoldemort e36freak alyx mth starcoder
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This merely creates the PING command, which will highlight everyone in the
|
||||
channel, excluding the bot itself and those who are /away.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by Elijah Perrault.
|
||||
|
||||
This module is maintained by Xelhua Development Group.
|
||||
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
This module is Copyright 2010-2011 Xelhua Development Group. All rights
|
||||
reserved.
|
||||
|
||||
This module is released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et ts=4 sw=4:
|
||||
+12
-11
@@ -15,7 +15,7 @@ sub _init
|
||||
cmd_add('QDB', 0, 0, \%M::QDB::HELP_QDB, \&M::QDB::cmd_qdb) or return;
|
||||
|
||||
# Check the database format. Fail to load if it's PostgreSQL.
|
||||
if ($Auto::ENFEAT =~ /pgsql/) { err(2, 'Unable to load QDB: PostgreSQL is not supported.', 0); return; }
|
||||
if ($Auto::ENFEAT =~ /pgsql/) { err(2, 'Unable to load QDB: PostgreSQL is not supported.', 0); return }
|
||||
|
||||
# Check for database table.
|
||||
$Auto::DB->do('CREATE TABLE IF NOT EXISTS qdb (quoteid INTEGER PRIMARY KEY, creator TEXT, time INTEGER, quote TEXT)') or return;
|
||||
@@ -82,11 +82,11 @@ sub cmd_qdb
|
||||
my @data = $dbq->fetchrow_array;
|
||||
|
||||
# Check for an unusual issue.
|
||||
if (!defined $data[1]) { notice($src->{svr}, $src->{nick}, trans('An error occurred').'. Quote might not exist.'); return; }
|
||||
if (!defined $data[1]) { notice($src->{svr}, $src->{nick}, trans('An error occurred').'. Quote might not exist.'); return }
|
||||
|
||||
# Send it back.
|
||||
privmsg($src->{svr}, $src->{chan}, "\002Submitted by\002 $data[1] \002on\002 ".POSIX::strftime('%F', localtime($data[2]))." \002at\002 ".POSIX::strftime('%I:%M %p', localtime($data[2])));
|
||||
privmsg($src->{svr}, $src->{chan}, $data[3]);
|
||||
privmsg($src->{svr}, $src->{chan}, '> '.$data[3]);
|
||||
}
|
||||
when ('COUNT') {
|
||||
# Get count.
|
||||
@@ -103,7 +103,7 @@ sub cmd_qdb
|
||||
|
||||
# Random number.
|
||||
my $rand = int(rand($count));
|
||||
if ($rand == 0) { $rand = $count; }
|
||||
if ($rand == 0) { $rand = $count }
|
||||
|
||||
# Get quote.
|
||||
my $dbq = $Auto::DB->prepare('SELECT * FROM qdb WHERE quoteid = ?') or
|
||||
@@ -113,7 +113,7 @@ sub cmd_qdb
|
||||
|
||||
# Send it back.
|
||||
privmsg($src->{svr}, $src->{chan}, "\002ID:\002 $data[0] - \002Submitted by\002 $data[1] \002on\002 ".POSIX::strftime('%F', localtime($data[2]))." \002at\002 ".POSIX::strftime('%I:%M %p', localtime($data[2])));
|
||||
privmsg($src->{svr}, $src->{chan}, $data[3]);
|
||||
privmsg($src->{svr}, $src->{chan}, '> '.$data[3]);
|
||||
}
|
||||
when ('SEARCH') {
|
||||
# QDB SEARCH.
|
||||
@@ -157,7 +157,7 @@ sub cmd_qdb
|
||||
privmsg($src->{svr}, $src->{chan}, "\2".scalar @BUFFER."\2 results for \2$expr\2:");
|
||||
my $i = 0;
|
||||
my $si = 3;
|
||||
if (conf_get('qdb_search_resnum')) { $si = (conf_get('qdb_search_resnum'))[0][0] - 1; }
|
||||
if (conf_get('qdb_search_resnum')) { $si = (conf_get('qdb_search_resnum'))[0][0] - 1 }
|
||||
while ($i <= $si) {
|
||||
if (!defined $BUFFER[0]) {
|
||||
last;
|
||||
@@ -177,7 +177,7 @@ sub cmd_qdb
|
||||
# Return four quotes.
|
||||
my $i = 0;
|
||||
my $si = 3;
|
||||
if (conf_get('qdb_search_resnum')) { $si = (conf_get('qdb_search_resnum'))[0][0] - 1; }
|
||||
if (conf_get('qdb_search_resnum')) { $si = (conf_get('qdb_search_resnum'))[0][0] - 1 }
|
||||
while ($i <= $si) {
|
||||
if (!defined $BUFFER[0]) {
|
||||
last;
|
||||
@@ -204,15 +204,14 @@ sub cmd_qdb
|
||||
|
||||
notice($src->{svr}, $src->{nick}, (($dbq) ? 'Done.' : trans('An error occurred').q{.}));
|
||||
}
|
||||
default { notice($src->{svr}, $src->{nick}, "Unknown action \002".uc($argv[0])."\002. \002Syntax:\002 QDB (ADD|VIEW|COUNT|RAND|DEL) [quote]"); return; }
|
||||
default { notice($src->{svr}, $src->{nick}, "Unknown action \002".uc($argv[0])."\002. \002Syntax:\002 QDB (ADD|VIEW|COUNT|RAND|DEL) [quote]"); return }
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
API::Std::mod_init('QDB', 'Xelhua', '1.02', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('QDB', 'Xelhua', '1.04', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -223,7 +222,7 @@ QDB - Quote database module.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.02
|
||||
1.04
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
@@ -260,3 +259,5 @@ This module is Copyright 2010-2011 Xelhua Development Group.
|
||||
Released under the same licensing terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+13
-12
@@ -14,20 +14,20 @@ use API::IRC qw(privmsg);
|
||||
sub _init
|
||||
{
|
||||
# Check if this Auto was built with SASL support.
|
||||
if ($Auto::ENFEAT !~ m/sasl/xsm) { err(2, 'Auto was not built with SASL support. Aborting SASLAuth.', 0) and return; }
|
||||
if ($Auto::ENFEAT !~ m/sasl/xsm) { err(2, 'Auto was not built with SASL support. Aborting SASLAuth.', 0) and return }
|
||||
# Add sasl to supported CAP for servers configured with SASL.
|
||||
my %servers = conf_get('server');
|
||||
foreach my $svr (keys %servers) {
|
||||
if (conf_get("server:$svr:sasl_username")) { $Proto::IRC::cap{$svr} .= ' sasl'; }
|
||||
if (conf_get("server:$svr:sasl_username") and conf_get("server:$svr:sasl_password") and conf_get("server:$svr:sasl_timeout")) { $Proto::IRC::cap{$svr} .= ' sasl' }
|
||||
}
|
||||
# Hook for when CAP ACK sasl is received.
|
||||
hook_add('on_capack', 'sasl.cap', \&M::SASLAuth::handle_capack) or return;
|
||||
# Hook for parsing 903.
|
||||
rchook_add('903', \&M::SASLAuth::handle_903) or return;
|
||||
rchook_add('903', 'sasl.903', \&M::SASLAuth::handle_903) or return;
|
||||
# Hook for parsing 904.
|
||||
rchook_add('904', \&M::SASLAuth::handle_904) or return;
|
||||
rchook_add('904', 'sasl.904', \&M::SASLAuth::handle_904) or return;
|
||||
# Hook for parsing 906.
|
||||
rchook_add('906', \&M::SASLAuth::handle_906) or return;
|
||||
rchook_add('906', 'sasl.906', \&M::SASLAuth::handle_906) or return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ sub _void
|
||||
{
|
||||
# Delete the hooks.
|
||||
hook_del('on_capack') or return;
|
||||
rchook_del('903') or return;
|
||||
rchook_del('904') or return;
|
||||
rchook_del('906') or return;
|
||||
rchook_del('903', 'sasl.903') or return;
|
||||
rchook_del('904', 'sasl.904') or return;
|
||||
rchook_del('906', 'sasl.906') or return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ sub handle_capack {
|
||||
|
||||
if ($sacap eq 'sasl') {
|
||||
Auto::socksnd($svr, 'AUTHENTICATE PLAIN');
|
||||
timer_add('auth_timeout_'.$svr, 1, (conf_get("server:$svr:sasl_timeout"))[0][0], sub { Auto::socksnd($svr, 'CAP END'); });
|
||||
timer_add('auth_timeout_'.$svr, 1, (conf_get("server:$svr:sasl_timeout"))[0][0], sub { Auto::socksnd($svr, 'CAP END') });
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -111,8 +111,7 @@ sub handle_906
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('SASLAuth', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('SASLAuth', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -169,6 +168,8 @@ block(s) you wish to use SASL with:
|
||||
This adds an extra dependency: You must build Auto with the
|
||||
--enable-sasl option.
|
||||
|
||||
This module is compatible with Auto v3.0.0a6+.
|
||||
This module is compatible with Auto v3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+391
-245
File diff suppressed because it is too large.
Load diff
+12
-10
@@ -13,7 +13,7 @@ use XML::Simple;
|
||||
sub _init
|
||||
{
|
||||
# Create the Weather command.
|
||||
cmd_add("WEATHER", 0, 0, \%M::Weather::HELP_WEATHER, \&M::Weather::weather) or return 0;
|
||||
cmd_add('WEATHER', 0, 0, \%M::Weather::HELP_WEATHER, \&M::Weather::weather) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -23,7 +23,7 @@ sub _init
|
||||
sub _void
|
||||
{
|
||||
# Delete the Weather command.
|
||||
cmd_del("WEATHER") or return 0;
|
||||
cmd_del('WEATHER') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
@@ -32,6 +32,7 @@ sub _void
|
||||
# Help hashes.
|
||||
our %HELP_WEATHER = (
|
||||
'en' => "This command will retrieve the weather via Wunderground for the specified location. \002Syntax:\002 WEATHER <location>",
|
||||
'fr' => "Cette commande permet de récupérer la météo via Wunderground pour l'emplacement spécifié. \002Syntaxe:\002 WEATHER <emplacement>",
|
||||
);
|
||||
|
||||
# Callback for Weather command.
|
||||
@@ -45,8 +46,8 @@ sub weather
|
||||
$ua->timeout(2);
|
||||
# Put together the call to the Wunderground API.
|
||||
if (!defined $args[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans("Not enough parameters").".");
|
||||
return 0;
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').".");
|
||||
return;
|
||||
}
|
||||
my $loc = join(' ', @args);
|
||||
$loc =~ s/ /%20/g;
|
||||
@@ -60,26 +61,25 @@ sub weather
|
||||
# And send to channel
|
||||
if (!ref($d->{observation_location}->{country})) {
|
||||
my $windc = $d->{wind_string};
|
||||
if (substr($windc, length($windc) - 1, 1) eq " ") { $windc = substr($windc, 0, length($windc) - 1); }
|
||||
if (substr($windc, length($windc) - 1, 1) eq " ") { $windc = substr($windc, 0, length($windc) - 1) }
|
||||
privmsg($src->{svr}, $src->{chan}, "Results for \2".$d->{observation_location}->{full}."\2 - \2Temperature:\2 ".$d->{temperature_string}." \2Wind Conditions:\2 ".$windc." \2Conditions:\2 ".$d->{weather});
|
||||
privmsg($src->{svr}, $src->{chan}, "\2Heat index:\2 ".$d->{heat_index_string}." \2Humidity:\2 ".$d->{relative_humidity}." \2Pressure:\2 ".$d->{pressure_string}." - ".$d->{observation_time});
|
||||
}
|
||||
else {
|
||||
# Otherwise, send an error message.
|
||||
privmsg($src->{svr}, $src->{chan}, "Location not found.");
|
||||
privmsg($src->{svr}, $src->{chan}, 'Location not found.');
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Otherwise, send an error message.
|
||||
privmsg($src->{svr}, $src->{chan}, "An error occurred while retrieving your weather.");
|
||||
privmsg($src->{svr}, $src->{chan}, 'An error occurred while retrieving your weather.');
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('Weather', 'Xelhua', '1.00', '3.0.0a6', __PACKAGE__);
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
API::Std::mod_init('Weather', 'Xelhua', '1.00', '3.0.0a10');
|
||||
# build: cpan=LWP::UserAgent,XML::Simple perl=5.010000
|
||||
|
||||
__END__
|
||||
@@ -121,6 +121,8 @@ From the NE at 9 MPH Gusting to 22 MPH Conditions: Overcast
|
||||
This module requires LWP::UserAgent and XML::Simple. Both are
|
||||
obtainable from CPAN <http://www.cpan.org>.
|
||||
|
||||
This module is compatible with Auto version 3.0.0a6+.
|
||||
This module is compatible with Auto version 3.0.0a10+.
|
||||
|
||||
=back
|
||||
|
||||
# vim: set ai et sw=4 ts=4:
|
||||
+2248
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,373 @@
|
||||
# Module: WerewolfAdmin. See below for documentation.
|
||||
# Copyright (C) 2010-2011 Xelhua Development Group, et al.
|
||||
# This program is free software; rights to this code are stated in doc/LICENSE.
|
||||
package M::WerewolfAdmin;
|
||||
use strict;
|
||||
use warnings;
|
||||
use feature qw(switch);
|
||||
use API::Std qw(cmd_add cmd_del timer_add timer_del trans conf_get);
|
||||
use API::IRC qw(privmsg notice cmode ison);
|
||||
|
||||
# Initialization subroutine.
|
||||
sub _init {
|
||||
# Create the WOLFA command.
|
||||
cmd_add('WOLFA', 0, 'werewolf.admin', \%M::WerewolfAdmin::HELP_WOLFA, \&M::WerewolfAdmin::cmd_wolfa) or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Void subroutine.
|
||||
sub _void {
|
||||
# Delete the WOLFA command.
|
||||
cmd_del('WOLFA') or return;
|
||||
|
||||
# Success.
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Help hash for the WOLFA command.
|
||||
our %HELP_WOLFA = (
|
||||
en => "This command allows you to perform various administrative actions in a game of Werewolf (A.K.A. Mafia). \2Syntax:\2 WOLFA (JOIN|WAIT|START|KICK|STOP) [parameters]",
|
||||
);
|
||||
|
||||
# Callback for the WOLFA command.
|
||||
sub cmd_wolfa {
|
||||
my ($src, @argv) = @_;
|
||||
|
||||
# We require at least one parameter.
|
||||
if (!defined $argv[0]) {
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return;
|
||||
}
|
||||
|
||||
# Iterate the parameter.
|
||||
given (uc $argv[0]) {
|
||||
when (/^(JOIN|J)$/) {
|
||||
# WOLFA JOIN
|
||||
|
||||
# Requires an extra parameter.
|
||||
if (!defined $argv[1]) {
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if a game is running.
|
||||
if (!$M::Werewolf::PGAME and !$M::Werewolf::GAME) {
|
||||
notice($src->{svr}, $src->{nick}, 'No game is currently running.');
|
||||
}
|
||||
elsif ($M::Werewolf::GAME) {
|
||||
notice($src->{svr}, $src->{nick}, 'Sorry, but the game is already running. Try again next time.');
|
||||
}
|
||||
else {
|
||||
# Check if this is the game channel.
|
||||
if ($src->{svr}.'/'.$src->{chan} ne $M::Werewolf::GAMECHAN) {
|
||||
notice($src->{svr}, $src->{nick}, "Werewolf is currently running in \2$M::Werewolf::GAMECHAN\2.");
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if this user exists in channel.
|
||||
if (!ison($src->{svr}, $src->{chan}, lc $argv[1])) {
|
||||
notice($src->{svr}, $src->{nick}, "No such user \2$argv[1]\2 is on the channel.");
|
||||
return;
|
||||
}
|
||||
|
||||
# Make sure they're not already playing.
|
||||
if (exists $M::Werewolf::PLAYERS{lc $argv[1]}) {
|
||||
notice($src->{svr}, $src->{nick}, 'They\'re already playing!');
|
||||
return;
|
||||
}
|
||||
|
||||
# Set variables.
|
||||
$M::Werewolf::PLAYERS{lc $argv[1]} = 0;
|
||||
my $nick = $M::Werewolf::NICKS{lc $argv[1]} = $Core::IRC::Users::users{$src->{svr}}{lc $argv[1]};
|
||||
|
||||
# Send message.
|
||||
my ($gsvr, $gchan) = split '/', $M::Werewolf::GAMECHAN, 2;
|
||||
cmode($gsvr, $gchan, "+v $nick");
|
||||
privmsg($gsvr, $gchan, "\2$nick\2 was forced to join the game by \2$src->{nick}\2.");
|
||||
}
|
||||
}
|
||||
when (/^(WAIT|W)$/) {
|
||||
# WOLFA WAIT
|
||||
|
||||
# Check if a game is running.
|
||||
if (!$M::Werewolf::PGAME) {
|
||||
if (!$M::Werewolf::GAME) {
|
||||
notice($src->{svr}, $src->{nick}, 'No game is currently running.');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
notice($src->{svr}, $src->{nick}, 'Werewolf is already in play.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# Check if this is the game channel.
|
||||
if ($src->{svr}.'/'.$src->{chan} ne $M::Werewolf::GAMECHAN) {
|
||||
notice($src->{svr}, $src->{nick}, "Werewolf is currently running in \2$M::Werewolf::GAMECHAN\2.");
|
||||
return;
|
||||
}
|
||||
|
||||
# Increase WAIT.
|
||||
$M::Werewolf::WAIT += 20;
|
||||
# And WAITED.
|
||||
$M::Werewolf::WAITED++;
|
||||
privmsg($src->{svr}, $src->{chan}, "\2$src->{nick}\2 forcibly increased join wait time by 20 seconds.");
|
||||
}
|
||||
when ('START') {
|
||||
# WOLFA START
|
||||
|
||||
# Check if a game is running.
|
||||
if (!$M::Werewolf::PGAME) {
|
||||
if (!$M::Werewolf::GAME) {
|
||||
notice($src->{svr}, $src->{nick}, 'No game is currently running.');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
notice($src->{svr}, $src->{nick}, 'Werewolf is already in play.');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# Check if this is the game channel.
|
||||
if ($src->{svr}.'/'.$src->{chan} ne $M::Werewolf::GAMECHAN) {
|
||||
notice($src->{svr}, $src->{nick}, "Werewolf is currently running in \2$M::Werewolf::GAMECHAN\2.");
|
||||
return;
|
||||
}
|
||||
|
||||
# Need four or more players.
|
||||
if (keys %M::Werewolf::PLAYERS < 4) {
|
||||
privmsg($src->{svr}, $src->{chan}, "$src->{nick}: Four or more players are required to play.");
|
||||
return;
|
||||
}
|
||||
|
||||
# First, determine how many players to declare a wolf.
|
||||
my $cwolves = POSIX::ceil(keys(%M::Werewolf::PLAYERS) * .14);
|
||||
# Only one seer, harlot, guardian angel, traitor and detective.
|
||||
my $cseers = 1;
|
||||
my $charlots = my $cdrunks = my $cangels = my $ctraitors = my $cdetectives = 0;
|
||||
if (keys %M::Werewolf::PLAYERS >= 6) { $charlots++ unless conf_get('werewolf:rated-g') }
|
||||
if (keys %M::Werewolf::PLAYERS >= 7) { $cdrunks++ unless conf_get('werewolf:rated-g') }
|
||||
if (keys %M::Werewolf::PLAYERS >= 9) { $cangels++ unless conf_get('werewolf:no-angels') }
|
||||
if (keys %M::Werewolf::PLAYERS >= 12 and conf_get('werewolf:traitors')) { $ctraitors++ }
|
||||
if (keys %M::Werewolf::PLAYERS >= 16 and conf_get('werewolf:detectives')) { $cdetectives++ }
|
||||
|
||||
# Give all players a role.
|
||||
foreach my $plyr (keys %M::Werewolf::PLAYERS) { $M::Werewolf::PLAYERS{$plyr} = 'v' }
|
||||
# Push players into a temporary array.
|
||||
my @plyrs = keys %M::Werewolf::PLAYERS;
|
||||
|
||||
# Set wolves.
|
||||
while ($cwolves > 0) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
if ($M::Werewolf::PLAYERS{$rpi} !~ m/^(w|s|g|h|d|t)$/xsm) {
|
||||
$M::Werewolf::PLAYERS{$rpi} = 'w';
|
||||
$cwolves--;
|
||||
$M::Werewolf::STATIC[0] .= ", \2$M::Werewolf::NICKS{$rpi}\2";
|
||||
}
|
||||
}
|
||||
$M::Werewolf::STATIC[0] = substr $M::Werewolf::STATIC[0], 2;
|
||||
# Set seers.
|
||||
while ($cseers > 0) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
if ($M::Werewolf::PLAYERS{$rpi} !~ m/^(w|g|h|d|t)$/xsm) {
|
||||
$M::Werewolf::PLAYERS{$rpi} = 's';
|
||||
$cseers--;
|
||||
$M::Werewolf::STATIC[1] = "\2$M::Werewolf::NICKS{$rpi}\2";
|
||||
}
|
||||
}
|
||||
# Set harlots.
|
||||
while ($charlots > 0) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
if ($M::Werewolf::PLAYERS{$rpi} !~ m/^(w|g|s|d|t)$/xsm) {
|
||||
$M::Werewolf::PLAYERS{$rpi} = 'h';
|
||||
$charlots--;
|
||||
$M::Werewolf::STATIC[2] = "\2$M::Werewolf::NICKS{$rpi}\2";
|
||||
}
|
||||
}
|
||||
# Set drunks.
|
||||
while ($cdrunks > 0) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
if ($M::Werewolf::PLAYERS{$rpi} =~ m/v/xsm) {
|
||||
$M::Werewolf::PLAYERS{$rpi} = 'vi';
|
||||
$cdrunks--;
|
||||
}
|
||||
}
|
||||
# Set guardian angels.
|
||||
while ($cangels > 0) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
if ($M::Werewolf::PLAYERS{$rpi} !~ m/^(w|h|s|d|t)$/xsm) {
|
||||
$M::Werewolf::PLAYERS{$rpi} = 'g';
|
||||
$cangels--;
|
||||
$M::Werewolf::STATIC[3] = "\2$M::Werewolf::NICKS{$rpi}\2";
|
||||
}
|
||||
}
|
||||
# Set traitors.
|
||||
while ($ctraitors > 0) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
if ($M::Werewolf::PLAYERS{$rpi} !~ m/^(w|h|s|d|g)$/xsm) {
|
||||
$M::Werewolf::PLAYERS{$rpi} = 't';
|
||||
$ctraitors--;
|
||||
$M::Werewolf::STATIC[4] = "\2$M::Werewolf::NICKS{$rpi}\2";
|
||||
}
|
||||
}
|
||||
# Set detectives.
|
||||
while ($cdetectives > 0) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
if ($M::Werewolf::PLAYERS{$rpi} !~ m/^(w|h|s|g|t)$/xsm) {
|
||||
$M::Werewolf::PLAYERS{$rpi} = 'd';
|
||||
$cdetectives--;
|
||||
$M::Werewolf::STATIC[5] = "\2$M::Werewolf::NICKS{$rpi}\2";
|
||||
}
|
||||
}
|
||||
|
||||
# If there's 8 or more players, give one of them a gun.
|
||||
if (keys %M::Werewolf::PLAYERS >= 8) {
|
||||
my $rpi = $plyrs[int rand scalar @plyrs];
|
||||
while ($M::Werewolf::PLAYERS{$rpi} =~ m/w/xsm || $M::Werewolf::PLAYERS{$rpi} =~ m/t/xsm) { $rpi = $plyrs[int rand scalar @plyrs] }
|
||||
$M::Werewolf::PLAYERS{$rpi} .= 'b';
|
||||
|
||||
# And give them PLAYER COUNT * .12 bullets rounded up.
|
||||
$M::Werewolf::BULLETS = POSIX::ceil(keys(%M::Werewolf::PLAYERS) * .12);
|
||||
|
||||
if ($M::Werewolf::PLAYERS{$rpi} =~ m/i/xsm) { $M::Werewolf::BULLETS = $M::Werewolf::BULLETS * 3 }
|
||||
}
|
||||
|
||||
# Set variables.
|
||||
$M::Werewolf::GAME = 1;
|
||||
$M::Werewolf::PGAME = 0;
|
||||
|
||||
# Set spoke variables.
|
||||
foreach (keys %M::Werewolf::PLAYERS) { $M::Werewolf::SPOKE{$_} = time }
|
||||
|
||||
# All players have their role, so lets begin the game!
|
||||
my ($gsvr, $gchan) = split '/', $M::Werewolf::GAMECHAN, 2;
|
||||
privmsg($gsvr, $gchan, "Game is now starting. (forced start by \2$src->{nick}\2)");
|
||||
cmode($gsvr, $gchan, '+m');
|
||||
# Delete waiting timer.
|
||||
timer_del('werewolf.joinwait');
|
||||
# Start timer for bed checking.
|
||||
timer_add('werewolf.chkbed', 2, 5, \&M::Werewolf::_chkbed);
|
||||
# Initialize the nighttime.
|
||||
M::Werewolf::_init_night();
|
||||
}
|
||||
when (/^(KICK|K)$/) {
|
||||
# WOLFA KICK
|
||||
|
||||
# Check if a game is running.
|
||||
if (!$M::Werewolf::GAME and !$M::Werewolf::PGAME) {
|
||||
notice($src->{svr}, $src->{nick}, 'No game is currently running.');
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if this is the game channel.
|
||||
if ($src->{svr}.'/'.$src->{chan} ne $M::Werewolf::GAMECHAN) {
|
||||
notice($src->{svr}, $src->{nick}, "Werewolf is currently running in \2$M::Werewolf::GAMECHAN\2.");
|
||||
return;
|
||||
}
|
||||
|
||||
# Requires an extra parameter.
|
||||
if (!defined $argv[1]) {
|
||||
notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.});
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if the target is playing.
|
||||
if (!exists $M::Werewolf::PLAYERS{lc $argv[1]}) {
|
||||
notice($src->{svr}, $src->{nick}, "\2$argv[1]\2 is not currently playing.");
|
||||
return;
|
||||
}
|
||||
|
||||
# Kill the target.
|
||||
privmsg($src->{svr}, $src->{chan}, "\2$argv[1]\2 died of an unknown disease. He/She was a \2".M::Werewolf::_getrole(lc $argv[1], 2)."\2.");
|
||||
M::Werewolf::_player_del(lc $argv[1]);
|
||||
}
|
||||
when ('STOP') {
|
||||
# WOLFA STOP
|
||||
|
||||
# Check if a game is running.
|
||||
if (!$M::Werewolf::GAME and !$M::Werewolf::PGAME) {
|
||||
notice($src->{svr}, $src->{nick}, 'No game is currently running.');
|
||||
return;
|
||||
}
|
||||
|
||||
# Check if this is the game channel.
|
||||
if ($src->{svr}.'/'.$src->{chan} ne $M::Werewolf::GAMECHAN) {
|
||||
notice($src->{svr}, $src->{nick}, "Werewolf is currently running in \2$M::Werewolf::GAMECHAN\2.");
|
||||
return;
|
||||
}
|
||||
|
||||
# End the game.
|
||||
my ($gsvr, $gchan) = split '/', $M::Werewolf::GAMECHAN, 2;
|
||||
privmsg($gsvr, $gchan, "\2$src->{nick}\2 is forcing the game to end...");
|
||||
M::Werewolf::_gameover('n');
|
||||
}
|
||||
default { notice($src->{svr}, $src->{nick}, trans('Unknown action', $_).q{.}) }
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Start initialization.
|
||||
API::Std::mod_init('WerewolfAdmin', 'Xelhua', '1.00', '3.0.0a11');
|
||||
# build: perl=5.010000
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WerewolfAdmin - Administrative functions for Werewolf
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.00
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
None
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module allows one to administer the Werewolf IRC game, provided by the
|
||||
Werewolf module.
|
||||
|
||||
It provides the following commands:
|
||||
|
||||
WOLFA JOIN|J - Force join.
|
||||
WOLFA WAIT - Force wait.
|
||||
WOLFA START - Force start.
|
||||
WOLFA KICK|K - Kick a player.
|
||||
WOLFA STOP - Stop a game forcibly.
|
||||
|
||||
And requires the werewolf.admin privilege.
|
||||
|
||||
=head1 DEPENDENCIES
|
||||
|
||||
This module depends on the following Auto module(s):
|
||||
|
||||
=over
|
||||
|
||||
=item Werewolf
|
||||
|
||||
The Werewolf module provides the game that this module provides administrative
|
||||
commands for. Using this module without Werewolf will likely cause a fatal
|
||||
error.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
This module was written by Elijah Perrault.
|
||||
|
||||
This module is maintained by Xelhua Development Group.
|
||||
|
||||
=head1 LICENSE AND COPYRIGHT
|
||||
|
||||
This module is Copyright (C) 2010-2011, Xelhua Development Group.
|
||||
|
||||
This module is released under the same terms as Auto itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set ai et ts=4 sw=4:
|
||||
File renamed without changes.
Reference in new issue
Block a user