Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
feat: executor supporting block90
Browse files Browse the repository at this point in the history
  • Loading branch information
lumina37 committed Feb 24, 2024
1 parent 6445f20 commit 62b2329
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion aiotieba_reviewer/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.1"
__version__ = "0.4.2a0"
2 changes: 1 addition & 1 deletion aiotieba_reviewer/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any, Callable, Final, List, Optional, Tuple, Union

import aiomysql
from aiotieba.logging import get_logger as LOG
from aiotieba import get_logger as LOG
from aiotieba.typing import UserInfo

from .config import DB_CONFIG
Expand Down
11 changes: 9 additions & 2 deletions aiotieba_reviewer/executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Awaitable, Callable, Optional

from aiotieba.logging import get_logger as LOG
import aiotieba as tb
from aiotieba import get_logger as LOG

from .client import get_client, get_fname
from .enums import Ops
Expand All @@ -12,7 +13,13 @@
async def default_punish_executor(punish: Punish) -> Optional[Punish]:
if day := punish.day:
client = await get_client()
await client.block(get_fname(), punish.obj.user.portrait, day=day, reason=punish.note)
ret = await client.block(get_fname(), punish.obj.user.portrait, day=day, reason=punish.note)
if isinstance(ret.err, tb.exception.TiebaServerError):
if ret.err.code == 1211068:
await client.unblock(get_fname(), punish.obj.user.user_id)
await client.block(get_fname(), punish.obj.user.portrait, day=day, reason=punish.note)
elif ret.err.code == 3150003:
await client.block(get_fname(), punish.obj.user.portrait, day=10, reason=punish.note)

op = punish.op
if op == Ops.NORMAL:
Expand Down
2 changes: 1 addition & 1 deletion aiotieba_reviewer/imgproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import cv2 as cv
import numpy as np
from aiotieba.logging import get_logger as LOG
from aiotieba import get_logger as LOG

from .client import get_db

Expand Down
2 changes: 1 addition & 1 deletion aiotieba_reviewer/reviewer/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Generator, List, NoReturn, Optional

from aiotieba.enums import PostSortType
from aiotieba.logging import get_logger as LOG
from aiotieba import get_logger as LOG

from .. import client, executor
from ..client import get_client
Expand Down
2 changes: 1 addition & 1 deletion aiotieba_reviewer/reviewer/thread/runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Awaitable, Callable

from aiotieba.logging import get_logger as LOG
from aiotieba import get_logger as LOG

from ... import executor
from ...perf_stat import aperf_stat
Expand Down
2 changes: 1 addition & 1 deletion aiotieba_reviewer/reviewer/threads/runner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
from typing import Awaitable, Callable

from aiotieba.logging import get_logger as LOG
from aiotieba import get_logger as LOG

from ... import executor
from ...perf_stat import aperf_stat
Expand Down
2 changes: 1 addition & 1 deletion aiotieba_reviewer/reviewer/user_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async def _(obj: TypeObj) -> Optional[Punish]:
db = await get_db()
permission = await db.get_user_id(obj.user.user_id)
if permission <= -5:
return Punish(obj, Ops.DELETE, 10, "黑名单")
return Punish(obj, Ops.DELETE, 90, "黑名单")
if permission >= 1:
return Punish(obj, Ops.NORMAL)
return await func(obj)
Expand Down
8 changes: 6 additions & 2 deletions examples/cmd_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,12 @@ async def cmd_block(self, ctx: Context) -> None:
note = ctx.args[1] if len(ctx.args) > 1 else ctx.note

success = await ctx.admin.block(ctx.fname, user.portrait, day=day, reason=note)
if isinstance(success.err, tb.exception.TiebaServerError) and success.err.code == 3150003:
success = await ctx.admin.block(ctx.fname, user.portrait, day=10, reason=note)
if isinstance(success.err, tb.exception.TiebaServerError):
if success.err.code == 3150003:
success = await ctx.admin.block(ctx.fname, user.portrait, day=10, reason=note)
elif success.err.code == 1211068:
await ctx.admin.unblock(ctx.fname, user.user_id)
success = await ctx.admin.block(ctx.fname, user.portrait, day=10, reason=note)
if success:
await ctx.admin.del_post(ctx.fname, ctx.tid, ctx.pid)

Expand Down

0 comments on commit 62b2329

Please sign in to comment.