line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of the GNU General Public License |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# (C) Paul Evans, 2008-2014 -- leonerd@leonerd.org.uk |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Circle; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
321120
|
use strict; |
|
4
|
|
|
|
|
28
|
|
|
4
|
|
|
|
|
93
|
|
8
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
109
|
|
9
|
4
|
|
|
4
|
|
19
|
use base qw( Net::Async::Tangence::Server ); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
1590
|
|
10
|
|
|
|
|
|
|
IO::Async::Listener->VERSION( '0.64' ); # {handle_constructor} |
11
|
|
|
|
|
|
|
Net::Async::Tangence::Server->VERSION( '0.13' ); # Future-returning API |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.173320'; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
323842
|
use Carp; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
204
|
|
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
1509
|
use Tangence::Registry 0.20; # Support for late-loading classes |
|
4
|
|
|
|
|
62476
|
|
|
4
|
|
|
|
|
132
|
|
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
4
|
|
1808
|
use File::ShareDir qw( module_file ); |
|
4
|
|
|
|
|
24741
|
|
|
4
|
|
|
|
|
222
|
|
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
4
|
|
24
|
use IO::Async::OS; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1640
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
require Circle::RootObj; # must be late-bound, after $VERSION is set |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
C - server backend for the C application host |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new |
32
|
|
|
|
|
|
|
{ |
33
|
3
|
|
|
3
|
1
|
6
|
my $class = shift; |
34
|
3
|
|
|
|
|
10
|
my %args = @_; |
35
|
|
|
|
|
|
|
|
36
|
3
|
50
|
|
|
|
14
|
my $loop = $args{loop} or croak "Need a loop"; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
17
|
my $registry = Tangence::Registry->new( |
39
|
|
|
|
|
|
|
tanfile => module_file( __PACKAGE__, "circle.tan" ), |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
176243
|
my $rootobj = $registry->construct( |
43
|
|
|
|
|
|
|
"Circle::RootObj", |
44
|
|
|
|
|
|
|
loop => $loop |
45
|
|
|
|
|
|
|
); |
46
|
3
|
50
|
|
|
|
459
|
$rootobj->id == 1 or die "Assert failed: root object does not have ID 1"; |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
86
|
my $self = $class->SUPER::new( |
49
|
|
|
|
|
|
|
registry => $registry, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
427
|
$loop->add( $self ); |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
358
|
$self->{rootobj} = $rootobj; |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
13
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub make_local_client |
60
|
|
|
|
|
|
|
{ |
61
|
3
|
|
|
3
|
0
|
7
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
6
|
my $loop = $self->loop; |
64
|
|
|
|
|
|
|
|
65
|
3
|
50
|
|
|
|
71
|
my ( $S1, $S2 ) = IO::Async::OS->socketpair or die "Cannot socketpair - $!"; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Internal hackery; stolen from IaListener |
68
|
3
|
|
|
|
|
1074
|
my $acceptor = $self->acceptor; |
69
|
3
|
|
|
|
|
22
|
my $handle = $self->{handle_constructor}->( $self ); |
70
|
3
|
|
|
|
|
727
|
$S1->blocking( 0 ); |
71
|
3
|
|
|
|
|
82
|
$handle->set_handle( $S1 ); |
72
|
3
|
|
|
|
|
554
|
$self->on_accept( $handle ); |
73
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
2330
|
require Net::Async::Tangence::Client; |
75
|
3
|
|
|
|
|
34649
|
my $client = Net::Async::Tangence::Client->new( |
76
|
|
|
|
|
|
|
handle => $S2, |
77
|
|
|
|
|
|
|
identity => "test_client", |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
3
|
|
|
|
|
1736
|
$loop->add( $client ); |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
|
|
978
|
return $client; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub new_with_client |
86
|
|
|
|
|
|
|
{ |
87
|
3
|
|
|
3
|
0
|
10956
|
my $class = shift; |
88
|
|
|
|
|
|
|
|
89
|
3
|
|
|
|
|
15
|
my $self = $class->new( @_ ); |
90
|
|
|
|
|
|
|
|
91
|
3
|
|
|
|
|
11
|
my $client = $self->make_local_client; |
92
|
|
|
|
|
|
|
|
93
|
3
|
|
|
|
|
16
|
return ( $self, $client ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub warn |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
99
|
0
|
|
|
|
|
|
my $text = join " ", @_; |
100
|
0
|
|
|
|
|
|
chomp $text; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my $rootobj = $self->{rootobj}; |
103
|
0
|
|
|
|
|
|
$rootobj->push_displayevent( warning => { text => $text } ); |
104
|
0
|
|
|
|
|
|
$rootobj->bump_level( 2 ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 QUESTIONS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 How do I connect to freenode.net #perl and identify with NickServ |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# in Global tab |
112
|
|
|
|
|
|
|
/networks add -type irc Freenode |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# in Freenode tab |
115
|
|
|
|
|
|
|
/set nick YourNickHere |
116
|
|
|
|
|
|
|
/servers add irc.freenode.net -ident yournamehere -pass secretpasswordhere |
117
|
|
|
|
|
|
|
/connect |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Don't forget to |
120
|
|
|
|
|
|
|
/config save |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 How do I get notifications whenever someone uses the word perl in a channel that isn't on magnet or freenode#perl |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
/rules add input not(channel("#perl")) matches("perl"): highlight |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Rules are network-specific so just don't do that on Magnet. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 How do I set up a command to ban the hostmask for a given nick in the current channel for 24h |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
You'll have to read the hostmask of the user specifically, but then |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
/mode +b ident@host.name.here |
133
|
|
|
|
|
|
|
/delay 86400 mode -b ident@host.name.here |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Note the lack of C> on the inner C to C |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Paul Evans |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
0x55AA; |