Merge lp:~cjohnston/ubuntu-classroom/topic-event into lp:~ubuntu-classroom/ubuntu-classroom/classbot

Proposed by Chris Johnston
Status: Merged
Approved by: Nathan Handler
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~cjohnston/ubuntu-classroom/topic-event
Merge into: lp:~ubuntu-classroom/ubuntu-classroom/classbot
Diff against target: 160 lines (+59/-21)
1 file modified
classbot.pl (+59/-21)
To merge this branch: bzr merge lp:~cjohnston/ubuntu-classroom/topic-event
Reviewer Review Type Date Requested Status
Nathan Handler Approve
Review via email: mp+19680@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) wrote :

Adds Event Name to /topic dony by nhandler and fix to endless topic cycling by cjohnston

8. By Chris Johnston

Commit of /topic cycling fix

Revision history for this message
Nathan Handler (nhandler) :
review: Approve

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 2010-02-18 04:25:19 +0000
3+++ classbot.pl 2010-02-19 04:17:13 +0000
4@@ -20,7 +20,9 @@
5 Irssi::settings_add_str('classroom', 'classroom_questions', '');
6 Irssi::settings_add_str('classroom', 'classroom_channel', '');
7 Irssi::settings_add_str('classroom', 'classroom_session', '');
8-my ($leaders, $qchan, $chan, %leaders, $session, @questions, $review);
9+Irssi::settings_add_str('classroom', 'classroom_event', '');
10+#Added $current_session
11+my ($leaders, $qchan, $chan, %leaders, $session, @questions, $review, $event, $current_session);
12 &refresh_settings();
13
14 &sessions();
15@@ -37,12 +39,16 @@
16 }
17 $qchan = Irssi::settings_get_str('classroom_questions');
18 $chan = Irssi::settings_get_str('classroom_channel');
19- $session = Irssi::settings_get_str('classroom_session');
20+ #changed $session to $current_session
21+ $current_session = Irssi::settings_get_str('classroom_session');
22+ $event = Irssi::settings_get_str('classroom_event');
23
24 Irssi::print("Leaders: " . lc($leaders));
25 Irssi::print("qchan: $qchan");
26 Irssi::print("chan: $chan");
27+ #I don't know if this needs to be changed or not...
28 Irssi::print("Session: $session");
29+ Irssi::print("Event: $event");
30 }
31
32 sub sessions {
33@@ -51,31 +57,35 @@
34 my $content = get($url);
35 return unless defined $content;
36 my @events = $content =~ m/BEGIN:VEVENT.*?END:VEVENT/isg;
37- EVENT: foreach my $event (@events) {
38- my($dtstart) = $event=~m/DTSTART[;:](.*?)\n/i;
39+ EVENT: foreach my $session (@events) {
40+ my($dtstart) = $session=~m/DTSTART[;:](.*?)\n/i;
41 $dtstart=~s/[\n\r]//g;
42 my($dt_start) = DateTime::Format::ICal->parse_datetime($dtstart);
43- my($dtend) = $event=~m/DTEND[;:](.*?)\n/i;
44+ my($dtend) = $session=~m/DTEND[;:](.*?)\n/i;
45 $dtend=~s/[\n\r]//g;
46 my($dt_end) = DateTime::Format::ICal->parse_datetime($dtend);
47- my($location) = $event=~m/LOCATION:(.*?)\n/i;
48+ my($location) = $session=~m/LOCATION:(.*?)\n/i;
49 $location=~s/[\n\r]//g;
50 next EVENT if $location !~ m/\#ubuntu-classroom/i;
51- my($summary) = $event=~m/SUMMARY:(.*?)\n/i;
52+ my($summary) = $session=~m/SUMMARY:(.*?)\n/i;
53 $summary=~s/[\n\r]//g;
54- my($description) = $event=~m/DESCRIPTION:(.*?)\n\S/i;
55+ my($description) = $session=~m/DESCRIPTION:(.*?)\n\S/i;
56 $description=~s/[\n\r]//g;
57 my($instructors) = $description =~ m/Instructors?:\s*(.*?)$/i;
58 $instructors=~s/[\n\r]//g;
59 $instructors=~s/\\n.*?$//;
60 $instructors=~s/\s*\\?,\s*/, /g;
61+ my($event) = $description =~ m/Event:\s*(.*?)$/i;
62+ $event =~ s/[\n\r]//g;
63+ $event =~ s/\\n.*?$//;
64
65 my $now = DateTime->now();
66 if ($now >= $dt_start && $now < $dt_end) {
67 Irssi::print("Session Currently In Progress.");
68- my %event=();
69- $event{'summary'}=$summary;
70- $event{'instructors'}=$instructors;
71+ my %session=();
72+ $session{'summary'}=$summary;
73+ $session{'instructors'}=$instructors;
74+ $session{'event'}=$event;
75 if($leaders ne $instructors) { #If the instructors have changed
76 Irssi::print("New Instructors: $instructors");
77 Irssi::settings_set_str('classroom_leaders', $instructors);
78@@ -89,44 +99,72 @@
79 &moderate($chan,1);
80 Irssi::print("Session: $summary (instructors changed).");
81 Irssi::settings_set_str('classroom_session', $summary);
82+ Irssi::settings_set_str('classroom_event', $event);
83 &refresh_settings();
84 @questions=();
85 $review='';
86 if(keys(%leaders) > 1) { #If there is more than 1 instructor
87- &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders || Questions in #ubuntu-classroom-chat");
88- &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders");
89+ if($event !~ m/^\s*$/) { #If an event is going on
90+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructors: $leaders || Questions in #ubuntu-classroom-chat");
91+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructors: $leaders");
92+ }
93+ else {
94+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders || Questions in #ubuntu-classroom-chat");
95+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders");
96+ }
97 }
98 else {
99- &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors || Questions in #ubuntu-classroom-chat");
100- &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors");
101+ if($event !~ m/^\s*$/) { #If an event is going on
102+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructor: $instructors || Questions in #ubuntu-classroom-chat");
103+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructor: $instructors");
104+ }
105+ else {
106+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors || Questions in #ubuntu-classroom-chat");
107+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors");
108+ }
109 }
110 }
111- elsif($session ne $summary) { #If the session has changed, we need to update the /topic
112+ #Changed $session to $current_session
113+ elsif($current_session ne $summary) { #If the session has changed, we need to update the /topic
114 Irssi::print("New Session: $summary");
115 Irssi::settings_set_str('classroom_session', $summary);
116+ Irssi::settings_set_str('classroom_event', $event);
117 &refresh_settings();
118 @questions=();
119 $review='';
120 if(keys(%leaders) > 1) { #If there is more than 1 instructor
121- &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders || Questions in #ubuntu-classroom-chat");
122- &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders");
123+ if($event !~ m/^\s*$/) { #If an event is going on
124+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructors: $leaders || Questions in #ubuntu-classroom-chat");
125+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructors: $leaders");
126+ }
127+ else {
128+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders || Questions in #ubuntu-classroom-chat");
129+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructors: $leaders");
130+ }
131 }
132 else {
133- &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors || Questions in #ubuntu-classroom-chat");
134- &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors");
135+ if($event !~ m/^\s*$/) { #If an event is going on
136+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructor: $instructors || Questions in #ubuntu-classroom-chat");
137+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Event: $event - Current Session: $summary - Instructor: $instructors");
138+ }
139+ else {
140+ &topic($chan,"Welcome to the Ubuntu Classroom - http://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors || Questions in #ubuntu-classroom-chat");
141+ &topic($qchan,"Sessions in #ubuntu-classroom, chat and questions related to sessions here || Upcoming Schedule in #ubuntu-classroom: http://is.gd/8rtIi || Current Session: $summary - Instructor: $instructors");
142+ }
143 }
144 &moderate($chan,1);
145 }
146 return;
147 }
148 }
149- #If an event is not going on
150+ #If a session is not going on
151 Irssi::print("No Session Is In Progress.");
152 if($leaders=~m/^$/ && $session=~m/^$/) { #No session was going on
153 }
154 else {
155 Irssi::settings_set_str('classroom_leaders', '');
156 Irssi::settings_set_str('classroom_session', '');
157+ Irssi::settings_set_str('classroom_event', '');
158 &refresh_settings();
159 @questions=();
160 $review='';

Subscribers

People subscribed via source and target branches

to all changes: