integrations.web.parser

integrations/web/parser.py

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

メッセージ解析クラス

def parser(self, body: dict):
26    def parser(self, body: dict):
27        _ = body

メッセージ解析

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

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

Returns:

bool: 真偽値

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

botのポストかチェック

Returns:

bool: 真偽値

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

DB操作の許可チェック

Returns:

bool: 真偽値

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

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

Returns:

bool: 真偽値

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