App-RoboBot
view release on metacpan or search on metacpan
114115116117118119120121122123124125126127128129130131132133134RoboBot is not strictly limited to IRC. Any text-based chat protocol can be
supported via the network plugin interface. Out of the box, RoboBot supports
standard IRC networks (
with
or without SSL), the Slack RTM API, and Mattermost
WebSockets/Web Services APIs. A single instance of RoboBot may mix and match
connections to as many different chat protocols as you wish.
Other chat protocols, such as the various instant messaging platforms, could be
added fairly easily, providing there is already a CPAN module (compatible
with
AnyEvent) or you are willing to
write
one. Network plugins need only implement
a handful of methods (
connect
, disconnect,
join
\_channel, and
send
) as well as
register any callbacks required to deal
with
messages coming in over the wire.
Any functionality beyond that is generally optional, though some protocols may
require
some additional support (e.g. Slack support requires ID<->name mappings
via Slack API calls
for
both channels and participants).
### Plugins
The bulk of RoboBot's functionality is implemented through a generic plugin
members, or to hook into message and response parsing phases
before
and
after
expression evaluation.
lib/App/RoboBot/Network/IRC.pm view on Meta::CPAN
919293949596979899100101102103104105106107108109110111
});
$self
->client->
connect
(
$self
->host,
$self
->port, {
nick
=>
$self
->nick->name });
$self
->
log
->info(
'Connected.'
);
$_
->
join
for
@{
$self
->channels};
}
sub
disconnect {
# TODO: remove callbacks
# call client->disconnect
}
sub
kick {
my
(
$self
,
$response
,
$nick
,
$message
) =
@_
;
return
unless
$response
->has_channel;
my
$channel
=
'#'
.
$response
->channel->name;
return
unless
defined
$nick
&&
defined
$message
&&
$nick
=~ m{\w+} &&
$message
=~ m{\w+};
( run in 0.244 second using v1.01-cache-2.11-cpan-8d75d55dd25 )