Skip to content

Commit

Permalink
[rt.cpan.org 85315] Make cver optional.
Browse files Browse the repository at this point in the history
Per Axel Beckert's recommendation, the IRC version string is made
optinoal and will default to the module's current version info.  cver
can still be overridden in the .conf file, and all existing
installations will continue to work the way they always have.
  • Loading branch information
rcaputo committed Jul 13, 2013
1 parent cfdfcc4 commit 6472f72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 6 additions & 6 deletions examples/pastebot.conf
Expand Up @@ -2,29 +2,29 @@
# you see here.

web_server
iface 10.0.0.201
ifname 10.0.0.201
iname http://10.0.0.201:8888/
iface 10.0.0.5
ifname 10.0.0.5
iname http://10.0.0.5:8888/
irc internal_irc
name internal_web
port 8888
static ./static

irc
away saving humanity from evil paste
ccinfo ACTION VERSION CLIENTINFO USERINFO
channel pastebot
channel poe
cuinfo owned and operated by rcaputo <rcaputo@cpan.org>
cver pastebot 1.0 <http://thirdlobe.com/projects/pastebot/>
flags +i
iname http://10.0.0.201:8888/
iname http://10.0.0.5:8888/
join_cfg_only 1
name internal_irc
nick pastebot
quit how will you live without me?
server 10.0.0.25 6667
uname pastebot
localaddr 10.0.0.201
localaddr 10.0.0.5

pastes
check 3600
Expand Down
13 changes: 11 additions & 2 deletions lib/Bot/Pastebot/Client/Irc.pm
@@ -1,4 +1,5 @@
# Rocco's IRC bot stuff.
# vim: expandtab

package Bot::Pastebot::Client::Irc;

Expand Down Expand Up @@ -83,7 +84,7 @@ my %conf = (
channel => LIST | REQUIRED,
quit => SCALAR | REQUIRED,
cuinfo => SCALAR | REQUIRED,
cver => SCALAR | REQUIRED,
cver => SCALAR,
ccinfo => SCALAR | REQUIRED,
localaddr => SCALAR,
use_ssl => SCALAR,
Expand All @@ -109,6 +110,14 @@ sub initialize {
foreach my $server (get_names_by_type('irc')) {
my %conf = get_items_by_name($server);

my $version_string = $conf{cver};
unless (defined $version_string and length $version_string) {
$version_string = (
"Bot::Pastebot $main::VERSION " .
"<https://github.com/rcaputo/bot-pastebot>"
);
}

my $web_alias = $irc_to_web{$server};
my $irc = POE::Component::IRC::State->spawn();

Expand Down Expand Up @@ -402,7 +411,7 @@ sub initialize {
my ($kernel, $sender) = @_[KERNEL, ARG0];
my $who = (split /!/, $sender)[0];
print "ctcp version from $who\n";
$irc->yield( ctcpreply => $who, "VERSION $conf{cver}" );
$irc->yield( ctcpreply => $who, "VERSION $version_string" );
},

irc_ctcp_clientinfo => sub {
Expand Down

0 comments on commit 6472f72

Please sign in to comment.