refactor: move get line to main
This commit is contained in:
parent
eff7634e83
commit
48fd87a8dc
@ -11,23 +11,11 @@ class Autopost(commands.Cog):
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user