Skip to content

Commit

Permalink
Merge pull request #323 from StampyAI/autopost-in-ai-safety-questions…
Browse files Browse the repository at this point in the history
…-channel

changed autoposting from meta-editing to AI safety questions channel
  • Loading branch information
MatthewBaggins authored Oct 1, 2023
2 parents 646f43b + 9790d7c commit 853e28b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from config import coda_api_token, is_rob_server
from servicemodules.discordConstants import (
general_channel_id,
meta_editing_channel_id,
ai_safety_questions_channel_id,
)
from modules.module import Module, Response
from utilities.utilities import (
Expand Down Expand Up @@ -415,15 +415,16 @@ async def autopost_not_started(self) -> None:
def is_time_for_autopost_wip(self) -> bool:
now = datetime.now()
return (
now.weekday() in (0, 2, 4) # Monday, Wednesday, or Friday
now.weekday() in (0, 4) # Monday or Friday
and 8 <= now.hour <= 12 # between 08:00 and 12:00
and self.last_wip_autopost_attempt_date
!= now.date() # Wasn't posted today yet
)

async def last_msg_in_meta_editing_was_autoposted(self) -> bool:
async def last_msg_in_ai_safety_questions_was_autoposted(self) -> bool:
channel = cast(
TextChannel, self.utils.client.get_channel(int(meta_editing_channel_id))
TextChannel,
self.utils.client.get_channel(int(ai_safety_questions_channel_id)),
)
async for msg in channel.history(limit=1):
if msg.content.startswith(self.AUTOPOST_STAGNANT_MSG_PREFIX):
Expand All @@ -436,7 +437,7 @@ async def autopost_wip(self) -> None:
today = date.today()
self.last_wip_autopost_attempt_date = today

if await self.last_msg_in_meta_editing_was_autoposted():
if await self.last_msg_in_ai_safety_questions_was_autoposted():
self.log.info(
self.class_name,
msg="Last message in `#meta-editing` was one or more autoposted WIP question(s) -> skipping autoposting",
Expand Down Expand Up @@ -475,7 +476,8 @@ async def autopost_wip(self) -> None:
self.coda_api.last_question_id = questions[0]["id"]

channel = cast(
TextChannel, self.utils.client.get_channel(int(meta_editing_channel_id))
TextChannel,
self.utils.client.get_channel(int(ai_safety_questions_channel_id)),
)
current_time = datetime.now()
msg = self.AUTOPOST_STAGNANT_MSG_PREFIX + "\n\n"
Expand Down

0 comments on commit 853e28b

Please sign in to comment.