From d6160f3ac142a4d606d76e59fdd4b4bcbc8155c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=AA=E3=82=B9=E3=82=AB=E3=83=BC=E3=80=81?= Date: Mon, 14 Oct 2024 20:09:51 +0900 Subject: [PATCH] fix: post problem --- .idea/Autopost.iml | 7 +++++++ exts/post.py | 8 ++++---- main.py | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.idea/Autopost.iml b/.idea/Autopost.iml index 2c80e12..893c971 100644 --- a/.idea/Autopost.iml +++ b/.idea/Autopost.iml @@ -7,4 +7,11 @@ + + + \ No newline at end of file diff --git a/exts/post.py b/exts/post.py index 40150b2..140673d 100644 --- a/exts/post.py +++ b/exts/post.py @@ -1,11 +1,11 @@ from datetime import datetime from mipa.ext import commands, tasks -from mipa.ext.commands.bot import Bot +from ..main import Autoposter class Post(commands.Cog): - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Autoposter) -> None: self.bot = bot self.visibility = bot.config.visibility or "home" self.rate = bot.config.rate or 30 @@ -23,10 +23,10 @@ class Post(commands.Cog): line = await self.bot.get_random_line() template = self.bot.config.note result = template.replace("{text}", line.text).replace("{from}", line.where).replace("{number}", line.number) - await self.bot.client.note.action.send(content=result, visibility=self.visibility) + await self.bot.client.note.action.send(text=result, visibility=self.visibility) -async def setup(bot: Bot): +async def setup(bot: Autoposter): cog = Post(bot) await bot.add_cog(cog) await cog._postLine.start() diff --git a/main.py b/main.py index cdb71a0..c8b00f1 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ import asyncio import json import random +from typing import Optional import gspread_asyncio from aiohttp import ClientWebSocketResponse @@ -77,7 +78,7 @@ class Autoposter(commands.Bot): worksheet = await spreadsheet.get_worksheet(0) return worksheet - async def get_random_line(self) -> Line: + async def get_random_line(self) -> Optional[Line]: sheet: Worksheet = await self.get_worksheet() response = await sheet.get("F4") if response is None or response == "": @@ -119,7 +120,7 @@ class Autoposter(commands.Bot): line: Line = await self.get_random_line() template = self.config.reply result = template.replace("{text}", line.text).replace("{from}", line.where).replace("{number}", line.number) - await notice.note.api.action.reply(content=result, visibility=notice.note.visibility, reply_id=notice.note.id) + await notice.note.api.action.reply(text=result, visibility=notice.note.visibility) if __name__ == '__main__':