integrations.protocols module

integrations/protocols.py

class integrations.protocols.DataMixin

Bases: object

共通処理

reset()

デフォルト値にリセット

Return type:

None

class integrations.protocols.MessageParserProtocol

Bases: Protocol

メッセージ解析クラス

__init__(*args, **kwargs)
property argument: list[str]

コマンド引数として認識しているオプションを文字列のリストで返す

property check_updatable: bool

DB更新可能チャンネルか判定

data: MsgData

受け取ったメッセージデータ

property ignore_user: bool

コマンドを拒否するユーザか判定

property in_thread: bool

スレッド内のメッセージか判定

property is_bot: bool

botによる操作かチェック

Returns:

真偽値

  • True: botが操作

  • False: ユーザが操作

Return type:

bool

property is_command: bool

コマンドとして実行されたかチェック

Returns:

真偽値

  • True: スラッシュコマンド

  • False: チャンネル内呼び出しキーワード

Return type:

bool

property keyword: str

コマンドとして認識している文字列を返す

parser(body)

メッセージ解析メソッド

Parameters:

body (Any)

Return type:

None

post: PostData

送信する内容

property reply_ts: str

リプライ先のタイムスタンプ

reset()

状態リセット

Return type:

None

set_headline(data, options)

ヘッドラインメッセージをセット

Parameters:
Return type:

None

set_message(data, options)

本文メッセージをセット

Parameters:
Return type:

None

status: StatusData

処理した結果

class integrations.protocols.MsgData

Bases: DataMixin

ポストされたメッセージデータ

__init__(text='', event_ts='undetermined', thread_ts='undetermined', edited_ts='undetermined', channel_id='', channel_type=ChannelType.UNDETERMINED, user_id='', status=MessageStatus.UNDETERMINED, reaction_ok=<factory>, reaction_ng=<factory>, remarks=<factory>)
Parameters:
  • text (str)

  • event_ts (str)

  • thread_ts (str)

  • edited_ts (str)

  • channel_id (str)

  • channel_type (ChannelType)

  • user_id (str)

  • status (MessageStatus)

  • reaction_ok (list[str])

  • reaction_ng (list[str])

  • remarks (list[str])

Return type:

None

channel_id: str = ''

チャンネルID

channel_type: ChannelType = 'undetermined'

チャンネルタイプ

edited_ts: str = 'undetermined'

イベント編集タイムスタンプ

event_ts: str = 'undetermined'

イベント発生タイムスタンプ

reaction_ng: list[str]

NGリアクションデータ格納用

reaction_ok: list[str]

OKリアクションデータ格納用

remarks: list[str]

メモ格納用

status: MessageStatus = 'undetermined'

イベントステータス

text: str = ''

本文

thread_ts: str = 'undetermined'

スレッド元タイムスタンプ

  • 0: スレッドになっていない

  • undetermined: 未定義状態

user_id: str = ''

ユーザーID

class integrations.protocols.PostData

Bases: DataMixin

ポストするデータ

__init__(headline=None, message=<factory>, thread=True, ts='undetermined', thread_title='')
Parameters:
Return type:

None

headline: tuple[MessageType, StyleOptions] | None = None

ヘッダメッセージ

message: list[tuple[MessageType, StyleOptions]]

本文メッセージ

thread: bool = True

スレッドに返す

thread_title: str = ''

スレッドに付けるタイトル

ts: str = 'undetermined'

指定タイムスタンプへの強制リプライ

class integrations.protocols.StatusData

Bases: DataMixin

処理した結果

__init__(command_type=CommandType.UNKNOWN, command_flg=False, command_name='', reaction=False, action=ActionStatus.NOTHING, target_ts=<factory>, rpoint_sum=0, result=True, message=None, source='')
Parameters:
  • command_type (CommandType)

  • command_flg (bool)

  • command_name (str)

  • reaction (bool)

  • action (ActionStatus)

  • target_ts (list[str])

  • rpoint_sum (int)

  • result (bool)

  • message (Any)

  • source (str)

Return type:

None

action: ActionStatus = 'nothing'

DBに対する操作

command_flg: bool = False

コマンドとして実行されたかチェック

  • True: コマンド実行

  • False: キーワード呼び出し

command_name: str = ''

実行したコマンド名

command_type: CommandType = 'unknown'

実行(する/した)サブコマンド

message: Any = None

汎用メッセージ

reaction: bool = False

データステータス状態

  • True: 矛盾なくデータを取り込んだ(OK)

  • False: 矛盾があったがデータを取り込んだ or データを取り込めなかった(NG)

result: bool = True

メッセージデータに対する処理結果 - True: 目的の処理が達成できた - False: 何らかの原因で処理が達成できなかった

rpoint_sum: int = 0

素点合計値格納用

source: str = ''

データ入力元識別子

target_ts: list[str]

同じ処理をしたタイムスタンプリスト(1件だけの処理でもセットされる)