Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7902aba4c5 | ||
|
|
f3f58c8f94 | ||
|
|
c616931339 | ||
|
|
92c9a64793 | ||
|
|
cc1c8fd5bc | ||
|
|
ad799a32a2 | ||
|
|
35f58bf5b7 | ||
|
|
9ad245fc79 | ||
|
|
f9cafa11e7 | ||
|
|
6a7cf754cc | ||
|
|
24ab4aaf9a | ||
|
|
9ff384866e | ||
|
|
4eb157ad8e | ||
|
|
bec120c70f | ||
|
|
8898e74341 | ||
|
|
18a8752e28 | ||
|
|
27521072c5 | ||
|
|
01cc71d564 | ||
|
|
634a68b5f2 | ||
|
|
c330a59474 | ||
|
|
be43449e74 | ||
|
|
445b7e0db3 | ||
|
|
30d9e11f1f | ||
|
|
66c4b3441a | ||
|
|
ba6f7dba40 | ||
|
|
5f74bb3171 | ||
|
|
15f188edfb | ||
|
|
6e0263bcd8 | ||
|
|
411e08fd1c | ||
|
|
e93939d4cf | ||
|
|
88d7799569 | ||
|
|
234c8d1657 | ||
|
|
11dae6b927 | ||
|
|
897ad85615 | ||
|
|
96384f853a | ||
|
|
c5e0853cb1 |
No files matched your search
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
*.conf
|
auto.conf
|
||||||
build/*
|
build/*
|
||||||
*.swp
|
*.swp
|
||||||
|
autodoc/*
|
||||||
@@ -11,30 +11,21 @@
|
|||||||
The future of IRC bots is here! Xelhua gives to you, Auto 3.0, a new version of
|
The future of IRC bots is here! Xelhua gives to you, Auto 3.0, a new version of
|
||||||
the popular Auto IRC bot.
|
the popular Auto IRC bot.
|
||||||
|
|
||||||
In this alpha4 release, we have added:
|
In this alpha5 release, we have added:
|
||||||
|
|
||||||
* MySQL support.
|
* LinkTitle module for returning the page title of links sent to a channel.
|
||||||
* PostgreSQL support.
|
* Added core command MODLIST.
|
||||||
* A Greet module for greeting users on join.
|
* Added SEARCH and MORE to QDB. Amount of results returned at a time with
|
||||||
* IRC logchan functionality.
|
qdb_search_resnum in the config.
|
||||||
* Improved multilingual support.
|
|
||||||
* A ChanTopics module for advanced management of channel topics.
|
|
||||||
* buildmod now generates HTML and man(1) pages from a module's POD.
|
|
||||||
* server:ajoin now supports channel keys by spacing the name and key.
|
|
||||||
* A Dictionary module for looking up definitions of words.
|
|
||||||
* Heavily improved module API.
|
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
* Commands getting Permission denied even with incorrect prefix.
|
* Fixed a bug when viewing non-existent quotes.
|
||||||
* Program not properly shutting down if all IRC connections close.
|
* SEVERE: Fixed a bug that caused rehash to fail.
|
||||||
|
|
||||||
Incompatibilities:
|
Incompatibilities:
|
||||||
|
|
||||||
* Database: Changed structure of the `qdb` table. Modify the configuration
|
None
|
||||||
values in upgrade.pl then run it to upgrade the database.
|
|
||||||
* database:format is now required in the config.
|
|
||||||
* bantype is now required in the config.
|
|
||||||
|
|
||||||
We thank you for choosing Auto. Please remember that he is still in early
|
We thank you for choosing Auto. Please remember that he is still in early
|
||||||
development stages. But we hope we've piqued your interest, as Auto's upcoming
|
development stages. But we hope we've piqued your interest, as Auto's upcoming
|
||||||
@@ -44,4 +35,4 @@ there for everyone to use.
|
|||||||
Auto's goal is to create an efficient, stable and highly customizable IRC bot
|
Auto's goal is to create an efficient, stable and highly customizable IRC bot
|
||||||
in Perl. To offer an alternative to other platforms.
|
in Perl. To offer an alternative to other platforms.
|
||||||
|
|
||||||
Enjoy Auto 3.0.0 Alpha 4!
|
Enjoy Auto 3.0.0 Alpha 5!
|
||||||
@@ -5,8 +5,7 @@
|
|||||||
# Written in sh because the user may not have Perl...to run Auto....
|
# Written in sh because the user may not have Perl...to run Auto....
|
||||||
|
|
||||||
PID=bin/auto.pid
|
PID=bin/auto.pid
|
||||||
MODS="Mouse Class::Unload"
|
MODS="Class::Unload DBI"
|
||||||
EMODS="MIME::Base64 XML::Simple"
|
|
||||||
|
|
||||||
if [ "$1" = "start" ] ; then
|
if [ "$1" = "start" ] ; then
|
||||||
if [ -e $PID ]; then
|
if [ -e $PID ]; then
|
||||||
@@ -47,11 +46,8 @@ elif [ "$1" = "status" ]; then
|
|||||||
elif [ "$1" = "getmodules" ]; then
|
elif [ "$1" = "getmodules" ]; then
|
||||||
cpan -i $MODS
|
cpan -i $MODS
|
||||||
|
|
||||||
elif [ "$1" = "getextras" ]; then
|
|
||||||
cpan -i $EMODS
|
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Usage: auto (start|stop|rehash|status|getmodules|getextras)"
|
echo "Usage: auto (start|stop|rehash|status|getmodules)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# vim: set ai sw=4 ts=4:
|
# vim: set ai sw=4 ts=4:
|
||||||
@@ -33,7 +33,7 @@ BEGIN {
|
|||||||
}
|
}
|
||||||
use Lib::Auto;
|
use Lib::Auto;
|
||||||
use API::Std qw(conf_get err);
|
use API::Std qw(conf_get err);
|
||||||
use API::Log qw(println alog dbug);
|
use API::Log qw(alog dbug);
|
||||||
#use DB::Flatfile;
|
#use DB::Flatfile;
|
||||||
use Parser::Config;
|
use Parser::Config;
|
||||||
use Parser::Lang;
|
use Parser::Lang;
|
||||||
@@ -434,6 +434,7 @@ undef $it;
|
|||||||
API::Std::cmd_add('MODLOAD', 1, 'cfunc.modules', \%Core::Cmd::HELP_MODLOAD, \&Core::Cmd::cmd_modload);
|
API::Std::cmd_add('MODLOAD', 1, 'cfunc.modules', \%Core::Cmd::HELP_MODLOAD, \&Core::Cmd::cmd_modload);
|
||||||
API::Std::cmd_add('MODUNLOAD', 1, 'cfunc.modules', \%Core::Cmd::HELP_MODUNLOAD, \&Core::Cmd::cmd_modunload);
|
API::Std::cmd_add('MODUNLOAD', 1, 'cfunc.modules', \%Core::Cmd::HELP_MODUNLOAD, \&Core::Cmd::cmd_modunload);
|
||||||
API::Std::cmd_add('MODRELOAD', 1, 'cfunc.modules', \%Core::Cmd::HELP_MODRELOAD, \&Core::Cmd::cmd_modreload);
|
API::Std::cmd_add('MODRELOAD', 1, 'cfunc.modules', \%Core::Cmd::HELP_MODRELOAD, \&Core::Cmd::cmd_modreload);
|
||||||
|
API::Std::cmd_add('MODLIST', 1, 'cfunc.modules', \%Core::Cmd::HELP_MODLIST, \&Core::Cmd::cmd_modlist);
|
||||||
API::Std::cmd_add('SHUTDOWN', 2, 'cmd.shutdown', \%Core::Cmd::HELP_SHUTDOWN, \&Core::Cmd::cmd_shutdown);
|
API::Std::cmd_add('SHUTDOWN', 2, 'cmd.shutdown', \%Core::Cmd::HELP_SHUTDOWN, \&Core::Cmd::cmd_shutdown);
|
||||||
API::Std::cmd_add('RESTART', 2, 'cmd.restart', \%Core::Cmd::HELP_RESTART, \&Core::Cmd::cmd_restart);
|
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('REHASH', 2, 'cmd.rehash', \%Core::Cmd::HELP_REHASH, \&Core::Cmd::cmd_rehash);
|
||||||
|
|||||||
@@ -2,6 +2,20 @@ Auto IRC Bot 3.0: Change Log
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
3.0 Indev
|
3.0 Indev
|
||||||
|
===============================================================================
|
||||||
|
* Bug fix: Fixed broken rehash.
|
||||||
|
* Ignore PRIVMSG's if they're from an invalid source.
|
||||||
|
* Fixed an odd bug when viewing non-existent quotes.
|
||||||
|
* You can now define how many results are returned by QDB SEARCH/MORE at a
|
||||||
|
time with qdb_search_resnum in the config.
|
||||||
|
* Added SEARCH and MORE to QDB.
|
||||||
|
* Killed EMODS in the starter script and updated MODS
|
||||||
|
* Added core command MODLIST.
|
||||||
|
* Added command level 3 for logchan-only command.
|
||||||
|
* Added a LinkTitle module for getting the title of a web page posted in a
|
||||||
|
channel.
|
||||||
|
|
||||||
|
3.0 Alpha 4
|
||||||
===============================================================================
|
===============================================================================
|
||||||
* Added a Dictionary module for looking up definitions of words.
|
* Added a Dictionary module for looking up definitions of words.
|
||||||
* server:ajoin now supports channel keys by spacing the name and key.
|
* server:ajoin now supports channel keys by spacing the name and key.
|
||||||
|
|||||||
+3
-3
@@ -26,7 +26,7 @@ sub mod_init
|
|||||||
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.
|
# Check if this module is compatible with this version of Auto.
|
||||||
if ($autover ne '3.0.0a4') {
|
if ($autover ne '3.0.0a4' and $autover ne '3.0.0a5') {
|
||||||
API::Log::dbug('MODULES: Failed to load '.$name.': Incompatible with your version of Auto.');
|
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.');
|
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.'); }
|
||||||
@@ -115,12 +115,12 @@ sub cmd_add
|
|||||||
$cmd = uc $cmd;
|
$cmd = uc $cmd;
|
||||||
|
|
||||||
if (defined $API::Std::CMDS{$cmd}) { return; }
|
if (defined $API::Std::CMDS{$cmd}) { return; }
|
||||||
if ($lvl =~ m/[^0-2]/sm) { return; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
if ($lvl =~ m/[^0-3]/sm) { return; } ## no critic qw(RegularExpressions::RequireExtendedFormatting)
|
||||||
|
|
||||||
$API::Std::CMDS{$cmd}{lvl} = $lvl;
|
$API::Std::CMDS{$cmd}{lvl} = $lvl;
|
||||||
$API::Std::CMDS{$cmd}{help} = $help;
|
$API::Std::CMDS{$cmd}{help} = $help;
|
||||||
$API::Std::CMDS{$cmd}{priv} = $priv;
|
$API::Std::CMDS{$cmd}{priv} = $priv;
|
||||||
$API::Std::CMDS{$cmd}{sub} = $sub;
|
$API::Std::CMDS{$cmd}{'sub'} = $sub;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-1
@@ -125,9 +125,31 @@ sub cmd_modreload
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Help hash for MODLIST. Spanish, French and German needed.
|
||||||
|
our %HELP_MODLIST = (
|
||||||
|
'en' => "This will return a list of all currently loaded modules. \2Syntax:\2 MODLIST",
|
||||||
|
);
|
||||||
|
# MODLIST callback.
|
||||||
|
sub cmd_modlist
|
||||||
|
{
|
||||||
|
my ($src, undef) = @_;
|
||||||
|
|
||||||
|
# Iterate through all loaded modules.
|
||||||
|
my $str;
|
||||||
|
foreach (keys %API::Std::MODULE) {
|
||||||
|
$str .= ", \2$_\2 (v".$API::Std::MODULE{$_}{version}.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return it.
|
||||||
|
$str = substr $str, 2;
|
||||||
|
notice($src->{svr}, $src->{nick}, "\2Module List:\2 $str");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
# Help hash for SHUTDOWN. Spanish, French and German needed.
|
# Help hash for SHUTDOWN. Spanish, French and German needed.
|
||||||
our %HELP_SHUTDOWN = (
|
our %HELP_SHUTDOWN = (
|
||||||
'en' => 'This will send out shutdown notifications, quit all networks, flush the database then exit the program.',
|
'en' => "This will send out shutdown notifications, quit all networks, flush the database then exit the program. \2Syntax:\2 SHUTDOWN",
|
||||||
);
|
);
|
||||||
# SHUTDOWN callback.
|
# SHUTDOWN callback.
|
||||||
sub cmd_shutdown
|
sub cmd_shutdown
|
||||||
|
|||||||
+9
-8
@@ -4,11 +4,12 @@
|
|||||||
package Lib::Auto;
|
package Lib::Auto;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use feature qw(say);
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Sys::Hostname;
|
use Sys::Hostname;
|
||||||
use feature qw(switch);
|
use feature qw(switch);
|
||||||
use API::Std qw(hook_add conf_get err);
|
use API::Std qw(hook_add conf_get err);
|
||||||
use API::Log qw(println dbug alog);
|
use API::Log qw(dbug alog);
|
||||||
our $VERSION = 3.000000;
|
our $VERSION = 3.000000;
|
||||||
|
|
||||||
# Core events.
|
# Core events.
|
||||||
@@ -19,7 +20,7 @@ API::Std::event_add('on_rehash');
|
|||||||
sub checkver
|
sub checkver
|
||||||
{
|
{
|
||||||
if (!$Auto::NUC and Auto::RSTAGE ne 'd') {
|
if (!$Auto::NUC and Auto::RSTAGE ne 'd') {
|
||||||
println '* Connecting to update server...';
|
say '* Connecting to update server...';
|
||||||
my $uss = IO::Socket::INET->new(
|
my $uss = IO::Socket::INET->new(
|
||||||
'Proto' => 'tcp',
|
'Proto' => 'tcp',
|
||||||
'PeerAddr' => 'dist.xelhua.org',
|
'PeerAddr' => 'dist.xelhua.org',
|
||||||
@@ -37,11 +38,11 @@ sub checkver
|
|||||||
}
|
}
|
||||||
elsif ($v eq 'version') {
|
elsif ($v eq 'version') {
|
||||||
if (Auto::VER.q{.}.Auto::SVER.q{.}.Auto::REV.Auto::RSTAGE ne $c) {
|
if (Auto::VER.q{.}.Auto::SVER.q{.}.Auto::REV.Auto::RSTAGE ne $c) {
|
||||||
println('!!! NOTICE !!! Your copy of Auto is outdated. Current version: '.Auto::VER.q{.}.Auto::SVER.q{.}.Auto::REV.Auto::RSTAGE.' - Latest version: '.$c);
|
say('!!! NOTICE !!! Your copy of Auto is outdated. Current version: '.Auto::VER.q{.}.Auto::SVER.q{.}.Auto::REV.Auto::RSTAGE.' - Latest version: '.$c);
|
||||||
println('!!! NOTICE !!! You can get the latest Auto by downloading '.$dll);
|
say('!!! NOTICE !!! You can get the latest Auto by downloading '.$dll);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
println('* Auto is up-to-date.');
|
say('* Auto is up-to-date.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +55,7 @@ sub rehash
|
|||||||
my %newsettings = $Auto::CONF->parse or err(2, 'Failed to parse configuration file!', 0) and return;
|
my %newsettings = $Auto::CONF->parse or err(2, 'Failed to parse configuration file!', 0) and return;
|
||||||
|
|
||||||
# Check for required configuration values.
|
# Check for required configuration values.
|
||||||
my @REQCVALS = qw(locale expire_logs server fantasy_pf ratelimit database:format bantype);
|
my @REQCVALS = qw(locale expire_logs server fantasy_pf ratelimit bantype);
|
||||||
foreach my $REQCVAL (@REQCVALS) {
|
foreach my $REQCVAL (@REQCVALS) {
|
||||||
if (!defined $newsettings{$REQCVAL}) {
|
if (!defined $newsettings{$REQCVAL}) {
|
||||||
err(2, "Missing required configuration value: $REQCVAL", 0) and return;
|
err(2, "Missing required configuration value: $REQCVAL", 0) and return;
|
||||||
@@ -261,7 +262,7 @@ sub signal_perlwarn
|
|||||||
my ($warnmsg) = @_;
|
my ($warnmsg) = @_;
|
||||||
$warnmsg =~ s/(\n|\r)//xsmg;
|
$warnmsg =~ s/(\n|\r)//xsmg;
|
||||||
alog 'Perl Warning: '.$warnmsg;
|
alog 'Perl Warning: '.$warnmsg;
|
||||||
if ($Auto::DEBUG) { println 'Perl Warning: '.$warnmsg; }
|
if ($Auto::DEBUG) { say 'Perl Warning: '.$warnmsg; }
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +277,7 @@ sub signal_perldie
|
|||||||
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');
|
API::Std::event_run('on_shutdown');
|
||||||
sleep 1;
|
sleep 1;
|
||||||
println 'FATAL: '.$diemsg;
|
say 'FATAL: '.$diemsg;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+29
-4
@@ -303,12 +303,12 @@ sub cjoin
|
|||||||
|
|
||||||
# Check if this is coming from ourselves.
|
# Check if this is coming from ourselves.
|
||||||
if ($src{nick} eq $botnick{$svr}{nick}) {
|
if ($src{nick} eq $botnick{$svr}{nick}) {
|
||||||
$botchans{$svr}{lc(substr $ex[2], 1)} = 1;
|
$botchans{$svr}{lc $chan} = 1;
|
||||||
API::Std::event_run("on_ucjoin", ($svr, $chan));
|
API::Std::event_run("on_ucjoin", ($svr, $chan));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# It isn't. Update chanusers and trigger on_rcjoin.
|
# It isn't. Update chanusers and trigger on_rcjoin.
|
||||||
$chanusers{$svr}{lc(substr $ex[2], 1)}{$src{nick}} = 1;
|
$chanusers{$svr}{lc $chan}{$src{nick}} = 1;
|
||||||
$src{svr} = $svr;
|
$src{svr} = $svr;
|
||||||
API::Std::event_run("on_rcjoin", (\%src, $chan));
|
API::Std::event_run("on_rcjoin", (\%src, $chan));
|
||||||
}
|
}
|
||||||
@@ -532,6 +532,9 @@ sub privmsg
|
|||||||
my ($svr, @ex) = @_;
|
my ($svr, @ex) = @_;
|
||||||
my %data = API::IRC::usrc(substr($ex[0], 1));
|
my %data = API::IRC::usrc(substr($ex[0], 1));
|
||||||
|
|
||||||
|
# Ensure this is coming from a user rather than a server.
|
||||||
|
if ($ex[0] !~ m/!/xsm) { return; }
|
||||||
|
|
||||||
my @argv;
|
my @argv;
|
||||||
for (my $i = 4; $i < scalar(@ex); $i++) {
|
for (my $i = 4; $i < scalar(@ex); $i++) {
|
||||||
push(@argv, $ex[$i]);
|
push(@argv, $ex[$i]);
|
||||||
@@ -603,12 +606,12 @@ sub privmsg
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Else give them the boot.
|
# Else give them the boot.
|
||||||
API::IRC::notice($data{svr}, $data{nick}, API::Std::trans("Permission denied").".");
|
API::IRC::notice($data{svr}, $data{nick}, API::Std::trans('Permission denied').q{.});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# Else continue executing without any extra checks.
|
# Else continue executing without any extra checks.
|
||||||
&{ $API::Std::CMDS{$cmd}{'sub'} }(\%data, @argv) if $rprefix eq $cprefix;
|
&{ $API::Std::CMDS{$cmd}{'sub'} }(\%data, @argv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -616,6 +619,28 @@ sub privmsg
|
|||||||
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
|
API::IRC::notice($data{svr}, $data{nick}, trans('Rate limit exceeded').q{.});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ($API::Std::CMDS{$cmd}{lvl} == 3) {
|
||||||
|
# Or if it's a logchan command...
|
||||||
|
my ($lcn, $lcc) = split '/', (conf_get('logchan'))[0][0];
|
||||||
|
if ($lcn eq $data{svr} and lc $lcc eq lc $data{chan}) {
|
||||||
|
# Check if it's being sent from the logchan.
|
||||||
|
if ($API::Std::CMDS{$cmd}{priv}) {
|
||||||
|
# If this command takes a privilege...
|
||||||
|
if (API::Std::has_priv(API::Std::match_user(%data), $API::Std::CMDS{$cmd}{priv})) {
|
||||||
|
# Make sure they have it.
|
||||||
|
&{ $API::Std::CMDS{$cmd}{'sub'} }(\%data, @argv);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Else give them the boot.
|
||||||
|
API::IRC::notice($data{svr}, $data{nick}, API::Std::trans('Permission denied').q{.});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Else continue executing without any extra checks.
|
||||||
|
&{ $API::Std::CMDS{$cmd}{'sub'} }(\%data, @argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
# Module: LinkTitle. 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::LinkTitle;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use LWP::UserAgent;
|
||||||
|
use HTML::Entities;
|
||||||
|
use API::Std qw(hook_add hook_del);
|
||||||
|
use API::IRC qw(privmsg);
|
||||||
|
|
||||||
|
# Initialization subroutine.
|
||||||
|
sub _init
|
||||||
|
{
|
||||||
|
# Create the on_cprivmsg hook.
|
||||||
|
hook_add('on_cprivmsg', 'privmsg.html.returntitle', \&M::LinkTitle::gettitle) or return;
|
||||||
|
|
||||||
|
# Success.
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Void subroutine.
|
||||||
|
sub _void
|
||||||
|
{
|
||||||
|
# Delete the hook we created.
|
||||||
|
hook_del('on_cprivmsg', 'privmsg.html.returntitle') or return;
|
||||||
|
|
||||||
|
# Success.
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Hook callback.
|
||||||
|
sub gettitle
|
||||||
|
{
|
||||||
|
my ($src, $chan, @msg) = @_;
|
||||||
|
|
||||||
|
# Check if the message contains a URL.
|
||||||
|
foreach my $smw (@msg) {
|
||||||
|
if ($smw =~ m{(http|https)://}xsm) {
|
||||||
|
# We've got a match, connect to the server.
|
||||||
|
my $srv = $1;
|
||||||
|
# Create an instance of LWP::UserAgent.
|
||||||
|
my $ua = LWP::UserAgent->new();
|
||||||
|
$ua->agent('Auto IRC Bot');
|
||||||
|
$ua->timeout(3);
|
||||||
|
# Get data.
|
||||||
|
my $res = $ua->get($smw);
|
||||||
|
|
||||||
|
# Check if we're successful.
|
||||||
|
if ($res->is_success) {
|
||||||
|
# We were, decode the data.
|
||||||
|
my $data = $res->decoded_content;
|
||||||
|
|
||||||
|
# Check for <title>
|
||||||
|
if ($data =~ m{<title>(.*)</title>}ixsm) {
|
||||||
|
# Found. Decode it.
|
||||||
|
my $title = decode_entities($1);
|
||||||
|
# Return to channel.
|
||||||
|
privmsg($src->{svr}, $chan, "\2Title:\2 $title");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Start initialization.
|
||||||
|
API::Std::mod_init('LinkTitle', 'Xelhua', '1.00', '3.0.0a5', __PACKAGE__);
|
||||||
|
# vim: set ai sw=4 ts=4:
|
||||||
|
# build: cpan=LWP::UserAgent,HTML::Entities perl=5.010000
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
LinkTitle - A module for returning the page title of links.
|
||||||
|
|
||||||
|
=head1 VERSION
|
||||||
|
|
||||||
|
1.00
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
<starcoder> http://xelhua.org/auto.php
|
||||||
|
<blue> Title: Xelhua / Projects / Auto
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
This module will make Auto parse all links sent to a channel. When a link is
|
||||||
|
detected, Auto will connect to it and get the page title by scanning for the
|
||||||
|
<title> tag and returning its contents to the channel.
|
||||||
|
|
||||||
|
=head1 DEPENDENCIES
|
||||||
|
|
||||||
|
This module is dependent on two modules from the CPAN.
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item L<LWP::UserAgent|LWP::UserAgent>
|
||||||
|
|
||||||
|
This module is used for connecting to the target web server via HTTP(S).
|
||||||
|
|
||||||
|
=item L<HTML::Entities|HTML::Entities>
|
||||||
|
|
||||||
|
This module is used for decoding HTML entities in the response we receive from
|
||||||
|
the server.
|
||||||
|
|
||||||
|
=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. All rights
|
||||||
|
reserved.
|
||||||
|
|
||||||
|
This module is released under the same licensing terms as Auto itself.
|
||||||
+112
-24
@@ -5,8 +5,9 @@ package M::QDB;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use feature qw(switch);
|
use feature qw(switch);
|
||||||
use API::Std qw(cmd_add cmd_del trans has_priv match_user);
|
use API::Std qw(cmd_add cmd_del trans has_priv conf_get match_user);
|
||||||
use API::IRC qw(privmsg notice);
|
use API::IRC qw(privmsg notice);
|
||||||
|
our @BUFFER;
|
||||||
|
|
||||||
sub _init
|
sub _init
|
||||||
{
|
{
|
||||||
@@ -34,7 +35,7 @@ sub _void
|
|||||||
|
|
||||||
# Help hash for QDB. Spanish, French and German translations needed.
|
# Help hash for QDB. Spanish, French and German translations needed.
|
||||||
our %HELP_QDB = (
|
our %HELP_QDB = (
|
||||||
'en' => "This command allows you to add, read, and delete quotes. \002Syntax:\002 QDB (ADD|VIEW|COUNT|RAND|DEL) [quote]",
|
'en' => "This command allows you to add, read, and delete quotes. \002Syntax:\002 QDB (ADD|VIEW|COUNT|RAND|SEARCH|MORE|DEL) [quote|expression]",
|
||||||
);
|
);
|
||||||
sub cmd_qdb
|
sub cmd_qdb
|
||||||
{
|
{
|
||||||
@@ -46,7 +47,7 @@ sub cmd_qdb
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ADD|VIEW|COUNT|RAND|DEL.
|
# ADD|VIEW|COUNT|RAND|SEARCH|MORE|DEL.
|
||||||
given (uc $argv[0]) {
|
given (uc $argv[0]) {
|
||||||
when ('ADD') {
|
when ('ADD') {
|
||||||
# QDB ADD.
|
# QDB ADD.
|
||||||
@@ -55,13 +56,10 @@ sub cmd_qdb
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get rid of the ADD part.
|
|
||||||
shift @argv;
|
|
||||||
|
|
||||||
# Insert into database.
|
# Insert into database.
|
||||||
my $dbq = $Auto::DB->prepare('INSERT INTO qdb (creator, time, quote) VALUES (?, ?, ?)') or
|
my $dbq = $Auto::DB->prepare('INSERT INTO qdb (creator, time, quote) VALUES (?, ?, ?)') or
|
||||||
notice($src->{svr}, $src->{nick}, trans('An error occurred').q{.}) and return;
|
notice($src->{svr}, $src->{nick}, trans('An error occurred').q{.}) and return;
|
||||||
$dbq->execute($src->{nick}, time, join(q{ }, @argv)) or
|
$dbq->execute($src->{nick}, time, join(q{ }, @argv[1..$#argv])) or
|
||||||
notice($src->{svr}, $src->{nick}, trans('An error occurred').q{.}) and return;
|
notice($src->{svr}, $src->{nick}, trans('An error occurred').q{.}) and return;
|
||||||
|
|
||||||
# Get ID.
|
# Get ID.
|
||||||
@@ -83,6 +81,9 @@ sub cmd_qdb
|
|||||||
$dbq->execute($argv[1]) or notice($src->{svr}, $src->{nick}, trans('An error occurred').'. Quote might not exist.') and return;
|
$dbq->execute($argv[1]) or notice($src->{svr}, $src->{nick}, trans('An error occurred').'. Quote might not exist.') and return;
|
||||||
my @data = $dbq->fetchrow_array;
|
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; }
|
||||||
|
|
||||||
# Send it back.
|
# 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}, "\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]);
|
||||||
@@ -114,6 +115,78 @@ sub cmd_qdb
|
|||||||
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}, "\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.
|
||||||
|
|
||||||
|
# Get all quotes.
|
||||||
|
my $dbq = $Auto::DB->prepare('SELECT * FROM qdb') or return;
|
||||||
|
$dbq->execute or return;
|
||||||
|
my $quotes = $dbq->fetchall_hashref('quoteid') or return;
|
||||||
|
|
||||||
|
# Set expression.
|
||||||
|
my $expr = my $rexpr = join ' ', @argv[1 .. $#argv];
|
||||||
|
$rexpr =~ s{\(}{\\\(}g;
|
||||||
|
$rexpr =~ s{\)}{\\\)}g;
|
||||||
|
$rexpr =~ s{\?}{\\\?}g;
|
||||||
|
$rexpr =~ s{\*}{\\\*}g;
|
||||||
|
$rexpr =~ s{\[}{\\\[}g;
|
||||||
|
$rexpr =~ s{\]}{\\\]}g;
|
||||||
|
$rexpr =~ s{\.}{\\\.}g;
|
||||||
|
$rexpr =~ s{\$}{\\\$}g;
|
||||||
|
$rexpr =~ s{\^}{\\\^}g;
|
||||||
|
|
||||||
|
# Clear the buffer.
|
||||||
|
@BUFFER = ();
|
||||||
|
|
||||||
|
# Iterate through all quotes.
|
||||||
|
foreach my $qkt (keys %$quotes) {
|
||||||
|
# Check if we have a match.
|
||||||
|
if ($quotes->{$qkt}->{quote} =~ m/$rexpr/ixsm) {
|
||||||
|
# Match. Add to buffer.
|
||||||
|
push @BUFFER, "\2ID:\2 $qkt - ".$quotes->{$qkt}->{quote};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if we had any matches.
|
||||||
|
if (!defined $BUFFER[0]) {
|
||||||
|
privmsg($src->{svr}, $src->{chan}, "No results for \2$expr\2.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return four quotes.
|
||||||
|
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; }
|
||||||
|
while ($i <= $si) {
|
||||||
|
if (!defined $BUFFER[0]) {
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
|
privmsg($src->{svr}, $src->{chan}, shift @BUFFER);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
when ('MORE') {
|
||||||
|
# Check if there's any quotes in the buffer.
|
||||||
|
if (!defined $BUFFER[0]) {
|
||||||
|
notice($src->{svr}, $src->{nick}, 'No quotes in buffer.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return four quotes.
|
||||||
|
my $i = 0;
|
||||||
|
my $si = 3;
|
||||||
|
if (conf_get('qdb_search_resnum')) { $si = (conf_get('qdb_search_resnum'))[0][0] - 1; }
|
||||||
|
while ($i <= $si) {
|
||||||
|
if (!defined $BUFFER[0]) {
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
|
privmsg($src->{svr}, $src->{chan}, shift @BUFFER);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
when ('DEL') {
|
when ('DEL') {
|
||||||
# Check for the cmd.qdbdel privilege.
|
# Check for the cmd.qdbdel privilege.
|
||||||
if (!has_priv(match_user(%$src), 'cmd.qdbdel')) {
|
if (!has_priv(match_user(%$src), 'cmd.qdbdel')) {
|
||||||
@@ -138,37 +211,52 @@ sub cmd_qdb
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
API::Std::mod_init('QDB', 'Xelhua', '1.00', '3.0.0a4', __PACKAGE__);
|
API::Std::mod_init('QDB', 'Xelhua', '1.02', '3.0.0a4', __PACKAGE__);
|
||||||
# vim: set ai sw=4 ts=4:
|
# vim: set ai sw=4 ts=4:
|
||||||
# build: perl=5.010000
|
# build: perl=5.010000
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
=head1 QDB
|
=head1 NAME
|
||||||
|
|
||||||
=head2 Description
|
QDB - Quote database module.
|
||||||
|
|
||||||
=over
|
=head1 VERSION
|
||||||
|
|
||||||
This module adds the QDB (ADD|VIEW|COUNT|RAND|DEL) command, for adding,
|
1.02
|
||||||
viewing, listing number of, viewing a random, deleting a quote from the Auto
|
|
||||||
database.
|
|
||||||
|
|
||||||
=back
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
=head2 Examples
|
|
||||||
|
|
||||||
=over
|
|
||||||
|
|
||||||
<JohnSmith> !qdb add <JohnDoe> moocows
|
<JohnSmith> !qdb add <JohnDoe> moocows
|
||||||
<Auto> Quote successfully submitted. ID: 732
|
<Auto> Quote successfully submitted. ID: 732
|
||||||
|
|
||||||
=back
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
=head2 Technical
|
This module adds the QDB (ADD|VIEW|COUNT|RAND|SEARCH|MORE|DEL) command, for
|
||||||
|
adding, viewing, listing number of, viewing a random, deleting a quote from the
|
||||||
|
Auto database.
|
||||||
|
|
||||||
=over
|
=head1 INSTALL
|
||||||
|
|
||||||
This module is compatible with Auto v3.0.0a4+.
|
Before using QDB, we'd recommend adding the following to your configuration
|
||||||
|
file:
|
||||||
|
|
||||||
=back
|
qdb_search_resnum <number>;
|
||||||
|
|
||||||
|
Where <number> is the amount of results returned per SEARCH/MORE load.
|
||||||
|
|
||||||
|
This is not required, 4 will be used if it is not specified.
|
||||||
|
|
||||||
|
=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
|
||||||
Reference in new issue
Block a user