1
0

refactor: move get line to main

This commit is contained in:
オスカー、 2023-11-23 15:40:16 +09:00 committed by GitHub
parent eff7634e83
commit 48fd87a8dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,24 +10,12 @@ class Autopost(commands.Cog):
def __init__(self, bot: Bot) -> None:
self.bot = bot
self.posted = []
def get_line(self) -> str:
sheet: Worksheet = self.bot.get_worksheet()
response = sheet.get("F4")
if response is None or response == "":
return
count = int(response[0][0])
result = random.randint(1, count)
number = result + 2
res = sheet.get(f"D{number}")
text = res[0][0].strip()
return text
@tasks.loop(seconds=1800)
async def _postLine(self) -> None:
line = self.get_line()
line = self.bot.get_line()
while line in self.posted:
line = self.get_line()
line = self.bot.get_line()
await self.bot.client.note.action.send(content=line, visibility="home")
self.posted.append(line)
if len(self.posted) > self.bot.max_count:
@ -37,4 +25,4 @@ class Autopost(commands.Cog):
async def setup(bot: Bot):
cog = Autopost(bot)
await cog._postLine.start()
await bot.add_cog(cog)
await bot.add_cog(cog)