Merge lp:~mhall119/classbot/pod into lp:classbot

Proposed by Michael Hall
Status: Needs review
Proposed branch: lp:~mhall119/classbot/pod
Merge into: lp:classbot
Diff against target: 298 lines (+162/-0)
1 file modified
classbot.pl (+162/-0)
To merge this branch: bzr merge lp:~mhall119/classbot/pod
Reviewer Review Type Date Requested Status
Nathan Handler Pending
Review via email: mp+55142@code.launchpad.net

Description of the change

Adds some initial POD code documentation

To post a comment you must log in.

Unmerged revisions

99. By Michael Hall

Initial perldoc documentation effort

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'classbot.pl'
2--- classbot.pl 2011-01-26 22:48:29 +0000
3+++ classbot.pl 2011-03-28 13:11:00 +0000
4@@ -1,5 +1,16 @@
5 #!/usr/bin/perl
6
7+=pod
8+
9+=head1 NAME
10+
11+classbot - Ubuntu Classroom Helper
12+
13+=head1 DESCRIPTION
14+
15+ClassBot is a bot to assist with the running of sessions in #ubuntu-classroom'
16+
17+=cut
18 use strict;
19 use vars qw($VERSION %IRSSI);
20 use LWP::Simple;
21@@ -532,6 +543,13 @@
22 }
23 }
24
25+=head1 EVENT HANDLERS
26+
27+=over
28+
29+=item client_join($server, $channel, $nick, $host)
30+
31+=cut
32 sub client_join {
33 my ($server, $channel, $nick, $host) = @_;
34 $channel =~ s/^://;
35@@ -628,6 +646,25 @@
36 $server->command("^MSG ChanServ TOPIC $chan $text");
37 }
38
39+=item event_privmsg($server, $data, $nick, $address)
40+
41+Handles private messages sent to the bot.
42+
43+=over
44+
45+=item server
46+
47+=item nick
48+
49+=item address
50+
51+=item data
52+
53+This comes as a string formatted as "B<target>: B<text>".
54+
55+=over
56+
57+=cut
58 sub event_privmsg {
59 # $data = "nick/#channel :text"
60 my ($server, $data, $nick, $address) = @_;
61@@ -638,6 +675,12 @@
62 utf8::decode($text);
63 utf8::decode($mynick);
64
65+=item QUESTION:
66+
67+When "target" is the question channel, and B<text> starts with the
68+ "QUESTION:" prefix, then "text" is added to the questions queue.
69+
70+=cut
71 #TRANSLATORS: QUESTION: is the prefix that must go before all questions in the -chat IRC channel ($qchan) for ClassBot to recognize them.
72 my $qprefix=$d->get("QUESTION:");
73 if($target =~ m/^$qchan$/i && $text =~ m/^$qprefix\s*(.*)$/i) {
74@@ -647,6 +690,18 @@
75 #TRANSLATORS: The first %s is the nickname of the person who asked the question. The second %s is the question that was asked.
76 push(@questions,sprintf($d->get("%s asked: %s"), $nick, $question));
77 }
78+
79+=item Commands
80+
81+When "target" is the nick of the bot, then B<text> is treated like a command.
82+
83+=over
84+
85+=item !logs
86+
87+When B<text> is B<!logs>, the bot will respond with links to the session logs.
88+
89+=cut
90 elsif($text =~ m/^!logs?\s*$/i) {
91 if($session !~ m/^\s*$/) {
92 for my $key ( keys %sessions ) {
93@@ -684,6 +739,12 @@
94 }
95 }
96 }
97+
98+=item !question, !q
99+
100+Shows the next question in the queue for the instructor to accept or reject.
101+
102+=cut
103 elsif($target =~ m/^$mynick$/i && ($leaders{lc($nick)} || $shelpers{lc($nick)} || $admins{lc($nick)}) && $text =~ m/^!(question|q)$/i) {
104 if($review ne '') {
105 Irssi::print("$nick must finish reviewing $review before they can do !question.") if($debug);
106@@ -706,6 +767,12 @@
107 #TRANSLATORS: The %s represents a special bot command (!question).
108 $server->command("^MSG $nick ".sprintf($d->get("You are not currently a session leader, so you cannot use %s."), "!question"));
109 }
110+
111+=item !yes, !y
112+
113+Tells the bot to post the next question in the queue into the classroom channel
114+
115+=cut
116 elsif($target =~ m/^$mynick$/i && ($leaders{lc($nick)} || $shelpers{lc($nick)} || $admins{lc($nick)}) && $text =~ m/^!(yes|y)$/i) {
117 if($review ne '') {
118 my($channel)=$server->channel_find($chan);
119@@ -729,6 +796,13 @@
120 #TRANSLATORS: The %s represents a special bot command (!yes).
121 $server->command("^MSG $nick ".sprintf($d->get("You are not currently a session leader, so you cannot use %s."), "!yes"));
122 }
123+
124+=item !no [reason], !n [reason]
125+
126+Rejects the next question in the queue, any text after the command will be
127+ posted into the questions channel as a reason for the rejection.
128+
129+=cut
130 elsif($target =~ m/^$mynick$/i && ($leaders{lc($nick)} || $shelpers{lc($nick)} || $admins{lc($nick)}) && $text =~ m/^!(no|n)\s*(.*?)$/i) {
131 my $comment = $2;
132 utf8::decode($comment);
133@@ -750,6 +824,12 @@
134 #TRANSLATORS: The %s represents a special bot command (!no).
135 $server->command("^MSG $nick ".sprintf($d->get("You are not currently a session leader, so you cannot use %s."), "!no"));
136 }
137+
138+=item !moderate, $m
139+
140+Toggles the classroom channel's moderation (+m) status.
141+
142+=cut
143 elsif($target =~ m/^$mynick$/i && ($leaders{lc($nick)} || $shelpers{lc($nick)} || $admins{lc($nick)}) && $text =~ m/^!(moderate|m)$/i) {
144 my($channel)=$server->channel_find($chan);
145 my($mode)=$channel->{'mode'};
146@@ -769,6 +849,12 @@
147 #TRANSLATORS: The %s represents a special bot command (!moderate).
148 $server->command("^MSG $nick ".sprintf($d->get("You are not currently a session leader, so you cannot use %s."), "!moderate"));
149 }
150+
151+=item !schedule, !s
152+
153+Returns the next 3 scheduled classroom sessions.
154+
155+=cut
156 elsif($target =~ m/^$mynick$/i && $text =~ m/^!(schedule|s)$/i) {
157 if($#sessions < 0) {
158 $server->command("MSG $nick ".$d->get("There are currently no scheduled classes."));
159@@ -777,6 +863,12 @@
160 $server->command("MSG $nick ".sprintf($d->get("The next 3 scheduled classroom sessions are: %s"), join(', ', @sessions)));
161 }
162 }
163+
164+=item !voice [person], !v [person]
165+
166+Gives the specified person voice (+v) in the classroom channel
167+
168+=cut
169 elsif($target =~ m/^$mynick$/i && $admins{lc($nick)} && $text =~ m/^!(voice|v)\s*(.*?)$/i) {
170 my $person = $2;
171 utf8::decode($person);
172@@ -793,6 +885,12 @@
173 #TRANSLATORS: The %s represents a special bot command (!voice).
174 $server->command("^MSG $nick ".sprintf($d->get("You are not currently an admin, so you cannot use %s."), "!voice"));
175 }
176+
177+=item !devoice [person], !dv [person]
178+
179+Removes voice (+v) from the specified person in the classroom channel
180+
181+=cut
182 elsif($target =~ m/^$mynick$/i && $admins{lc($nick)} && $text =~ m/^!(devoice|dv)\s*(.*?)$/i) {
183 my $person = $2;
184 utf8::decode($person);
185@@ -809,6 +907,12 @@
186 #TRANSLATORS: The %s represents a special bot command (!devoice).
187 $server->command("^MSG $nick ".sprintf($d->get("You are not currently an admin, so you cannot use %s."), "!devoice"));
188 }
189+
190+=item !calendar, !cal, !c
191+
192+Imports the classroom schedule from the ical source
193+
194+=cut
195 elsif($target =~ m/^$mynick$/i && $admins{lc($nick)} && $text =~ m/^!(calendar|cal|c)$/i) {
196 Irssi::print("Forced download of calendar triggered by $nick") if($debug);
197 $server->command("^MSG $nick ".$d->get("Forcing download of calendar."));
198@@ -820,6 +924,12 @@
199 #TRANSLATORS: The %s represents a special bot command (!calendar).
200 $server->command("^MSG $nick ".sprintf($d->get("You are not currently an admin, so you cannot use %s."), "!calendar"));
201 }
202+
203+=item !topic [text], !t [text]
204+
205+Sets the classroom channel topic to the given text.
206+
207+=cut
208 elsif($target =~ m/^$mynick$/i && $admins{lc($nick)} && $text =~ m/^!(topic|t)\s*(.*?)$/i) {
209 Irssi::print("Setting classroom_topic to: $2") if($debug);
210 Irssi::settings_set_str('classroom_topic', "$2");
211@@ -830,6 +940,12 @@
212 #TRANSLATORS: The %s represents a special bot command (!topic).
213 $server->command("^MSG $nick ".sprintf($d->get("You are not currently an admin, so you cannot use %s."), "!topic"));
214 }
215+
216+=item !qtopic [text], !qt [text]
217+
218+Sets the question channel topic to the given text.
219+
220+=cut
221 elsif($target =~ m/^$mynick$/i && $admins{lc($nick)} && $text =~ m/^!(qtopic|qt)\s*(.*?)$/i) {
222 Irssi::print("Setting classroom_qtopic to: $2") if($debug);
223 Irssi::settings_set_str('classroom_qtopic', "$2");
224@@ -840,6 +956,13 @@
225 #TRANSLATORS: The %s represents a special bot command (!qtopic).
226 $server->command("^MSG $nick ".sprintf($d->get("You are not currently an admin, so you cannot use %s."), "!qtopic"));
227 }
228+
229+=item !dent [msg]
230+
231+Sends the given message to Identi.ca using the bot's configured identi.ca
232+ username and password
233+
234+=cut
235 elsif($target =~ m/^$mynick$/i && $admins{lc($nick)} && $text =~ m/^!dent\s*(.*?)$/i) {
236 my $dent_text = $1;
237 utf8::decode($dent_text);
238@@ -858,6 +981,13 @@
239 #TRANSLATORS: The %s represents a special bot command (!dent).
240 $server->command("^MSG $nick ".sprintf($d->get("You are not currently an admin, so you cannot use %s."), "!dent"));
241 }
242+
243+=item !admin [msg]
244+
245+Sends a message to the backstage channel requesting assistance, along with an
246+ optional message.
247+
248+=cut
249 elsif($target =~ m/^$mynick$/i && $text =~ m/^!(admin|a)\s*(.*?)$/i) {
250 my $admin_msg = $2;
251 utf8::decode($admin_msg);
252@@ -881,6 +1011,17 @@
253 }
254 }
255
256+=back
257+
258+=back
259+
260+=back
261+
262+=item cmd_help($data, $server, $witem)
263+
264+Prints Classbot usage information
265+
266+=cut
267 sub cmd_help {
268 my($data, $server, $witem) = @_;
269
270@@ -900,7 +1041,28 @@
271 }
272 }
273
274+=back
275+
276+=cut
277 Irssi::signal_add("setup changed", "refresh_settings");
278 Irssi::signal_add("event privmsg", "event_privmsg");
279 Irssi::signal_add("message join", "client_join");
280 Irssi::command_bind_last('help', 'cmd_help');
281+
282+=head1 AUTHORS
283+
284+Nathan Handler <nhandler@ubuntu.com>
285+
286+L<https://launchpad.net/~nhandler>
287+
288+=head1 BUGS
289+
290+L<https://bugs.launchpad.net/classbot/>
291+
292+=head1 SEE ALSO
293+
294+L<Irssi>
295+
296+=head2 COPYRIGHT
297+
298+GNU GPL v3

Subscribers

People subscribed via source and target branches