File tree Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Expand file tree Collapse file tree 4 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 9292 - name : Display the public key
9393 debug :
9494 msg : " For private repositories, make sure to put this key as deploy key on github: {{ deploy_key.content | b64decode }}"
95+
96+ - name : Install cron
97+ apt :
98+ name : cron
99+ state : present
100+ update_cache : yes
101+
102+ - name : Enable cron service
103+ service :
104+ name : cron
105+ enabled : yes
106+ state : started
95107
Original file line number Diff line number Diff line change 4545 - name : Migrate on prod
4646 shell : " make prod/migrate"
4747
48+ - name : Configure scheduled message for standup
49+ become : yes
50+ cron :
51+ name : " Monday standup message"
52+ user : " {{ app_user }}"
53+ minute : " 0"
54+ hour : " 11"
55+ weekday : " 1"
56+ job : " cd /home/{{ app_user }} && docker compose exec -T app make in-container/manage ARG='send_scheduled_message --type=standup'"
57+ state : present
58+
4859 - name : Restart everything and finish
4960 shell : " docker compose up -d"
Original file line number Diff line number Diff line change 1+ """
2+ Factory functions for scheduled messages
3+ """
4+
5+ from typing import Dict , Callable
6+
7+ from django .utils import timezone
8+
9+ from core .models import DiscordMessage
10+ from core .bot .channel_router import Channels
11+
12+
13+ def standup_message_factory () -> DiscordMessage :
14+ """Factory for weekly standup message."""
15+ today = timezone .now ()
16+ week_number = today .isocalendar ()[1 ]
17+
18+ content = (
19+ f"## Monday Standup - Week { week_number } \n \n "
20+ f"Good morning team! Please share:\n \n "
21+ f"1. What you accomplished last week\n "
22+ f"2. What you're planning for this week\n "
23+ f"3. Any blockers or assistance needed"
24+ )
25+
26+ # Using the test channel for now - replace with appropriate channel later
27+ channel = Channels .test_channel
28+
29+ return DiscordMessage (
30+ channel_id = channel .channel_id ,
31+ channel_name = channel .channel_name ,
32+ content = content ,
33+ sent_at = None
34+ )
35+
36+
37+ # Registry of message factories
38+ MESSAGE_FACTORIES : Dict [str , Callable [[], DiscordMessage ]] = {
39+ "standup" : standup_message_factory ,
40+ }
Original file line number Diff line number Diff line change 1+ from django .core .management .base import BaseCommand
2+
3+ from core .bot .scheduled_messages import MESSAGE_FACTORIES
4+
5+
6+ class Command (BaseCommand ):
7+ help = "Sends a scheduled message to Discord"
8+
9+ def add_arguments (self , parser ):
10+ parser .add_argument (
11+ "--type" ,
12+ required = True ,
13+ choices = MESSAGE_FACTORIES .keys (),
14+ help = "Message type to send"
15+ )
16+
17+ def handle (self , * args , ** options ):
18+ message_type = options ["type" ]
19+
20+ factory = MESSAGE_FACTORIES [message_type ]
21+ message = factory ()
22+ message .save ()
23+
24+ self .stdout .write (
25+ self .style .SUCCESS (
26+ f"Scheduled '{ message_type } ' message for channel { message .channel_name } "
27+ )
28+ )
You can’t perform that action at this time.
0 commit comments