3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 11:12:42 +01:00

Simplify arguments for IRC handlers

This commit is contained in:
Pragmatic Software 2023-01-31 05:44:34 -08:00
parent 441e858a84
commit 6240aee0a0
30 changed files with 300 additions and 273 deletions

View File

@ -6,7 +6,7 @@
# The nickserv/ban-evasion stuff probably ought to be in BanTracker or some # The nickserv/ban-evasion stuff probably ought to be in BanTracker or some
# such suitable class. # such suitable class.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::AntiFlood; package PBot::Core::AntiFlood;
@ -845,7 +845,7 @@ sub check_bans {
sub on_endofwhois { sub on_endofwhois {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $nick = $event->{event}->{args}[1]; my $nick = $event->{args}[1];
delete $self->{whois_pending}->{$nick}; delete $self->{whois_pending}->{$nick};
@ -869,8 +869,8 @@ sub on_endofwhois {
sub on_whoisuser { sub on_whoisuser {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $nick = $event->{event}->{args}[1]; my $nick = $event->{args}[1];
my $gecos = lc $event->{event}->{args}[5]; my $gecos = lc $event->{args}[5];
my ($id) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($nick); my ($id) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($nick);
@ -881,8 +881,8 @@ sub on_whoisuser {
sub on_whoisaccount { sub on_whoisaccount {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $nick = $event->{event}->{args}[1]; my $nick = $event->{args}[1];
my $account = lc $event->{event}->{args}[2]; my $account = lc $event->{args}[2];
$self->{pbot}->{logger}->log("[MH] $nick is using NickServ account [$account]\n"); $self->{pbot}->{logger}->log("[MH] $nick is using NickServ account [$account]\n");
@ -902,9 +902,9 @@ sub on_whoisaccount {
sub on_accountnotify { sub on_accountnotify {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $mask = $event->{event}->{from}; my $mask = $event->{from};
my ($nick, $user, $host) = $mask =~ m/^([^!]+)!([^@]+)@(.*)/; my ($nick, $user, $host) = $mask =~ m/^([^!]+)!([^@]+)@(.*)/;
my $account = $event->{event}{args}[0]; my $account = $event->{args}[0];
my $id = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host); my $id = $self->{pbot}->{messagehistory}->{database}->get_message_account($nick, $user, $host);
$self->{pbot}->{messagehistory}->{database}->update_hostmask_data($mask, {last_seen => scalar gettimeofday}); $self->{pbot}->{messagehistory}->{database}->update_hostmask_data($mask, {last_seen => scalar gettimeofday});

View File

@ -90,7 +90,7 @@ sub initialize {
sub on_inviting { sub on_inviting {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($botnick, $target, $channel) = $event->{event}->args; my ($botnick, $target, $channel) = $event->args;
$self->{pbot}->{logger}->log("User $target invited to channel $channel.\n"); $self->{pbot}->{logger}->log("User $target invited to channel $channel.\n");
@ -107,7 +107,7 @@ sub on_inviting {
sub on_useronchannel { sub on_useronchannel {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($botnick, $target, $channel) = $event->{event}->args; my ($botnick, $target, $channel) = $event->args;
$self->{pbot}->{logger}->log("User $target is already on channel $channel.\n"); $self->{pbot}->{logger}->log("User $target is already on channel $channel.\n");
@ -124,7 +124,7 @@ sub on_useronchannel {
sub on_nosuchnick { sub on_nosuchnick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($botnick, $target, $msg) = $event->{event}->args; my ($botnick, $target, $msg) = $event->args;
$self->{pbot}->{logger}->log("$target: $msg\n"); $self->{pbot}->{logger}->log("$target: $msg\n");

View File

@ -30,14 +30,15 @@ sub initialize {
# NickList reserves 0 and 100 to ensure its list is populated by JOINs, etc, # NickList reserves 0 and 100 to ensure its list is populated by JOINs, etc,
# before any handlers need to consult its list, or depopulated by PARTs, QUITs, # before any handlers need to consult its list, or depopulated by PARTs, QUITs,
# KICKs, etc, after any other handlers need to consult its list. # KICKs, etc, after any other handlers need to consult its list.
sub register_handler { sub register_handler {
my ($self, $event_name, $subref, $priority) = @_; my ($self, $name, $subref, $priority) = @_;
# get the package of the calling subroutine # get the package of the calling subroutine
my ($package) = caller(0); my ($package) = caller(0);
# internal identifier to find calling package's event handler # internal identifier to find calling package's event handler
my $handler_id = "$package-$event_name"; my $handler_id = "$package-$name";
my $entry = { my $entry = {
priority => $priority // 50, priority => $priority // 50,
@ -46,12 +47,12 @@ sub register_handler {
}; };
# create new priority-queue for event-name if one doesn't exist # create new priority-queue for event-name if one doesn't exist
if (not exists $self->{handlers}->{$event_name}) { if (not exists $self->{handlers}->{$name}) {
$self->{handlers}->{$event_name} = PBot::Core::Utils::PriorityQueue->new(pbot => $self->{pbot}); $self->{handlers}->{$name} = PBot::Core::Utils::PriorityQueue->new(pbot => $self->{pbot});
} }
# add the event handler # add the event handler
$self->{handlers}->{$event_name}->add($entry); $self->{handlers}->{$name}->add($entry);
# debugging # debugging
if ($self->{pbot}->{registry}->get_value('eventdispatcher', 'debug')) { if ($self->{pbot}->{registry}->get_value('eventdispatcher', 'debug')) {
@ -61,17 +62,17 @@ sub register_handler {
# remove an event handler # remove an event handler
sub remove_handler { sub remove_handler {
my ($self, $event_name) = @_; my ($self, $name) = @_;
# get the package of the calling subroutine # get the package of the calling subroutine
my ($package) = caller(0); my ($package) = caller(0);
# internal identifier to find calling package's event handler # internal identifier to find calling package's event handler
my $handler_id = "$package-$event_name"; my $handler_id = "$package-$name";
# remove the event handler # remove the event handler
if (exists $self->{handlers}->{$event_name}) { if (exists $self->{handlers}->{$name}) {
my $handlers = $self->{handlers}->{$event_name}; my $handlers = $self->{handlers}->{$name};
for (my $i = 0; $i < $handlers->count; $i++) { for (my $i = 0; $i < $handlers->count; $i++) {
my $handler = $handlers->get($i); my $handler = $handlers->get($i);
@ -82,8 +83,8 @@ sub remove_handler {
} }
# remove root event-name key if it has no more handlers # remove root event-name key if it has no more handlers
if (not $self->{handlers}->{$event_name}->count) { if (not $self->{handlers}->{$name}->count) {
delete $self->{handlers}->{$event_name}; delete $self->{handlers}->{$name};
} }
} }
@ -95,7 +96,7 @@ sub remove_handler {
# send an event to its handlers # send an event to its handlers
sub dispatch_event { sub dispatch_event {
my ($self, $event_name, $event_data) = @_; my ($self, $name, $data) = @_;
# debugging flag # debugging flag
my $debug = $self->{pbot}->{registry}->get_value('eventdispatcher', 'debug') // 0; my $debug = $self->{pbot}->{registry}->get_value('eventdispatcher', 'debug') // 0;
@ -104,17 +105,17 @@ sub dispatch_event {
my $dispatch_result= undef; my $dispatch_result= undef;
# if the event-name has handlers # if the event-name has handlers
if (exists $self->{handlers}->{$event_name}) { if (exists $self->{handlers}->{$name}) {
# then dispatch the event to each one # then dispatch the event to each one
foreach my $handler ($self->{handlers}->{$event_name}->entries) { foreach my $handler ($self->{handlers}->{$name}->entries) {
# debugging # debugging
if ($debug) { if ($debug) {
$self->{pbot}->{logger}->log("Dispatching $event_name to handler $handler->{id}\n"); $self->{pbot}->{logger}->log("Dispatching $name to handler $handler->{id}\n");
} }
# invoke an event handler. a handler may return undef to indicate # invoke an event handler. a handler may return undef to indicate
# that it decided not to handle this event. # that it decided not to handle this event.
my $handler_result = eval { $handler->{subref}->($event_name, $event_data) }; my $handler_result = eval { $handler->{subref}->($name, $data) };
# check for exception # check for exception
if (my $exception = $@) { if (my $exception = $@) {

View File

@ -3,7 +3,7 @@
# Purpose: Populates and maintains channel banlists by checking mode +b/+q # Purpose: Populates and maintains channel banlists by checking mode +b/+q
# when joining channels and by tracking modes +b/+q and -b/-q in channels. # when joining channels and by tracking modes +b/+q and -b/-q in channels.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::BanList; package PBot::Core::Handlers::BanList;
@ -30,7 +30,7 @@ sub initialize {
sub on_endofnames { sub on_endofnames {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $channel = lc $event->{event}->{args}[1]; my $channel = lc $event->{args}[1];
$self->{pbot}->{logger}->log("Retrieving banlist for $channel.\n"); $self->{pbot}->{logger}->log("Retrieving banlist for $channel.\n");
@ -52,10 +52,10 @@ sub on_endofnames {
sub on_banlist_entry { sub on_banlist_entry {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $channel = lc $event->{event}->{args}[1]; my $channel = lc $event->{args}[1];
my $target = lc $event->{event}->{args}[2]; my $target = lc $event->{args}[2];
my $source = lc $event->{event}->{args}[3]; my $source = lc $event->{args}[3];
my $timestamp = $event->{event}->{args}[4]; my $timestamp = $event->{args}[4];
my $ago = concise ago(gettimeofday - $timestamp); my $ago = concise ago(gettimeofday - $timestamp);
$self->{pbot}->{logger}->log("Ban List: [banlist entry] $channel: $target banned by $source $ago.\n"); $self->{pbot}->{logger}->log("Ban List: [banlist entry] $channel: $target banned by $source $ago.\n");
@ -66,10 +66,10 @@ sub on_banlist_entry {
sub on_quietlist_entry { sub on_quietlist_entry {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $channel = lc $event->{event}->{args}[1]; my $channel = lc $event->{args}[1];
my $target = lc $event->{event}->{args}[3]; my $target = lc $event->{args}[3];
my $source = lc $event->{event}->{args}[4]; my $source = lc $event->{args}[4];
my $timestamp = $event->{event}->{args}[5]; my $timestamp = $event->{args}[5];
my $ago = concise ago(gettimeofday - $timestamp); my $ago = concise ago(gettimeofday - $timestamp);
$self->{pbot}->{logger}->log("Ban List: [quietlist entry] $channel: $target quieted by $source $ago.\n"); $self->{pbot}->{logger}->log("Ban List: [quietlist entry] $channel: $target quieted by $source $ago.\n");
@ -80,7 +80,7 @@ sub on_quietlist_entry {
sub on_endofbanlist { sub on_endofbanlist {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $channel = lc $event->{event}->{args}[1]; my $channel = lc $event->{args}[1];
# first check for saved bans no longer in channel # first check for saved bans no longer in channel
foreach my $mask ($self->{pbot}->{banlist}->{banlist}->get_keys($channel)) { foreach my $mask ($self->{pbot}->{banlist}->{banlist}->get_keys($channel)) {
@ -142,7 +142,7 @@ sub on_endofbanlist {
sub on_endofquietlist { sub on_endofquietlist {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $channel = lc $event->{event}->{args}[1]; my $channel = lc $event->{args}[1];
my $mute_char = $self->{mute_char}; my $mute_char = $self->{mute_char};

View File

@ -2,7 +2,7 @@
# #
# Purpose: Handles IRCv3 CAP event. # Purpose: Handles IRCv3 CAP event.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::Cap; package PBot::Core::Handlers::Cap;
@ -24,17 +24,17 @@ sub initialize {
sub on_cap { sub on_cap {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
if ($event->{event}->{args}->[0] eq 'LS') { if ($event->{args}[0] eq 'LS') {
my $capabilities; my $capabilities;
my $caps_listed = 0; my $caps_listed = 0;
if ($event->{event}->{args}->[1] eq '*') { if ($event->{args}[1] eq '*') {
# more CAP LS messages coming # more CAP LS messages coming
$capabilities = $event->{event}->{args}->[2]; $capabilities = $event->{args}[2];
} else { } else {
# final CAP LS message # final CAP LS message
$caps_listed = 1; $caps_listed = 1;
$capabilities = $event->{event}->{args}->[1]; $capabilities = $event->{args}[1];
} }
$self->{pbot}->{logger}->log("Client capabilities available: $capabilities\n"); $self->{pbot}->{logger}->log("Client capabilities available: $capabilities\n");
@ -57,10 +57,10 @@ sub on_cap {
$self->request_caps($event); $self->request_caps($event);
} }
} }
elsif ($event->{event}->{args}->[0] eq 'ACK') { elsif ($event->{args}[0] eq 'ACK') {
$self->{pbot}->{logger}->log("Client capabilities granted: $event->{event}->{args}->[1]\n"); $self->{pbot}->{logger}->log("Client capabilities granted: $event->{args}[1]\n");
my @caps = split /\s+/, $event->{event}->{args}->[1]; my @caps = split /\s+/, $event->{args}[1];
foreach my $cap (@caps) { foreach my $cap (@caps) {
my ($key, $val) = split '=', $cap; my ($key, $val) = split '=', $cap;
@ -76,8 +76,8 @@ sub on_cap {
} }
} }
} }
elsif ($event->{event}->{args}->[0] eq 'NAK') { elsif ($event->{args}[0] eq 'NAK') {
$self->{pbot}->{logger}->log("Client capabilities rejected: $event->{event}->{args}->[1]\n"); $self->{pbot}->{logger}->log("Client capabilities rejected: $event->{args}[1]\n");
} }
else { else {
$self->{pbot}->{logger}->log("Unknown CAP event:\n"); $self->{pbot}->{logger}->log("Unknown CAP event:\n");

View File

@ -3,7 +3,7 @@
# Purpose: Handlers for general channel-related IRC events that aren't handled # Purpose: Handlers for general channel-related IRC events that aren't handled
# by any specialized Handler modules. # by any specialized Handler modules.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::Channel; package PBot::Core::Handlers::Channel;
@ -36,11 +36,11 @@ sub on_mode {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $mode_string, $channel) = ( my ($nick, $user, $host, $mode_string, $channel) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->{args}->[0], $event->{args}[0],
lc $event->{event}->{to}->[0], lc $event->{to}[0],
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
@ -60,7 +60,7 @@ sub on_mode {
} }
$mode = $modifier . $flag; $mode = $modifier . $flag;
$target = $event->{event}->{args}->[++$i]; $target = $event->{args}[++$i];
$self->{pbot}->{logger}->log("[MODE] $channel $mode" . (length $target ? " $target" : '') . " by $source\n"); $self->{pbot}->{logger}->log("[MODE] $channel $mode" . (length $target ? " $target" : '') . " by $source\n");
@ -112,10 +112,10 @@ sub on_join {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ( my ($nick, $user, $host, $channel) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
lc $event->{event}->{to}->[0], lc $event->{to}[0],
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
@ -131,8 +131,8 @@ sub on_join {
# IRCv3 extended-join capability provides more details about user # IRCv3 extended-join capability provides more details about user
if (exists $self->{pbot}->{irc_capabilities}->{'extended-join'}) { if (exists $self->{pbot}->{irc_capabilities}->{'extended-join'}) {
my ($nickserv, $gecos) = ( my ($nickserv, $gecos) = (
$event->{event}->{args}->[0], $event->{args}[0],
$event->{event}->{args}->[1], $event->{args}[1],
); );
$msg .= " $nickserv :$gecos"; $msg .= " $nickserv :$gecos";
@ -147,7 +147,7 @@ sub on_join {
$self->{pbot}->{messagehistory}->{database}->set_current_nickserv_account($message_account, ''); $self->{pbot}->{messagehistory}->{database}->set_current_nickserv_account($message_account, '');
} }
$self->{pbot}->{antiflood}->check_bans($message_account, $event->{event}->from, $channel); $self->{pbot}->{antiflood}->check_bans($message_account, $event->from, $channel);
} }
$self->{pbot}->{antiflood}->check_flood( $self->{pbot}->{antiflood}->check_flood(
@ -164,11 +164,11 @@ sub on_invite {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $target, $channel) = ( my ($nick, $user, $host, $target, $channel) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
lc $event->{event}->{args}->[0] lc $event->{args}[0]
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
@ -189,12 +189,12 @@ sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $target, $channel, $reason) = ( my ($nick, $user, $host, $target, $channel, $reason) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
lc $event->{event}->{args}->[0], lc $event->{args}[0],
$event->{event}->{args}->[1] $event->{args}[1]
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
@ -248,16 +248,16 @@ sub on_departure {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel, $args) = ( my ($nick, $user, $host, $channel, $args) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
lc $event->{event}->{to}->[0], lc $event->{to}[0],
$event->{event}->args $event->args
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
my $text = uc ($event->{event}->type) . ' ' . $args; my $text = uc ($event->type) . ' ' . $args;
my $message_account = $self->{pbot}->{messagehistory}->get_message_account($nick, $user, $host); my $message_account = $self->{pbot}->{messagehistory}->get_message_account($nick, $user, $host);
@ -295,7 +295,7 @@ sub on_departure {
sub on_channelmodeis { sub on_channelmodeis {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my (undef, $channel, $modes) = $event->{event}->args; my (undef, $channel, $modes) = $event->args;
$self->{pbot}->{logger}->log("Channel $channel modes: $modes\n"); $self->{pbot}->{logger}->log("Channel $channel modes: $modes\n");
@ -306,7 +306,7 @@ sub on_channelmodeis {
sub on_channelcreate { sub on_channelcreate {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($owner, $channel, $timestamp) = $event->{event}->args; my ($owner, $channel, $timestamp) = $event->args;
$self->{pbot}->{logger}->log("Channel $channel created by $owner on " . localtime($timestamp) . "\n"); $self->{pbot}->{logger}->log("Channel $channel created by $owner on " . localtime($timestamp) . "\n");
@ -318,16 +318,16 @@ sub on_channelcreate {
sub on_topic { sub on_topic {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
if (not length $event->{event}->{to}->[0]) { if (not length $event->{to}[0]) {
# on join # on join
my (undef, $channel, $topic) = $event->{event}->args; my (undef, $channel, $topic) = $event->args;
$self->{pbot}->{logger}->log("Topic for $channel: $topic\n"); $self->{pbot}->{logger}->log("Topic for $channel: $topic\n");
$self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC', $topic, 1); $self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC', $topic, 1);
} else { } else {
# user changing topic # user changing topic
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host); my ($nick, $user, $host) = ($event->nick, $event->user, $event->host);
my $channel = $event->{event}->{to}->[0]; my $channel = $event->{to}[0];
my $topic = $event->{event}->{args}->[0]; my $topic = $event->{args}[0];
$self->{pbot}->{logger}->log("$nick!$user\@$host changed topic for $channel to: $topic\n"); $self->{pbot}->{logger}->log("$nick!$user\@$host changed topic for $channel to: $topic\n");
$self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC', $topic, 1); $self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC', $topic, 1);
@ -340,7 +340,7 @@ sub on_topic {
sub on_topicinfo { sub on_topicinfo {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my (undef, $channel, $by, $timestamp) = $event->{event}->args; my (undef, $channel, $by, $timestamp) = $event->args;
$self->{pbot}->{logger}->log("Topic for $channel set by $by on " . localtime($timestamp) . "\n"); $self->{pbot}->{logger}->log("Topic for $channel set by $by on " . localtime($timestamp) . "\n");
$self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC_SET_BY', $by, 1); $self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC_SET_BY', $by, 1);
$self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC_SET_ON', $timestamp, 1); $self->{pbot}->{channels}->{storage}->set($channel, 'TOPIC_SET_ON', $timestamp, 1);

View File

@ -2,7 +2,7 @@
# #
# Purpose: IRC handlers for chat/message events. # Purpose: IRC handlers for chat/message events.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::Chat; package PBot::Core::Handlers::Chat;
@ -23,11 +23,11 @@ sub on_notice {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $to, $text) = ( my ($nick, $user, $host, $to, $text) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
$event->{event}->{args}->[0], $event->{args}[0],
); );
# don't handle non-chat NOTICE # don't handle non-chat NOTICE
@ -39,7 +39,7 @@ sub on_notice {
# if NOTICE is sent to the bot then replace the `to` field with the # if NOTICE is sent to the bot then replace the `to` field with the
# sender's nick instead so when we pass it on to on_public ... # sender's nick instead so when we pass it on to on_public ...
if ($to eq $self->{pbot}->{registry}->get_value('irc', 'botnick')) { if ($to eq $self->{pbot}->{registry}->get_value('irc', 'botnick')) {
$event->{event}->{to}->[0] = $nick; $event->{to}[0] = $nick;
} }
# handle this NOTICE as a public message # handle this NOTICE as a public message
@ -53,12 +53,12 @@ sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($from, $nick, $user, $host, $text, $tags) = ( my ($from, $nick, $user, $host, $text, $tags) = (
$event->{event}->{to}->[0], $event->{to}[0],
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->{args}->[0], $event->{args}[0],
$event->{event}->{args}->[1], $event->{args}[1],
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
@ -73,7 +73,7 @@ sub on_action {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
# prepend "/me " to the message text # prepend "/me " to the message text
$event->{event}->{args}->[0] = "/me " . $event->{event}->{args}->[0]; $event->{args}[0] = "/me " . $event->{args}[0];
# pass this along to on_public # pass this along to on_public
$self->on_public($event_type, $event); $self->on_public($event_type, $event);
@ -84,11 +84,11 @@ sub on_msg {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $text, $tags) = ( my ($nick, $user, $host, $text, $tags) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->{args}->[0], $event->{args}[0],
$event->{event}->{args}->[1], $event->{args}[1],
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);

View File

@ -2,7 +2,7 @@
# #
# Purpose: Maintains lists of nicks currently present in channels. # Purpose: Maintains lists of nicks currently present in channels.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::NickList; package PBot::Core::Handlers::NickList;
@ -39,7 +39,7 @@ sub initialize {
sub on_namreply { sub on_namreply {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($channel, $nicks) = ($event->{event}->{args}[2], $event->{event}->{args}[3]); my ($channel, $nicks) = ($event->{args}[2], $event->{args}[3]);
foreach my $nick (split ' ', $nicks) { foreach my $nick (split ' ', $nicks) {
my $stripped_nick = $nick; my $stripped_nick = $nick;
@ -70,7 +70,7 @@ sub on_namreply {
sub on_activity { sub on_activity {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{to}[0]); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->{to}[0]);
$self->{pbot}->{nicklist}->update_timestamp($channel, $nick); $self->{pbot}->{nicklist}->update_timestamp($channel, $nick);
@ -80,7 +80,7 @@ sub on_activity {
sub on_join { sub on_join {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->to);
$self->{pbot}->{nicklist}->add_nick($channel, $nick); $self->{pbot}->{nicklist}->add_nick($channel, $nick);
@ -95,7 +95,7 @@ sub on_join {
sub on_part { sub on_part {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->to);
$self->{pbot}->{nicklist}->remove_nick($channel, $nick); $self->{pbot}->{nicklist}->remove_nick($channel, $nick);
@ -105,7 +105,7 @@ sub on_part {
sub on_quit { sub on_quit {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host); my ($nick, $user, $host) = ($event->nick, $event->user, $event->host);
foreach my $channel (keys %{$self->{pbot}->{nicklist}->{nicklist}}) { foreach my $channel (keys %{$self->{pbot}->{nicklist}->{nicklist}}) {
if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) { if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) {
@ -119,7 +119,7 @@ sub on_quit {
sub on_kick { sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $channel) = ($event->{event}->to, $event->{event}->{args}[0]); my ($nick, $channel) = ($event->to, $event->{args}[0]);
$self->{pbot}->{nicklist}->remove_nick($channel, $nick); $self->{pbot}->{nicklist}->remove_nick($channel, $nick);
@ -128,7 +128,7 @@ sub on_kick {
sub on_nickchange { sub on_nickchange {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args); my ($nick, $user, $host, $newnick) = ($event->nick, $event->user, $event->host, $event->args);
foreach my $channel (keys %{$self->{pbot}->{nicklist}->{nicklist}}) { foreach my $channel (keys %{$self->{pbot}->{nicklist}->{nicklist}}) {
if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) { if ($self->{pbot}->{nicklist}->is_present($channel, $nick)) {

View File

@ -2,7 +2,7 @@
# #
# Purpose: Handles NickServ-related IRC events. # Purpose: Handles NickServ-related IRC events.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::NickServ; package PBot::Core::Handlers::NickServ;
@ -61,11 +61,11 @@ sub on_notice {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $to, $text) = ( my ($nick, $user, $host, $to, $text) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
$event->{event}->{args}->[0], $event->{args}[0],
); );
my $nickserv = $self->{pbot}->{registry}->get_value('general', 'identify_nick') // 'NickServ'; my $nickserv = $self->{pbot}->{registry}->get_value('general', 'identify_nick') // 'NickServ';
@ -110,8 +110,8 @@ sub on_notice {
sub on_nicknameinuse { sub on_nicknameinuse {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my (undef, $nick, $msg) = $event->{event}->args; my (undef, $nick, $msg) = $event->args;
my $from = $event->{event}->from; my $from = $event->from;
$self->{pbot}->{logger}->log("Received nicknameinuse for nick $nick from $from: $msg\n"); $self->{pbot}->{logger}->log("Received nicknameinuse for nick $nick from $from: $msg\n");

View File

@ -2,7 +2,7 @@
# #
# Purpose: Handles IRCv3 SASL events. Currently only PLAIN is supported. # Purpose: Handles IRCv3 SASL events. Currently only PLAIN is supported.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::SASL; package PBot::Core::Handlers::SASL;
@ -60,57 +60,57 @@ sub on_sasl_authenticate {
sub on_rpl_loggedin { sub on_rpl_loggedin {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[3] . "\n"); $self->{pbot}->{logger}->log($event->{args}[3] . "\n");
return 1; return 1;
} }
sub on_rpl_loggedout { sub on_rpl_loggedout {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log($event->{args}[1] . "\n");
return 1; return 1;
} }
sub on_err_nicklocked { sub on_err_nicklocked {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log($event->{args}[1] . "\n");
$self->{pbot}->exit(EXIT_FAILURE); $self->{pbot}->exit(EXIT_FAILURE);
} }
sub on_rpl_saslsuccess { sub on_rpl_saslsuccess {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log($event->{args}[1] . "\n");
$event->{conn}->sl("CAP END"); $event->{conn}->sl("CAP END");
return 1; return 1;
} }
sub on_err_saslfail { sub on_err_saslfail {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log($event->{args}[1] . "\n");
$self->{pbot}->exit(EXIT_FAILURE); $self->{pbot}->exit(EXIT_FAILURE);
} }
sub on_err_sasltoolong { sub on_err_sasltoolong {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log($event->{args}[1] . "\n");
$self->{pbot}->exit(EXIT_FAILURE); $self->{pbot}->exit(EXIT_FAILURE);
} }
sub on_err_saslaborted { sub on_err_saslaborted {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log($event->{args}[1] . "\n");
$self->{pbot}->exit(EXIT_FAILURE); $self->{pbot}->exit(EXIT_FAILURE);
} }
sub on_err_saslalready { sub on_err_saslalready {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log($event->{event}->{args}->[1] . "\n"); $self->{pbot}->{logger}->log($event->{args}[1] . "\n");
return 1; return 1;
} }
sub on_rpl_saslmechs { sub on_rpl_saslmechs {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log("SASL mechanism not available.\n"); $self->{pbot}->{logger}->log("SASL mechanism not available.\n");
$self->{pbot}->{logger}->log("Available mechanisms are: $event->{event}->{args}->[1]\n"); $self->{pbot}->{logger}->log("Available mechanisms are: $event->{args}[1]\n");
$self->{pbot}->exit(EXIT_FAILURE); $self->{pbot}->exit(EXIT_FAILURE);
} }

View File

@ -2,7 +2,7 @@
# #
# Purpose: Handles server-related IRC events. # Purpose: Handles server-related IRC events.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::Server; package PBot::Core::Handlers::Server;
@ -76,8 +76,8 @@ sub on_motd {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
if ($self->{pbot}->{registry}->get_value('irc', 'show_motd')) { if ($self->{pbot}->{registry}->get_value('irc', 'show_motd')) {
my $from = $event->{event}->{from}; my $from = $event->{from};
my $msg = $event->{event}->{args}->[1]; my $msg = $event->{args}[1];
$self->{pbot}->{logger}->log("MOTD from $from :: $msg\n"); $self->{pbot}->{logger}->log("MOTD from $from :: $msg\n");
} }
@ -88,9 +88,9 @@ sub on_notice {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($server, $to, $text) = ( my ($server, $to, $text) = (
$event->{event}->nick, $event->nick,
$event->{event}->to, $event->to,
$event->{event}->{args}->[0], $event->{args}[0],
); );
# don't handle non-server NOTICE # don't handle non-server NOTICE
@ -107,12 +107,12 @@ sub on_isupport {
# remove and discard first and last arguments # remove and discard first and last arguments
# (first arg is botnick, last arg is "are supported by this server") # (first arg is botnick, last arg is "are supported by this server")
shift @{$event->{event}->{args}}; shift @{$event->{args}};
pop @{$event->{event}->{args}}; pop @{$event->{args}};
my $logmsg = "$event->{event}->{from} supports:"; my $logmsg = "$event->{from} supports:";
foreach my $arg (@{$event->{event}->{args}}) { foreach my $arg (@{$event->{args}}) {
my ($key, $value) = split /=/, $arg; my ($key, $value) = split /=/, $arg;
if ($key =~ s/^-//) { if ($key =~ s/^-//) {
@ -132,7 +132,7 @@ sub on_isupport {
sub on_nickchange { sub on_nickchange {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args); my ($nick, $user, $host, $newnick) = ($event->nick, $event->user, $event->host, $event->args);
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
@ -169,7 +169,7 @@ sub on_nickchange {
sub on_nononreg { sub on_nononreg {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my $target = $event->{event}->{args}->[1]; my $target = $event->{args}[1];
$self->{pbot}->{logger}->log("Cannot send private /msg to $target; they are blocking unidentified /msgs.\n"); $self->{pbot}->{logger}->log("Cannot send private /msg to $target; they are blocking unidentified /msgs.\n");
@ -178,13 +178,13 @@ sub on_nononreg {
sub log_first_arg { sub log_first_arg {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log("$event->{event}->{args}->[1]\n"); $self->{pbot}->{logger}->log("$event->{args}[1]\n");
return 1; return 1;
} }
sub log_third_arg { sub log_third_arg {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
$self->{pbot}->{logger}->log("$event->{event}->{args}->[3]\n"); $self->{pbot}->{logger}->log("$event->{args}[3]\n");
return 1; return 1;
} }

View File

@ -2,7 +2,7 @@
# #
# Purpose: Handles IRC events related to PBot user accounts and user metadata. # Purpose: Handles IRC events related to PBot user accounts and user metadata.
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com> # SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
package PBot::Core::Handlers::Users; package PBot::Core::Handlers::Users;
@ -23,10 +23,10 @@ sub on_join {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ( my ($nick, $user, $host, $channel) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to $event->to
); );
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
@ -67,7 +67,7 @@ sub on_join {
sub on_departure { sub on_departure {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->to);
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
$self->{pbot}->{users}->decache_user($channel, "$nick!$user\@$host"); $self->{pbot}->{users}->decache_user($channel, "$nick!$user\@$host");
return 1; return 1;
@ -75,7 +75,7 @@ sub on_departure {
sub on_kick { sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{args}[0]); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->{args}[0]);
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
$self->{pbot}->{users}->decache_user($channel, "$nick!$user\@$host"); $self->{pbot}->{users}->decache_user($channel, "$nick!$user\@$host");
return 1; return 1;

View File

@ -998,7 +998,6 @@ sub parse {
if ($itype eq "ctcp") { # it's got CTCP in it! if ($itype eq "ctcp") { # it's got CTCP in it!
$self->parse_ctcp($type, $from, $stuff[0], $line); $self->parse_ctcp($type, $from, $stuff[0], $line);
next; next;
} elsif ($type eq "public" } elsif ($type eq "public"
or $type eq "msg" or $type eq "msg"
or $type eq "notice" or $type eq "notice"
@ -1008,9 +1007,9 @@ sub parse {
or $type eq "topic" or $type eq "topic"
or $type eq "invite" or $type eq "invite"
or $type eq "whoisaccount" or $type eq "whoisaccount"
or $type eq "chghost"
or $type eq "cap") # IRCv3 client capabilities pragma- or $type eq "cap") # IRCv3 client capabilities pragma-
{ {
$ev = PBot::Core::IRC::Event->new( $ev = PBot::Core::IRC::Event->new(
$type, # pragma_ 2011/21/01 $type, # pragma_ 2011/21/01
$from, $from,
@ -1019,7 +1018,6 @@ sub parse {
@stuff, @stuff,
); );
} elsif ($type eq "quit" or $type eq "nick" or $type eq "account") { } elsif ($type eq "quit" or $type eq "nick" or $type eq "account") {
$ev = PBot::Core::IRC::Event->new( $ev = PBot::Core::IRC::Event->new(
$type, # pragma_ 2011/21/01 $type, # pragma_ 2011/21/01
$from, $from,
@ -1028,7 +1026,6 @@ sub parse {
@stuff, @stuff,
); );
} elsif ($type eq "kick") { } elsif ($type eq "kick") {
$ev = PBot::Core::IRC::Event->new( $ev = PBot::Core::IRC::Event->new(
$type, # pragma_ 2011/21/01 $type, # pragma_ 2011/21/01
$from, $from,
@ -1036,8 +1033,10 @@ sub parse {
$type, $type,
@stuff[0, 2 .. $#stuff], @stuff[0, 2 .. $#stuff],
); );
} elsif ($type eq "kill"
} elsif ($type eq "kill") { or $type eq "wallops"
or $type eq "pong")
{
$ev = PBot::Core::IRC::Event->new( $ev = PBot::Core::IRC::Event->new(
$type, # pragma_ 2011/21/01 $type, # pragma_ 2011/21/01
$from, $from,
@ -1045,22 +1044,6 @@ sub parse {
$type, $type,
$line $line
); # Ahh, what the hell. ); # Ahh, what the hell.
} elsif ($type eq "wallops") {
$ev = PBot::Core::IRC::Event->new(
$type, # pragma_ 2011/21/01
$from,
'',
$type,
$line
);
} elsif ($type eq "pong") {
$ev = PBot::Core::IRC::Event->new(
$type, # pragma_ 2011/21/01
$from,
'',
$type,
$line
);
} else { } else {
carp "Unknown event type: $type"; carp "Unknown event type: $type";
} }

View File

@ -56,8 +56,11 @@ sub new {
bless $self, $class; bless $self, $class;
if ($self->type !~ /\D/) { $self->type($self->trans($self->type)); } if ($self->type !~ /\D/) {
else { $self->type(lc($self->type)); } $self->type($self->trans($self->type));
} else {
$self->type(lc($self->type));
}
$self->from($from); # sets nick, user, and host $self->from($from); # sets nick, user, and host
$self->args($args); # strips colons from args $self->args($args); # strips colons from args
@ -487,6 +490,7 @@ sub trans {
'cap' => 'cap', 'cap' => 'cap',
'account' => 'account', 'account' => 'account',
'authenticate' => 'authenticate', 'authenticate' => 'authenticate',
'chghost' => 'chghost',
); );
1; 1;

View File

@ -17,18 +17,18 @@ sub initialize {
# nothing to do here # nothing to do here
} }
# this default handler prepends 'irc.' to the event-type and then dispatches # this default handler prepends 'irc.' to the event-name and then dispatches
# the event to the rest of PBot via PBot::Core::EventDispatcher. # the event to the rest of PBot via PBot::Core::EventDispatcher.
sub default_handler { sub default_handler {
my ($self, $conn, $event) = @_; my ($self, $conn, $event) = @_;
# add conn to event object so we can access it within handlers
$event->{conn} = $conn;
my $result = $self->{pbot}->{event_dispatcher}->dispatch_event( my $result = $self->{pbot}->{event_dispatcher}->dispatch_event(
"irc.$event->{type}", "irc.$event->{type}",
{ $event
conn => $conn,
event => $event
}
); );
# log event if it was not handled and logging is requested # log event if it was not handled and logging is requested
@ -36,6 +36,7 @@ sub default_handler {
$Data::Dumper::Sortkeys = 1; $Data::Dumper::Sortkeys = 1;
$Data::Dumper::Indent = 2; $Data::Dumper::Indent = 2;
$Data::Dumper::Useqq = 1; $Data::Dumper::Useqq = 1;
delete $event->{conn}; # don't include conn in dump
$self->{pbot}->{logger}->log(Dumper $event); $self->{pbot}->{logger}->log(Dumper $event);
} }
} }

View File

@ -399,17 +399,17 @@ sub on_kick {
return 0 if $event->{interpreted}; return 0 if $event->{interpreted};
my ($nick, $user, $host) = ( my ($nick, $user, $host) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host $event->host
); );
my ($victim, $reason) = ( my ($victim, $reason) = (
$event->{event}->to, $event->to,
$event->{event}->{args}[1] $event->{args}[1]
); );
my $channel = $event->{event}->{args}[0]; my $channel = $event->{args}[0];
$self->check_trigger($nick, $user, $host, $channel, "KICK $victim $reason"); $self->check_trigger($nick, $user, $host, $channel, "KICK $victim $reason");
return 0; return 0;
@ -419,13 +419,13 @@ sub on_action {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ( my ($nick, $user, $host, $msg) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->args $event->args
); );
my $channel = $event->{event}->{to}[0]; my $channel = $event->{to}[0];
$msg =~ s/^\/me\s+//; $msg =~ s/^\/me\s+//;
@ -437,12 +437,12 @@ sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ( my ($nick, $user, $host, $msg) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->args); $event->args);
my $channel = $event->{event}->{to}[0]; my $channel = $event->{to}[0];
$self->check_trigger($nick, $user, $host, $channel, "PRIVMSG $msg"); $self->check_trigger($nick, $user, $host, $channel, "PRIVMSG $msg");
return 0; return 0;
@ -452,11 +452,11 @@ sub on_join {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel, $args) = ( my ($nick, $user, $host, $channel, $args) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
$event->{event}->args $event->args
); );
$self->check_trigger($nick, $user, $host, $channel, "JOIN"); $self->check_trigger($nick, $user, $host, $channel, "JOIN");
@ -467,14 +467,14 @@ sub on_departure {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel, $args) = ( my ($nick, $user, $host, $channel, $args) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
$event->{event}->args $event->args
); );
$self->check_trigger($nick, $user, $host, $channel, (uc $event->{event}->type) . " $args"); $self->check_trigger($nick, $user, $host, $channel, (uc $event->type) . " $args");
return 0; return 0;
} }

View File

@ -12,9 +12,11 @@ use PBot::Imports;
sub initialize { sub initialize {
my ($self, %conf) = @_; my ($self, %conf) = @_;
$self->{pbot}->{registry}->add_default('text', 'antiaway', 'bad_nicks', $self->{pbot}->{registry}->add_default('text', 'antiaway', 'bad_nicks',
$conf{bad_nicks} // '([[:punct:]](afk|brb|bbl|away|sleep|z+|work|gone|study|out|home|busy|off)[[:punct:]]*$|.+\[.*\]$)' $conf{bad_nicks} // '([[:punct:]](afk|brb|bbl|away|sleep|z+|work|gone|study|out|home|busy|off)[[:punct:]]*$|.+\[.*\]$)'
); );
$self->{pbot}->{registry}->add_default('text', 'antiaway', 'bad_actions', $conf{bad_actions} // '^/me (is (away|gone)|.*auto.?away)'); $self->{pbot}->{registry}->add_default('text', 'antiaway', 'bad_actions', $conf{bad_actions} // '^/me (is (away|gone)|.*auto.?away)');
$self->{pbot}->{registry}->add_default('text', 'antiaway', 'kick_msg', 'http://sackheads.org/~bnaylor/spew/away_msgs.html'); $self->{pbot}->{registry}->add_default('text', 'antiaway', 'kick_msg', 'http://sackheads.org/~bnaylor/spew/away_msgs.html');
@ -30,12 +32,20 @@ sub unload {
sub on_nickchange { sub on_nickchange {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
my ($nick, $user, $host, $newnick) = (
$event->nick,
$event->user,
$event->host,
$event->args
);
my $bad_nicks = $self->{pbot}->{registry}->get_value('antiaway', 'bad_nicks'); my $bad_nicks = $self->{pbot}->{registry}->get_value('antiaway', 'bad_nicks');
if ($newnick =~ m/$bad_nicks/i) { if ($newnick =~ m/$bad_nicks/i) {
my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg'); my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg');
my $channels = $self->{pbot}->{nicklist}->get_channels($newnick); my $channels = $self->{pbot}->{nicklist}->get_channels($newnick);
foreach my $chan (@$channels) { foreach my $chan (@$channels) {
next if not $self->{pbot}->{chanops}->can_gain_ops($chan); next if not $self->{pbot}->{chanops}->can_gain_ops($chan);
@ -52,7 +62,14 @@ sub on_nickchange {
sub on_action { sub on_action {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{args}[0], $event->{event}->{to}[0]);
my ($nick, $user, $host, $msg, $channel) = (
$event->nick,
$event->user,
$event->host,
$event->{args}[0],
$event->{to}[0],
);
return 0 if $channel !~ /^#/; return 0 if $channel !~ /^#/;
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel); return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
@ -61,6 +78,7 @@ sub on_action {
return 0 if $self->{pbot}->{capabilities}->userhas($u, 'is-whitelisted'); return 0 if $self->{pbot}->{capabilities}->userhas($u, 'is-whitelisted');
my $bad_actions = $self->{pbot}->{registry}->get_value('antiaway', 'bad_actions'); my $bad_actions = $self->{pbot}->{registry}->get_value('antiaway', 'bad_actions');
if ($msg =~ m/$bad_actions/i) { if ($msg =~ m/$bad_actions/i) {
$self->{pbot}->{logger}->log("$nick $msg matches bad away actions regex, kicking...\n"); $self->{pbot}->{logger}->log("$nick $msg matches bad away actions regex, kicking...\n");
my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg'); my $kick_msg = $self->{pbot}->{registry}->get_value('antiaway', 'kick_msg');

View File

@ -31,8 +31,8 @@ sub unload {
sub on_kick { sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host); my ($nick, $user, $host) = ($event->nick, $event->user, $event->host);
my ($target, $channel, $reason) = ($event->{event}->to, $event->{event}->{args}[0], $event->{event}->{args}[1]); my ($target, $channel, $reason) = ($event->to, $event->{args}[0], $event->{args}[1]);
$channel = lc $channel; $channel = lc $channel;
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel); return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
@ -48,10 +48,11 @@ sub on_kick {
sub on_join { sub on_join {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->to);
$channel = lc $channel; $channel = lc $channel;
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel); return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
my $u = $self->{pbot}->{users}->loggedin($channel, "$nick!$user\@$host"); my $u = $self->{pbot}->{users}->loggedin($channel, "$nick!$user\@$host");
return 0 if $self->{pbot}->{capabilities}->userhas($u, 'is-whitelisted'); return 0 if $self->{pbot}->{capabilities}->userhas($u, 'is-whitelisted');

View File

@ -29,8 +29,8 @@ sub unload {
sub on_action { sub on_action {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args); my ($nick, $user, $host, $msg) = ($event->nick, $event->user, $event->host, $event->args);
my $channel = $event->{event}->{to}[0]; my $channel = $event->{to}[0];
return 0 if $event->{interpreted}; return 0 if $event->{interpreted};
$self->check_flood($nick, $user, $host, $channel, $msg); $self->check_flood($nick, $user, $host, $channel, $msg);
return 0; return 0;
@ -38,8 +38,8 @@ sub on_action {
sub on_public { sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args); my ($nick, $user, $host, $msg) = ($event->nick, $event->user, $event->host, $event->args);
my $channel = $event->{event}->{to}[0]; my $channel = $event->{to}[0];
return 0 if $event->{interpreted}; return 0 if $event->{interpreted};
$self->check_flood($nick, $user, $host, $channel, $msg); $self->check_flood($nick, $user, $host, $channel, $msg);
return 0; return 0;

View File

@ -36,8 +36,15 @@ sub unload {
sub on_public { sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
my $channel = lc $event->{event}->{to}[0]; my ($nick, $user, $host, $msg) = (
$event->nick,
$event->user,
$event->host,
$event->args,
);
my $channel = lc $event->{to}[0];
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);

View File

@ -28,9 +28,10 @@ sub unload {
sub on_public { sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->{to}[0], $event->{event}->args); my ($nick, $user, $host, $channel, $msg) = ($event->nick, $event->user, $event->host, $event->{to}[0], $event->args);
return 0 if $event->{interpreted}; return 0 if $event->{interpreted};
$channel = lc $channel; $channel = lc $channel;
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel); return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);

View File

@ -49,12 +49,12 @@ sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $target, $channel, $reason) = ( my ($nick, $user, $host, $target, $channel, $reason) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
$event->{event}->{args}[0], $event->{args}[0],
$event->{event}->{args}[1], $event->{args}[1],
); );
return 0 if not $self->{pbot}->{channels}->is_active($channel); return 0 if not $self->{pbot}->{channels}->is_active($channel);
@ -71,10 +71,10 @@ sub on_part {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ( my ($nick, $user, $host, $channel) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host, $event->host,
$event->{event}->to, $event->to,
); );
return 0 if not $self->{pbot}->{channels}->is_active($channel); return 0 if not $self->{pbot}->{channels}->is_active($channel);

View File

@ -12,11 +12,14 @@ use parent 'PBot::Plugin::Base';
use PBot::Imports; use PBot::Imports;
use Time::Duration qw/concise duration/; use Time::Duration qw/concise duration/;
use Data::Dumper;
use List::Util qw[min max]; use List::Util qw[min max];
use Data::Dumper;
$Data::Dumper::Useqq = 1; $Data::Dumper::Useqq = 1;
$Data::Dumper::Sortkeys = 1; $Data::Dumper::Sortkeys = 1;
# This plugin was contributed by mannito, based on an earlier version of Battleship.pm
sub initialize { sub initialize {
my ($self, %conf) = @_; my ($self, %conf) = @_;
@ -46,9 +49,9 @@ sub unload {
sub on_kick { sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host); my ($nick, $user, $host) = ($event->nick, $event->user, $event->host);
my ($victim, $reason) = ($event->{event}->to, $event->{event}->{args}[1]); my ($victim, $reason) = ($event->to, $event->{args}[1]);
my $channel = $event->{event}->{args}[0]; my $channel = $event->{args}[0];
return 0 if lc $channel ne $self->{channel}; return 0 if lc $channel ne $self->{channel};
$self->player_left($nick, $user, $host); $self->player_left($nick, $user, $host);
return 0; return 0;
@ -56,8 +59,8 @@ sub on_kick {
sub on_departure { sub on_departure {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->to);
my $type = uc $event->{event}->type; my $type = uc $event->type;
return 0 if $type ne 'QUIT' and lc $channel ne $self->{channel}; return 0 if $type ne 'QUIT' and lc $channel ne $self->{channel};
$self->player_left($nick, $user, $host); $self->player_left($nick, $user, $host);
return 0; return 0;

View File

@ -487,8 +487,8 @@ sub cmd_countertrigger {
sub on_public { sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args); my ($nick, $user, $host, $msg) = ($event->nick, $event->user, $event->host, $event->args);
my $channel = $event->{event}->{to}[0]; my $channel = $event->{to}[0];
return 0 if $event->{interpreted}; return 0 if $event->{interpreted};

View File

@ -12,7 +12,10 @@ use PBot::Imports;
sub initialize { sub initialize {
my ($self, %conf) = @_; my ($self, %conf) = @_;
$self->{pbot}->{event_dispatcher}->register_handler('irc.public', sub { $self->on_public(@_) }); $self->{pbot}->{event_dispatcher}->register_handler(
'irc.public',
sub { $self->on_public(@_) },
);
} }
sub unload { sub unload {
@ -24,15 +27,21 @@ sub unload {
sub on_public { sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
my ($nick, $user, $host, $msg) = (
$event->nick,
$event->user,
$event->host,
$event->args,
);
if ($event->{interpreted}) { if ($event->{interpreted}) {
$self->{pbot}->{logger}->log("Message was already handled by the interpreter.\n"); $self->{pbot}->{logger}->log("Message was already handled by the interpreter.\n");
return 0; return 0; # event not handled by plugin
} }
$self->{pbot}->{logger}->log("Example plugin: got message from $nick!$user\@$host: $msg\n"); $self->{pbot}->{logger}->log("Example plugin: got message from $nick!$user\@$host: $msg\n");
return 0; return 1; # event handled by plugin
} }
1; 1;

View File

@ -32,8 +32,8 @@ sub unload {
sub on_public { sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args); my ($nick, $user, $host, $msg) = ($event->nick, $event->user, $event->host, $event->args);
my $channel = lc $event->{event}->{to}[0]; my $channel = lc $event->{to}[0];
$msg =~ s/^\s+|\s+$//g; $msg =~ s/^\s+|\s+$//g;
return 0 if not length $msg; return 0 if not length $msg;
@ -56,17 +56,8 @@ sub on_public {
return 0 if defined $nickserv && length $nickserv; return 0 if defined $nickserv && length $nickserv;
my @filters = ( my @filters = (
qr{https://bryanostergaard.com/}, # qr{list of filters},
qr{https://encyclopediadramatica.rs/Freenodegate}, # qr{etc},
qr{https://MattSTrout.com/},
qr{Contact me on twitter},
qr{At the beginning there was only Chaos},
qr{https://williampitcock.com/},
qr{Achievement Method},
qr{perceived death signal},
qr{efnet},
qr{https://evestigatorsucks.com},
qr{eVestigator},
); );
# don't notify/relay for spammers # don't notify/relay for spammers

View File

@ -84,9 +84,9 @@ sub unload {
sub on_kick { sub on_kick {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host); my ($nick, $user, $host) = ($event->nick, $event->user, $event->host);
my ($victim, $reason) = ($event->{event}->to, $event->{event}->{args}[1]); my ($victim, $reason) = ($event->to, $event->{args}[1]);
my $channel = $event->{event}->{args}[0]; my $channel = $event->{args}[0];
return 0 if lc $channel ne $self->{channel}; return 0 if lc $channel ne $self->{channel};
$self->player_left($nick, $user, $host); $self->player_left($nick, $user, $host);
return 0; return 0;
@ -94,8 +94,8 @@ sub on_kick {
sub on_departure { sub on_departure {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $channel) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->to); my ($nick, $user, $host, $channel) = ($event->nick, $event->user, $event->host, $event->to);
my $type = uc $event->{event}->type; my $type = uc $event->type;
return 0 if $type ne 'QUIT' and lc $channel ne $self->{channel}; return 0 if $type ne 'QUIT' and lc $channel ne $self->{channel};
$self->player_left($nick, $user, $host); $self->player_left($nick, $user, $host);
return 0; return 0;

View File

@ -34,12 +34,15 @@ sub unload {
sub on_public { sub on_public {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $msg) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
my $channel = lc $event->{event}->{to}[0]; my ($nick, $user, $host, $msg) = ($event->nick, $event->user, $event->host, $event->args);
my $channel = lc $event->{to}[0];
($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host); ($nick, $user, $host) = $self->{pbot}->{irchandlers}->normalize_hostmask($nick, $user, $host);
return 0 if $self->{pbot}->{ignorelist}->is_ignored($channel, "$nick!$user\@$host"); return 0 if $self->{pbot}->{ignorelist}->is_ignored($channel, "$nick!$user\@$host");
my $nosubs = $self->{pbot}->{registry}->get_value($channel, 'notyposub'); my $nosubs = $self->{pbot}->{registry}->get_value($channel, 'notyposub');
return 0 if defined $nosubs and $nosubs; return 0 if defined $nosubs and $nosubs;

View File

@ -52,6 +52,9 @@ sub unload {
sub is_ignored_url { sub is_ignored_url {
my ($self, $url) = @_; my ($self, $url) = @_;
return 1 if $url =~ m{https://asciinema.org}i;
return 1 if $url =~ m{https?://tpcg.io/}i;
return 1 if $url =~ m/bootlin.com/i;
return 1 if $url =~ m{https?://matrix\.to}i; return 1 if $url =~ m{https?://matrix\.to}i;
return 1 if $url =~ m{https?://.*\.c$}i; return 1 if $url =~ m{https?://.*\.c$}i;
return 1 if $url =~ m{https?://.*\.h$}i; return 1 if $url =~ m{https?://.*\.h$}i;
@ -67,6 +70,8 @@ sub is_ignored_url {
return 1 if $url =~ m{127}i; return 1 if $url =~ m{127}i;
return 1 if $url =~ m{192.168}i; return 1 if $url =~ m{192.168}i;
return 1 if $url =~ m{file://}i; return 1 if $url =~ m{file://}i;
return 1 if $url =~ m{/src/}i;
return 1 if $url =~ m{/trunk/}i;
return 1 if $url =~ m{\.\.}i; return 1 if $url =~ m{\.\.}i;
return 1 if $url =~ m{https?://www.irccloud.com/pastebin}i; return 1 if $url =~ m{https?://www.irccloud.com/pastebin}i;
return 1 if $url =~ m{http://smuj.ca/cl}i; return 1 if $url =~ m{http://smuj.ca/cl}i;
@ -258,14 +263,14 @@ sub show_url_titles {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host) = ( my ($nick, $user, $host) = (
$event->{event}->nick, $event->nick,
$event->{event}->user, $event->user,
$event->{event}->host $event->host
); );
my ($channel, $msg) = ( my ($channel, $msg) = (
$event->{event}->{to}[0], $event->{to}[0],
$event->{event}->{args}[0] $event->{args}[0]
); );
# get show_url_titles for channel or true if not defined # get show_url_titles for channel or true if not defined

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script # These are set by the /misc/update_version script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 4609, BUILD_REVISION => 4610,
BUILD_DATE => "2023-01-30", BUILD_DATE => "2023-01-31",
}; };
sub initialize {} sub initialize {}