« SpreadRevolutionaryDate/MsgMaker/RevolutionaryDate/Locale.pm
↑ Summary
SpreadRevolutionaryDate/Target/Liberachat.pm »
| 1 | # | ||||||||||
| 2 | # This file is part of App-SpreadRevolutionaryDate | ||||||||||
| 3 | # | ||||||||||
| 4 | # This software is Copyright (c) 2019-2026 by Gérald Sédrati. | ||||||||||
| 5 | # | ||||||||||
| 6 | # This is free software, licensed under: | ||||||||||
| 7 | # | ||||||||||
| 8 | # The GNU General Public License, Version 3, June 2007 | ||||||||||
| 9 | # | ||||||||||
| 10 | 4 | ▶ | use 5.014; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 4 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | package App::SpreadRevolutionaryDate::Target::Freenode; | ||||||||||
| 13 | 4 | $App::SpreadRevolutionaryDate::Target::Freenode::VERSION = '0.54'; | |||||||||
| 14 | # ABSTRACT: Target class for L<App::SpreadRevolutionaryDate> to handle spreading on Freenode. | ||||||||||
| 15 | |||||||||||
| 16 | 4 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 4 | with 'App::SpreadRevolutionaryDate::Target' | |||||||||
| 18 | => {worker => 'App::SpreadRevolutionaryDate::Target::Freenode::Bot'}; | ||||||||||
| 19 | |||||||||||
| 20 | 4 | ▶ | use App::SpreadRevolutionaryDate::Target::Freenode::Bot; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 4 | ▶ | use POE; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 4 | ▶ | use Locale::TextDomain 'App-SpreadRevolutionaryDate'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 4 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 4 | has 'nickname' => ( | |||||||||
| 27 | is => 'ro', | ||||||||||
| 28 | isa => 'Str', | ||||||||||
| 29 | required => 1, | ||||||||||
| 30 | ); | ||||||||||
| 31 | |||||||||||
| 32 | 4 | has 'password' => ( | |||||||||
| 33 | is => 'ro', | ||||||||||
| 34 | isa => 'Str', | ||||||||||
| 35 | required => 1, | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 4 | has 'channels' => ( | |||||||||
| 39 | is => 'ro', | ||||||||||
| 40 | isa => 'ArrayRef[Str]', | ||||||||||
| 41 | required => 1, | ||||||||||
| 42 | ); | ||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | 5 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.5
| |||||||||||
| 46 | 5 | my ($orig, $class) = @_; | |||||||||
| 47 | |||||||||||
| 48 | 5 | my $port = 6667; | |||||||||
| 49 | 5 | my $ssl = 0; | |||||||||
| 50 | |||||||||||
| 51 | # Switch to SSL if module POE::Component::SSLify is available | ||||||||||
| 52 | 0 | ▶ | if (eval { require POE::Component::SSLify; 1 }) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 0 | $port = 6697; | |||||||||
| 54 | 0 | $ssl = 1; | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | 5 | my $args = $class->$orig(@_); | |||||||||
| 58 | |||||||||||
| 59 | $args->{obj} = App::SpreadRevolutionaryDate::Target::Freenode::Bot->new( | ||||||||||
| 60 | server => 'irc.freenode.net', | ||||||||||
| 61 | port => $port, | ||||||||||
| 62 | nick => 'RevolutionaryBot', | ||||||||||
| 63 | alt_nicks => ['RevolutionaryCalendar', 'RevolutionaryDate'], | ||||||||||
| 64 | name => 'Revolutionary Date bot', | ||||||||||
| 65 | flood => 1, | ||||||||||
| 66 | useipv6 => 1, | ||||||||||
| 67 | ssl => $ssl, | ||||||||||
| 68 | charset => 'utf-8', | ||||||||||
| 69 | channels => $args->{channels}, | ||||||||||
| 70 | freenode_nickname => $args->{nickname}, | ||||||||||
| 71 | freenode_password => $args->{password}, | ||||||||||
| 72 | 5 | msg => '', | |||||||||
| 73 | no_run => 1, | ||||||||||
| 74 | ); | ||||||||||
| 75 | |||||||||||
| 76 | 5 | return $args; | |||||||||
| 77 | 4 | }; | |||||||||
| 78 | |||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | sub spread { | ||||||||
|
Subroutine
spread: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 81 | 0 | my ($self, $msg) = @_; | |||||||||
| 82 | |||||||||||
| 83 | # Multiline message | ||||||||||
| 84 | 0 | $msg =~ s/\\n/\n/g; | |||||||||
| 85 | |||||||||||
| 86 | 0 | $self->obj->msg($msg); | |||||||||
| 87 | 0 | $self->obj->run; | |||||||||
| 88 | 0 | POE::Kernel->run(); | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | |||||||||||
| 92 | 4 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 93 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||
| 94 | |||||||||||
| 95 | # A module must return a true value. Traditionally, a module returns 1. | ||||||||||
| 96 | # But this module is a revolutionary one, so it discards all old traditions. | ||||||||||
| 97 | # Idea borrowed from Jean Forget's DateTime::Calendar::FrenchRevolutionary. | ||||||||||
| 98 | 4 | "Quand le gouvernement viole les droits du peuple, | |||||||||
| 99 | l'insurrection est pour le peuple le plus sacré | ||||||||||
| 100 | et le plus indispensable des devoirs"; | ||||||||||
| 101 | |||||||||||
| 102 | __END__ | ||||||||||