comment¶
- PyPtt.API.comment(self, board: str, comment_type: CommentType, content: str, aid: str | None = None, index: int = 0) None
推文。
- 參數:
board (str) -- 看板名稱。
comment_type (CommentType) -- 推文類型。
content (str) -- 推文內容。
aid (str) -- 文章編號。
index (int) -- 文章編號。
- 回傳:
None
- 引發:
UnregisteredUser -- 未註冊使用者。
RequireLogin -- 需要登入。
NoSuchBoard -- 看板不存在。
NoSuchPost -- 文章不存在。
NoPermission -- 沒有推文權限。
NoFastComment -- 推文間隔太短。
範例:
import PyPtt ptt_bot = PyPtt.API() try: # .. login .. ptt_bot.comment(board='Test', comment_type=PyPtt.CommentType.PUSH, content='Comment by index', index=123) ptt_bot.comment(board='Test', comment_type=PyPtt.CommentType.PUSH, content='Comment by index', aid='17MrayxF') # .. do something .. finally: ptt_bot.logout()