From 9b7905f2fe98d21a855492c4f8f2ad259cce1902 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 4 Mar 2024 15:07:25 +0100 Subject: [PATCH 1/1] Support marking with orange. --- bin/sync.pl | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/sync.pl b/bin/sync.pl index 740d38f..23c5627 100644 --- a/bin/sync.pl +++ b/bin/sync.pl @@ -32,6 +32,12 @@ my %rgb = ( blue => 0, alpha => 1 }, + orange => { + red => 0xf9 / 255.0, + green => 0xcb / 255.0, + blue => 0x9c / 255.0, + alpha => 1 + }, blue => { red => 0, green => 1, @@ -344,7 +350,7 @@ sub best_name_for_log { sub create_reaction_log { my ($dbh, $invitation_ts, $slack_userid_to_real_name, $slack_userid_to_slack_name) = @_; - my $q = $dbh->prepare('select userid,event_type,reaction,to_char(event_ts,\'YYYY-mm-dd HH24:MI\') as event_ts from ( select distinct on (channel,ts,userid,reaction) userid,event_type,reaction,timestamptz \'1970-01-01 utc\' + event_ts::float * interval \'1 second\' as event_ts from reaction_log where channel=? and ts=? and reaction in (\'heart\',\'open_mouth\',\'blue_heart\') order by channel,ts,userid,reaction,event_ts desc ) t1 where event_ts > current_timestamp - interval \'8 hours\' order by event_ts desc limit 50'); + my $q = $dbh->prepare('select userid,event_type,reaction,to_char(event_ts,\'YYYY-mm-dd HH24:MI\') as event_ts from ( select distinct on (channel,ts,userid,reaction) userid,event_type,reaction,timestamptz \'1970-01-01 utc\' + event_ts::float * interval \'1 second\' as event_ts from reaction_log where channel=? and ts=? and reaction in (\'heart\',\'open_mouth\',\'blue_heart\',\'orange_heart\') order by channel,ts,userid,reaction,event_ts desc ) t1 where event_ts > current_timestamp - interval \'8 hours\' order by event_ts desc limit 50'); $q->execute($config::invitation_channel, $invitation_ts); my @recent_changes = (); while (my $ref = $q->fetchrow_hashref) { @@ -358,6 +364,8 @@ sub create_reaction_log { $msg .= '😮'; } elsif ($ref->{'reaction'} eq 'blue_heart') { $msg .= '💙'; + } elsif ($ref->{'reaction'} eq 'orange_heart') { + $msg .= '🧡'; } else { $msg .= '❤️'; } @@ -544,7 +552,7 @@ sub run { } # Find everyone who are marked as attending on Slack (via reactions). - $q = $dbh->prepare('SELECT DISTINCT userid,reaction FROM current_reactions WHERE channel=? AND ts=? AND reaction IN (\'heart\', \'open_mouth\', \'blue_heart\')'); + $q = $dbh->prepare('SELECT DISTINCT userid,reaction FROM current_reactions WHERE channel=? AND ts=? AND reaction IN (\'heart\', \'open_mouth\', \'blue_heart\', \'orange_heart\')'); $q->execute($config::invitation_channel, $invitation_ts); my @attending_userids = (); my %colors = (); @@ -553,12 +561,17 @@ sub run { my $userid = $ref->{'userid'}; push @attending_userids, $userid; if ($ref->{'reaction'} eq 'blue_heart') { - if (exists($colors{$userid}) && $colors{$userid} eq 'yellow') { + if (exists($colors{$userid}) && $colors{$userid} ne 'blue') { $double{$userid} = 1; } $colors{$userid} = 'blue'; + } elsif ($ref->{'reaction'} eq 'orange_heart') { + if (exists($colors{$userid}) && $colors{$userid} ne 'orange') { + $double{$userid} = 1; + } + $colors{$userid} = 'orange'; } else { - if (exists($colors{$userid}) && $colors{$userid} eq 'blue') { + if (exists($colors{$userid}) && $colors{$userid} ne 'yellow') { $double{$userid} = 1; } $colors{$userid} = 'yellow'; -- 2.39.2