libs.functions.events.slash_command
libs/functions/events/slash_command.py
1""" 2libs/functions/events/slash_command.py 3""" 4 5import logging 6 7import libs.commands.graph.slackpost 8import libs.commands.ranking.slackpost 9import libs.commands.report.slackpost 10import libs.commands.results.slackpost 11import libs.global_value as g 12from libs.data import comparison, lookup 13from libs.functions import message, slack_api 14from libs.registry import member, team 15 16 17def main(ack, body, client): 18 """スラッシュコマンド 19 20 Args: 21 ack (_type_): ack 22 body (dict): ポストされたデータ 23 client (slack_bolt.App.client): slack_boltオブジェクト 24 """ 25 26 ack() 27 logging.trace(body) # type: ignore 28 g.msg.parser(body) 29 g.msg.client = client 30 31 if g.msg.text: 32 match g.msg.keyword: 33 # 成績管理系コマンド 34 case x if x in g.cfg.alias.results: 35 libs.commands.results.slackpost.main() 36 case x if x in g.cfg.alias.graph: 37 libs.commands.graph.slackpost.main() 38 case x if x in g.cfg.alias.ranking: 39 libs.commands.ranking.slackpost.main() 40 case x if x in g.cfg.alias.report: 41 libs.commands.report.slackpost.main() 42 43 # データベース関連コマンド 44 case x if x in g.cfg.alias.check: 45 comparison.main() 46 case x if x in g.cfg.alias.download: 47 slack_api.post_fileupload("resultdb", g.cfg.db.database_file) 48 49 # メンバー管理系コマンド 50 case x if x in g.cfg.alias.member: 51 title, msg = lookup.textdata.get_members_list() 52 slack_api.post_text(g.msg.event_ts, title, msg) 53 case x if x in g.cfg.alias.add: 54 slack_api.post_message(member.append(g.msg.argument)) 55 case x if x in g.cfg.alias.delete: 56 slack_api.post_message(member.remove(g.msg.argument)) 57 58 # チーム管理系コマンド 59 case x if x in g.cfg.alias.team_create: 60 slack_api.post_message(team.create(g.msg.argument)) 61 case x if x in g.cfg.alias.team_del: 62 slack_api.post_message(team.delete(g.msg.argument)) 63 case x if x in g.cfg.alias.team_add: 64 slack_api.post_message(team.append(g.msg.argument)) 65 case x if x in g.cfg.alias.team_remove: 66 slack_api.post_message(team.remove(g.msg.argument)) 67 case x if x in g.cfg.alias.team_list: 68 slack_api.post_message(lookup.textdata.get_team_list()) 69 case x if x in g.cfg.alias.team_clear: 70 slack_api.post_message(team.clear()) 71 72 # その他 73 case _: 74 slack_api.post_message(message.slash_help(body["command"]))
def
main(ack, body, client):
18def main(ack, body, client): 19 """スラッシュコマンド 20 21 Args: 22 ack (_type_): ack 23 body (dict): ポストされたデータ 24 client (slack_bolt.App.client): slack_boltオブジェクト 25 """ 26 27 ack() 28 logging.trace(body) # type: ignore 29 g.msg.parser(body) 30 g.msg.client = client 31 32 if g.msg.text: 33 match g.msg.keyword: 34 # 成績管理系コマンド 35 case x if x in g.cfg.alias.results: 36 libs.commands.results.slackpost.main() 37 case x if x in g.cfg.alias.graph: 38 libs.commands.graph.slackpost.main() 39 case x if x in g.cfg.alias.ranking: 40 libs.commands.ranking.slackpost.main() 41 case x if x in g.cfg.alias.report: 42 libs.commands.report.slackpost.main() 43 44 # データベース関連コマンド 45 case x if x in g.cfg.alias.check: 46 comparison.main() 47 case x if x in g.cfg.alias.download: 48 slack_api.post_fileupload("resultdb", g.cfg.db.database_file) 49 50 # メンバー管理系コマンド 51 case x if x in g.cfg.alias.member: 52 title, msg = lookup.textdata.get_members_list() 53 slack_api.post_text(g.msg.event_ts, title, msg) 54 case x if x in g.cfg.alias.add: 55 slack_api.post_message(member.append(g.msg.argument)) 56 case x if x in g.cfg.alias.delete: 57 slack_api.post_message(member.remove(g.msg.argument)) 58 59 # チーム管理系コマンド 60 case x if x in g.cfg.alias.team_create: 61 slack_api.post_message(team.create(g.msg.argument)) 62 case x if x in g.cfg.alias.team_del: 63 slack_api.post_message(team.delete(g.msg.argument)) 64 case x if x in g.cfg.alias.team_add: 65 slack_api.post_message(team.append(g.msg.argument)) 66 case x if x in g.cfg.alias.team_remove: 67 slack_api.post_message(team.remove(g.msg.argument)) 68 case x if x in g.cfg.alias.team_list: 69 slack_api.post_message(lookup.textdata.get_team_list()) 70 case x if x in g.cfg.alias.team_clear: 71 slack_api.post_message(team.clear()) 72 73 # その他 74 case _: 75 slack_api.post_message(message.slash_help(body["command"]))
スラッシュコマンド
Arguments:
- ack (_type_): ack
- body (dict): ポストされたデータ
- client (slack_bolt.App.client): slack_boltオブジェクト