@@ -30,30 +30,58 @@ export class ScheduleCommand implements ICommand {
30
30
await this . scheduler . reset ( ) ;
31
31
await this . client . sendNotice ( roomId , "Schedule processing has been reset." ) ;
32
32
} else if ( args [ 0 ] === 'view' ) {
33
- const upcoming = sortTasks ( this . scheduler . inspect ( ) ) ;
34
- let html = "Upcoming tasks:<ul>" ;
35
- for ( const task of upcoming ) {
36
- const hasTalkRoom = this . conference . getTalk ( task . talk . id ) !== undefined ;
37
- const taskStart = moment ( getStartTime ( task ) ) ;
38
- const formattedTimestamp = taskStart . format ( "YYYY-MM-DD HH:mm:ss [UTC]ZZ" ) ;
39
-
40
- if ( html . length > 20000 ) {
41
- // chunk up the message so we don't fail to send one very large event.
42
- html += "</ul>" ;
43
- await this . client . sendHtmlNotice ( roomId , html ) ;
44
- html = "…<ul>" ;
45
- }
46
-
47
- const hasRoomIndicator = hasTalkRoom ? 'has talk room' : 'no talk room' ;
48
- html += `<li>${ formattedTimestamp } : <b>${ task . type } on ${ task . talk . title } </b> (<code>${ task . id } </code>, ${ hasRoomIndicator } ) ${ taskStart . fromNow ( ) } </li>` ;
49
- }
50
- html += "</ul>" ;
51
- await this . client . sendHtmlNotice ( roomId , html ) ;
33
+ await this . printUpcomingTasks ( roomId ) ;
34
+ } else if ( args [ 0 ] === 'debug' ) {
35
+ await this . printUpcomingTasks ( roomId ) ;
36
+ await this . printCompletedTasks ( roomId ) ;
52
37
} else if ( args [ 0 ] === 'execute' ) {
53
38
await this . scheduler . execute ( args [ 1 ] ) ;
54
39
await this . client . unstableApis . addReactionToEvent ( roomId , event [ 'event_id' ] , '✅' ) ;
55
40
} else {
56
41
await this . client . sendNotice ( roomId , "Unknown schedule command." ) ;
57
42
}
58
43
}
44
+
45
+ private async printUpcomingTasks ( roomId : string ) {
46
+ const upcoming = sortTasks ( this . scheduler . inspect ( ) ) ;
47
+ let html = "Upcoming tasks:<ul>" ;
48
+ for ( const task of upcoming ) {
49
+ const hasTalkRoom = this . conference . getTalk ( task . talk . id ) !== undefined ;
50
+ const taskStart = moment ( getStartTime ( task ) ) ;
51
+ const formattedTimestamp = taskStart . format ( "YYYY-MM-DD HH:mm:ss [UTC]ZZ" ) ;
52
+
53
+ if ( html . length > 20000 ) {
54
+ // chunk up the message so we don't fail to send one very large event.
55
+ html += "</ul>" ;
56
+ await this . client . sendHtmlNotice ( roomId , html ) ;
57
+ html = "…<ul>" ;
58
+ }
59
+
60
+ const hasRoomIndicator = hasTalkRoom ? 'has talk room' : 'no talk room' ;
61
+ html += `<li>${ formattedTimestamp } : <b>${ task . type } on ${ task . talk . title } </b> (<code>${ task . id } </code>, ${ hasRoomIndicator } ) ${ taskStart . fromNow ( ) } </li>` ;
62
+ }
63
+ html += "</ul>" ;
64
+ await this . client . sendHtmlNotice ( roomId , html ) ;
65
+ }
66
+
67
+ private async printCompletedTasks ( roomId : string ) {
68
+ const completed = this . scheduler . inspectCompleted ( ) ;
69
+ let html = "Completed tasks:<ul>" ;
70
+ completed . sort ( ) ;
71
+
72
+ for ( const taskId of completed ) {
73
+ if ( html . length > 20000 ) {
74
+ // chunk up the message so we don't fail to send one very large event.
75
+ html += "</ul>" ;
76
+ await this . client . sendHtmlNotice ( roomId , html ) ;
77
+ html = "…<ul>" ;
78
+ }
79
+
80
+ html += `<li>${ taskId } </li>` ;
81
+ }
82
+
83
+ html += "</ul>" ;
84
+
85
+ await this . client . sendHtmlNotice ( roomId , html ) ;
86
+ }
59
87
}
0 commit comments