| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bot::Cobalt::Core::ContextMeta::Auth; |
|
2
|
|
|
|
|
|
|
$Bot::Cobalt::Core::ContextMeta::Auth::VERSION = '0.021003'; |
|
3
|
6
|
|
|
6
|
|
13987
|
use strictures 2; |
|
|
6
|
|
|
|
|
1175
|
|
|
|
6
|
|
|
|
|
206
|
|
|
4
|
6
|
|
|
6
|
|
917
|
use Carp; |
|
|
6
|
|
|
|
|
7
|
|
|
|
6
|
|
|
|
|
335
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
352
|
use Bot::Cobalt::Common ':types'; |
|
|
6
|
|
|
|
|
6
|
|
|
|
6
|
|
|
|
|
36
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
491
|
use Moo; |
|
|
6
|
|
|
|
|
6187
|
|
|
|
6
|
|
|
|
|
36
|
|
|
10
|
|
|
|
|
|
|
extends 'Bot::Cobalt::Core::ContextMeta'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
around add => sub { |
|
14
|
|
|
|
|
|
|
my ($orig, $self) = splice @_, 0, 2; |
|
15
|
|
|
|
|
|
|
## auth->add( |
|
16
|
|
|
|
|
|
|
## Context => $context, |
|
17
|
|
|
|
|
|
|
## Username => $username, |
|
18
|
|
|
|
|
|
|
## Host => $host, |
|
19
|
|
|
|
|
|
|
## Level => $level, |
|
20
|
|
|
|
|
|
|
## Flags => $flags, |
|
21
|
|
|
|
|
|
|
## Alias => $plugin_alias |
|
22
|
|
|
|
|
|
|
## ) |
|
23
|
|
|
|
|
|
|
my %args = @_; |
|
24
|
|
|
|
|
|
|
$args{lc $_} = delete $args{$_} for keys %args; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
for my $required (qw/context nickname username host level/) { |
|
27
|
|
|
|
|
|
|
unless (defined $args{$required}) { |
|
28
|
|
|
|
|
|
|
carp "add() missing mandatory opt $required"; |
|
29
|
|
|
|
|
|
|
return |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$args{alias} = scalar caller unless defined $args{alias}; |
|
34
|
|
|
|
|
|
|
$args{flags} = {} unless defined $args{flags}; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $meta = { |
|
37
|
|
|
|
|
|
|
Alias => $args{alias}, |
|
38
|
|
|
|
|
|
|
Username => $args{username}, |
|
39
|
|
|
|
|
|
|
Host => $args{host}, |
|
40
|
|
|
|
|
|
|
Level => $args{level}, |
|
41
|
|
|
|
|
|
|
Flags => $args{flags}, |
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$self->$orig($args{context}, $args{nickname}, $meta) |
|
45
|
|
|
|
|
|
|
}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub level { |
|
48
|
1
|
|
|
1
|
1
|
2
|
my ($self, $context, $nickname) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return 0 |
|
51
|
|
|
|
|
|
|
unless defined $context |
|
52
|
|
|
|
|
|
|
and defined $nickname |
|
53
|
|
|
|
|
|
|
and exists $self->_list->{$context} |
|
54
|
1
|
50
|
33
|
|
|
34
|
and ref $self->_list->{$context}->{$nickname}; |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
50
|
|
|
36
|
$self->_list->{$context}->{$nickname}->{Level} // 0 |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub set_flag { |
|
60
|
1
|
|
|
1
|
1
|
268
|
my ($self, $context, $nickname, $flag) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return |
|
63
|
|
|
|
|
|
|
unless defined $context |
|
64
|
|
|
|
|
|
|
and defined $nickname |
|
65
|
|
|
|
|
|
|
and $flag |
|
66
|
|
|
|
|
|
|
and exists $self->_list->{$context} |
|
67
|
1
|
50
|
33
|
|
|
33
|
and exists $self->_list->{$context}->{$nickname}; |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
40
|
$self->_list->{$context}->{$nickname}->{Flags}->{$flag} = 1 |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub drop_flag { |
|
73
|
1
|
|
|
1
|
1
|
268
|
my ($self, $context, $nickname, $flag) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
return |
|
76
|
|
|
|
|
|
|
unless defined $context |
|
77
|
|
|
|
|
|
|
and defined $nickname |
|
78
|
|
|
|
|
|
|
and $flag |
|
79
|
|
|
|
|
|
|
and exists $self->_list->{$context} |
|
80
|
1
|
50
|
33
|
|
|
28
|
and exists $self->_list->{$context}->{$nickname}; |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
34
|
delete $self->_list->{$context}->{$nickname}->{Flags}->{$flag} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub has_flag { |
|
86
|
3
|
|
|
3
|
1
|
891
|
my ($self, $context, $nickname, $flag) = @_; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return |
|
89
|
|
|
|
|
|
|
unless defined $context |
|
90
|
|
|
|
|
|
|
and defined $nickname |
|
91
|
|
|
|
|
|
|
and $flag |
|
92
|
|
|
|
|
|
|
and exists $self->_list->{$context} |
|
93
|
3
|
50
|
33
|
|
|
109
|
and exists $self->_list->{$context}->{$nickname}; |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
3
|
|
|
|
|
99
|
$self->_list->{$context}->{$nickname}->{Flags}->{$flag} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub flags { |
|
99
|
0
|
|
|
0
|
1
|
0
|
my ($self, $context, $nickname) = @_; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
return +{} unless exists $self->_list->{$context} |
|
102
|
|
|
|
|
|
|
and ref $self->_list->{$context}->{$nickname} |
|
103
|
|
|
|
|
|
|
and ref $self->_list->{$context}->{$nickname}->{Flags} |
|
104
|
0
|
0
|
0
|
|
|
0
|
and reftype $self->_list->{$context}->{$nickname}->{Flags} eq 'HASH'; |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$self->_list->{$context}->{$nickname}->{Flags} |
|
107
|
0
|
|
|
|
|
0
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
6
|
|
|
6
|
|
5059
|
{ no warnings 'once'; *user = *username } |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
1434
|
|
|
110
|
|
|
|
|
|
|
sub username { |
|
111
|
2
|
|
|
2
|
1
|
276
|
my ($self, $context, $nickname) = @_; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
return |
|
114
|
|
|
|
|
|
|
unless defined $context |
|
115
|
|
|
|
|
|
|
and defined $nickname |
|
116
|
|
|
|
|
|
|
and exists $self->_list->{$context} |
|
117
|
2
|
50
|
33
|
|
|
50
|
and ref $self->_list->{$context}->{$nickname}; |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$self->_list->{$context}->{$nickname}->{Username} |
|
120
|
2
|
|
|
|
|
71
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub host { |
|
123
|
1
|
|
|
1
|
1
|
272
|
my ($self, $context, $nickname) = @_; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
return |
|
126
|
|
|
|
|
|
|
unless defined $context |
|
127
|
|
|
|
|
|
|
and defined $nickname |
|
128
|
|
|
|
|
|
|
and exists $self->_list->{$context} |
|
129
|
1
|
50
|
33
|
|
|
30
|
and ref $self->_list->{$context}->{$nickname}; |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
$self->_list->{$context}->{$nickname}->{Host} |
|
132
|
1
|
|
|
|
|
37
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub alias { |
|
135
|
1
|
|
|
1
|
0
|
270
|
my ($self, $context, $nickname) = @_; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
return |
|
138
|
|
|
|
|
|
|
unless defined $context |
|
139
|
|
|
|
|
|
|
and defined $nickname |
|
140
|
|
|
|
|
|
|
and exists $self->_list->{$context} |
|
141
|
1
|
50
|
33
|
|
|
25
|
and ref $self->_list->{$context}->{$nickname}; |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$self->_list->{$context}->{$nickname}->{Alias} |
|
144
|
1
|
|
|
|
|
36
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub move { |
|
147
|
1
|
|
|
1
|
1
|
267
|
my ($self, $context, $old, $new) = @_; |
|
148
|
|
|
|
|
|
|
## User changed nicks, f.ex |
|
149
|
|
|
|
|
|
|
|
|
150
|
1
|
50
|
|
|
|
20
|
return unless exists $self->_list->{$context}->{$old}; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
$self->_list->{$context}->{$new} |
|
153
|
1
|
|
|
|
|
18
|
= delete $self->_list->{$context}->{$old} |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |
|
158
|
|
|
|
|
|
|
__END__ |