@@ -24,15 +24,33 @@ use serenity::all::{
24
24
use serenity:: async_trait;
25
25
26
26
use super :: Task ;
27
+ <<<<<<< HEAD
27
28
use crate :: graphql:: models:: { Member , StreakWithMemberId } ;
28
29
use crate :: graphql:: queries:: { fetch_members , fetch_streaks , increment_streak , reset_streak } ;
29
30
use crate :: ids:: {
30
31
GROUP_FOUR_CHANNEL_ID , GROUP_ONE_CHANNEL_ID , GROUP_THREE_CHANNEL_ID , GROUP_TWO_CHANNEL_ID ,
31
32
STATUS_UPDATE_CHANNEL_ID ,
33
+ =======
34
+ use crate :: utils:: time:: time_until ;
35
+ use crate :: {
36
+ graphql:: {
37
+ models:: Member ,
38
+ queries:: { fetch_members , increment_streak , reset_streak } ,
39
+ } ,
40
+ >>>>>>> 948 e8e3 ( It now uses config-rs for configuration management instead of hard coded values)
32
41
} ;
33
42
use crate :: utils:: time:: time_until ;
34
43
44
+ <<<<<<< HEAD
35
45
/// Checks for status updates daily at 5 AM.
46
+ =======
47
+ const TITLE_URL : & str = & CONFIG . status_update. title_url;
48
+ const IMAGE_URL : & str = & CONFIG . status_update. image_url;
49
+ const AUTHOR_URL : & str = & CONFIG . status_update. author_url;
50
+ const ICON_URL : & str = & CONFIG . status_update. icon_url;
51
+
52
+ /// Checks for status updates daily at 9 AM.
53
+ >>>>>>> 948 e8e3 ( It now uses config-rs for configuration management instead of hard coded values)
36
54
pub struct StatusUpdateCheck ;
37
55
38
56
#[ async_trait]
@@ -78,6 +96,7 @@ async fn status_update_check(ctx: Context) -> anyhow::Result<()> {
78
96
Ok ( ( ) )
79
97
}
80
98
99
+ <<<<<<< HEAD
81
100
async fn get_updates ( ctx : & Context ) -> anyhow:: Result < Vec < Message > > {
82
101
let channel_ids = get_channel_ids ( ) ;
83
102
let mut updates = Vec :: new ( ) ;
@@ -105,6 +124,36 @@ fn get_channel_ids() -> Vec<ChannelId> {
105
124
fn is_valid_status_update ( msg : & Message ) -> bool {
106
125
let report_config = get_report_config( ) ;
107
126
let content = msg. content. to_lowercase( ) ;
127
+ =======
128
+ // TOOD: Get IDs through ENV instead
129
+ fn get_channel_ids ( ) -> anyhow:: Result < Vec < ChannelId > > {
130
+ Ok ( vec ! [
131
+ ChannelId :: new( CONFIG . channels. group_one) ,
132
+ ChannelId :: new( CONFIG . channels. group_two) ,
133
+ ChannelId :: new( CONFIG . channels. group_three) ,
134
+ ChannelId :: new( CONFIG . channels. group_four) ,
135
+ ] )
136
+ }
137
+
138
+
139
+ async fn send_and_save_limiting_messages (
140
+ channel_ids : & Vec < ChannelId > ,
141
+ ctx : & Context ,
142
+ ) -> anyhow:: Result < ( ) > {
143
+ trace ! ( "Running send_and_save_limiting_messages()" ) ;
144
+ let mut msg_ids: Vec < MessageId > = vec ! [ ] ;
145
+ for channel_id in channel_ids {
146
+ debug ! ( "Sending message in {}" , channel_id) ;
147
+ let msg = channel_id
148
+ . say(
149
+ & ctx. http ,
150
+ "Collecting messages for status update report. Please do not delete this message." ,
151
+ )
152
+ . await
153
+ . with_context( || {
154
+ anyhow:: anyhow!( "Failed to send limiting message in channel {}" , channel_id)
155
+ } ) ?;
156
+ >>>>>>> 948e8 e3 ( It now uses config-rs for configuration management instead of hard coded values)
108
157
109
158
let is_within_timeframe = DateTime :: < Utc > :: from_timestamp ( msg. timestamp. timestamp ( ) , 0 )
110
159
. expect( "Valid timestamp" )
@@ -214,10 +263,40 @@ async fn generate_embed(
214
263
description. push_str( & format_defaulters( & naughty_list) ) ;
215
264
}
216
265
266
+ <<<<<<< HEAD
217
267
let embed = CreateEmbed :: new ( )
218
268
. title( "Status Update Report" )
219
269
. description( description)
220
270
. color( serenity:: all:: Colour :: new( 0xeab308 ) ) ;
271
+ =======
272
+ let description = build_description(
273
+ highest_streak,
274
+ all_time_high,
275
+ & highest_streak_members,
276
+ & all_time_high_members,
277
+ & record_breakers,
278
+ & naughty_list,
279
+ ) ;
280
+ let today = chrono:: Local :: now ( )
281
+ . with_timezone ( & Asia :: Kolkata )
282
+ . date_naive( ) ;
283
+
284
+ let mut embed = CreateEmbed :: default( )
285
+ . title( format ! ( "Status Update Report - {}" , today) )
286
+ . url( & CONFIG . status_update. title_url)
287
+ . description( description)
288
+ . color( serenity:: all:: Colour :: new( 0xeab308 ) )
289
+ . timestamp( Timestamp :: now( ) )
290
+ . author(
291
+ CreateEmbedAuthor :: new( "amD" )
292
+ . url( & CONFIG . status_update. author_url)
293
+ . icon_url( & CONFIG . status_update. icon_url) ,
294
+ ) ;
295
+
296
+ if naughty_list. is_empty( ) {
297
+ embed = embed. image( & CONFIG . status_update. image_url) ;
298
+ }
299
+ >>>>>>> 948e8 e3 ( It now uses config-rs for configuration management instead of hard coded values)
221
300
222
301
Ok ( embed)
223
302
}
0 commit comments