integrations.web.parser

integrations/web/parser.py

 1"""
 2integrations/web/parser.py
 3"""
 4
 5from typing import Any
 6
 7from integrations.base.interface import MessageParserDataMixin, MessageParserInterface
 8from integrations.protocols import MsgData, PostData, StatusData
 9from libs.types import MessageStatus
10
11
12class MessageParser(MessageParserDataMixin, MessageParserInterface):
13    """メッセージ解析クラス"""
14
15    data: MsgData
16    post: PostData
17    status: StatusData
18
19    def __init__(self) -> None:
20        MessageParserDataMixin.__init__(self)
21        self.data = MsgData()
22        self.post = PostData()
23        self.status = StatusData()
24        self.data.status = MessageStatus.APPEND
25        self.status.command_flg = False
26
27    def parser(self, body: dict[str, Any]) -> None:
28        _ = body
29
30    @property
31    def in_thread(self) -> bool:
32        return False
33
34    @property
35    def is_bot(self) -> bool:
36        return False
37
38    @property
39    def check_updatable(self) -> bool:
40        return True
41
42    @property
43    def ignore_user(self) -> bool:
44        return False
13class MessageParser(MessageParserDataMixin, MessageParserInterface):
14    """メッセージ解析クラス"""
15
16    data: MsgData
17    post: PostData
18    status: StatusData
19
20    def __init__(self) -> None:
21        MessageParserDataMixin.__init__(self)
22        self.data = MsgData()
23        self.post = PostData()
24        self.status = StatusData()
25        self.data.status = MessageStatus.APPEND
26        self.status.command_flg = False
27
28    def parser(self, body: dict[str, Any]) -> None:
29        _ = body
30
31    @property
32    def in_thread(self) -> bool:
33        return False
34
35    @property
36    def is_bot(self) -> bool:
37        return False
38
39    @property
40    def check_updatable(self) -> bool:
41        return True
42
43    @property
44    def ignore_user(self) -> bool:
45        return False

メッセージ解析クラス

def parser(self, body: dict[str, typing.Any]) -> None:
28    def parser(self, body: dict[str, Any]) -> None:
29        _ = body

メッセージ解析

Arguments:
  • body (Any): 解析データ
in_thread: bool
31    @property
32    def in_thread(self) -> bool:
33        return False

元メッセージへのリプライとなっているか

Returns:

bool: 真偽値

  • True: リプライの形(リプライ/スレッドなど)
  • False: 通常メッセージ
is_bot: bool
35    @property
36    def is_bot(self) -> bool:
37        return False

botのポストかチェック

Returns:

bool: 真偽値

  • True: botのポスト
  • False: ユーザのポスト
check_updatable: bool
39    @property
40    def check_updatable(self) -> bool:
41        return True

DB操作の許可チェック

Returns:

bool: 真偽値

  • True: 許可
  • False: 禁止
ignore_user: bool
43    @property
44    def ignore_user(self) -> bool:
45        return False

ignore_useridに存在するユーザかチェック

Returns:

bool: 真偽値

  • True: 存在する(操作禁止ユーザ)
  • False: 存在しない