def gui_confirm_delete(bot): """gui not help string""" command_url = "https://slack.com/api/views.update" map_id = json.loads(read_user_data(bot.team_id, bot.user_id, "key_id")) view_id = map_id["view_id"] channel_id = map_id["channel_id"] block_content = [] block_content.append(build_plain_text_content("command execute done.")) view_content = { "type": "modal", "callback_id": "modal-executed", "title": { "type": "plain_text", "text": "COMPLETE!" }, "private_metadata": channel_id, "close": { "type": "plain_text", "text": "OK", "emoji": True }, "blocks": block_content } payload = { "token": bot.token, "trigger_id": bot.trigger_id, "view_id": view_id, "response_action": "clear", "view": json.dumps(view_content, ensure_ascii=False) } res = requests.post(command_url, data=payload) print(res.text)
def session_select_user(bot): """:point_left: *kp select member*\n`/cc kp select`""" body = read_user_data(bot.team_id, bot.user_id, KP_FILE_PATH) dict_kp = json.loads(body) lst_user = dict_kp["lst_user"] user_target = random.choices(lst_user) user_target_param = get_user_param(bot.team_id, user_target[0][0], user_target[0][1]) return user_target_param["name"], yig.config.COLOR_ATTENTION
def reduce_gamesession_user(team_id, kp_id, user_id, pc_id): body = read_user_data(team_id, kp_id, KP_FILE_PATH) dict_kp = json.loads(body) lst_reduce = [] lst = [ lst_joined for lst_joined in dict_kp["lst_user"] if lst_joined[0] != user_id ] dict_kp["lst_user"] = lst body_write = json.dumps(dict_kp, ensure_ascii=False).encode('utf-8') write_user_data(team_id, kp_id, KP_FILE_PATH, body_write)
def gui_confirm_sanc(bot): """gui not help string""" command_url = "https://slack.com/api/views.update" map_id = json.loads(read_user_data(bot.team_id, bot.user_id, "key_id")) view_id = map_id["view_id"] channel_id = map_id["channel_id"] block_content = [] # EN # "Enter the required SAN check value. `sanc [success]/[fail]`\n" # "If you only want to check the SAN, just [GO!] ahead\n" # "For example\n" # "sanc 0/1, sanc 1/1d6, 1d20/1d100" block_content.append( build_mrkdwn_content(("SANチェックの値を入力して下さい。 `sanc [成功量]/[失敗量]` \n" "もしSANチェックのみを行う場合、そのまま「GO!」ボタンを押して下さい\n" "例)\n" "sanc 0/1, sanc 1/1d6, 1d20/1d100"))) # Write the value of the SAN check block_content.append(build_input_content("SANチェックの値を入力して下さい", 'sanc')) view_content = { "type": "modal", "callback_id": "modal-dispatch_in_sanc", "title": { "type": "plain_text", "text": "SAN CHECK MODAL" }, "private_metadata": channel_id, "submit": { "type": "plain_text", "text": "GO!", "emoji": True }, "close": { "type": "plain_text", "text": "CLOSE", "emoji": True }, "blocks": block_content } payload = { "token": bot.token, "trigger_id": bot.trigger_id, "view_id": view_id, "response_action": "clear", "view": json.dumps(view_content, ensure_ascii=False) } res = requests.post(command_url, data=payload) print(res.text)
def gui_confirm_select_receiver(bot): """gui not help string""" command_url = "https://slack.com/api/views.update" user_param = get_user_param(bot.team_id, bot.user_id) block_content = [] bot.key = bot.key.replace('+', ' ') # "Do you want to add a correction value?\n" # "For example\n" # "%s+10, %s-20, %s*2, %s/2" % (bot.key, bot.key, bot.key, bot.key) block_content.append( build_plain_text_content(("ロールの補正値がある場合、補正値を入れて下さい\n" "例)\n" "%s+10, %s-20, %s*2, %s/2" % (bot.key, bot.key, bot.key, bot.key)))) block_content.append( build_input_content('Roll correction value', "%s" % bot.key)) map_id = json.loads(read_user_data(bot.team_id, bot.user_id, "key_id")) view_id = map_id["view_id"] channel_id = map_id["channel_id"] view_content = { "type": "modal", "callback_id": "modal-dispatch_in_select", "title": { "type": "plain_text", "text": "Call Of Cthulhu GUI Mode" }, "submit": { "type": "plain_text", "text": "ROLL!", "emoji": True }, "private_metadata": channel_id, "blocks": block_content } payload = { "token": bot.token, "channel": channel_id, "trigger_id": bot.trigger_id, "view_id": view_id, "private_metadata": channel_id, "response_action": "clear", "view": json.dumps(view_content, ensure_ascii=False) } res = requests.post(command_url, data=payload) logging.info(json.dumps(res.text))
def gui_confirm_session(bot): """gui not help string""" command_url = "https://slack.com/api/views.update" map_id = json.loads(read_user_data(bot.team_id, bot.user_id, "key_id")) view_id = map_id["view_id"] channel_id = map_id["channel_id"] block_content = [] block_content.append( build_mrkdwn_content( ("KPから発行されるセッション参加コマンドを入力して下さい `join [KPのID]` \n" "セッションから抜ける場合、leaveコマンドを入力して下さい `leave [KPのID]` \n"))) block_content.append(build_user_select_content("modal-button-select-user")) block_content.append(build_plain_text_content("ユーザID | %s" % bot.key)) block_content.append(build_input_content("参加コマンドを入力して下さい", 'join ')) view_content = { "type": "modal", "callback_id": "modal-dispatch_in_session", "title": { "type": "plain_text", "text": "SESSION MODAL" }, "private_metadata": channel_id, "submit": { "type": "plain_text", "text": "EXECUTE", "emoji": True }, "close": { "type": "plain_text", "text": "CLOSE", "emoji": True }, "blocks": block_content } payload = { "token": bot.token, "trigger_id": bot.trigger_id, "view_id": view_id, "response_action": "clear", "view": json.dumps(view_content, ensure_ascii=False) } res = requests.post(command_url, data=payload) print(res.text)
def gui_confirm_status(bot): """gui not help string""" command_url = "https://slack.com/api/views.update" map_id = json.loads(read_user_data(bot.team_id, bot.user_id, "key_id")) view_id = map_id["view_id"] channel_id = map_id["channel_id"] block_content = [] block_content.append( build_mrkdwn_content(("ステータスの変更を入力して下さい\n" "例)\n" "2点ダメージを回復する場合。 `u HP+2` \n" "5点MPを払う場合。 `u MP-5` \n" "3点のSANを減らす場合。 `u SAN-3` "))) block_content.append(build_input_content("変更を入力して下さい", 'u %s' % bot.key)) view_content = { "type": "modal", "callback_id": "modal-dispatch_in_status", "title": { "type": "plain_text", "text": "STATUS UPDATE MODAL" }, "private_metadata": channel_id, "submit": { "type": "plain_text", "text": "UPDATE", "emoji": True }, "close": { "type": "plain_text", "text": "CLOSE", "emoji": True }, "blocks": block_content } payload = { "token": bot.token, "trigger_id": bot.trigger_id, "view_id": view_id, "response_action": "clear", "view": json.dumps(view_content, ensure_ascii=False) } res = requests.post(command_url, data=payload) print(res.text)
def get_lst_player_data(team_id, user_id, roll_targ): dict_kp = json.loads( read_user_data(team_id, user_id, KP_FILE_PATH).decode('utf-8')) lst_user = dict_kp["lst_user"] lst_user_data = [] for user in lst_user: state_data = get_state_data(team_id, user[0]) user_param = get_user_param(team_id, user[0], user[1]) name = user_param['name'] lst_user_data.append({ 'name': name, 'user_id': user[0], 'user_param': user_param, 'state_data': state_data, }) lst_user_data.sort(key=lambda x: int(x['user_param'][roll_targ])) lst_user_data.reverse() return lst_user_data
def add_gamesession_user(team_id, kp_id, user_id, pc_name, pc_id, channel_name, data_user): body = read_user_data(team_id, kp_id, KP_FILE_PATH) dict_kp = json.loads(body) if "lst_user" not in dict_kp: dict_kp["lst_user"] = [] dict_kp["lst_user"].append([user_id, pc_id]) body_write = json.dumps(dict_kp, ensure_ascii=False).encode('utf-8') write_user_data(team_id, kp_id, KP_FILE_PATH, body_write) session_data = json.loads( read_session_data(team_id, f"{channel_name}/session.json")) session_data["PL"].append({ "id": user_id, "name": data_user["profile"]["display_name"], "pc_id": pc_id, "pc_name": pc_name }) write_session_data(team_id, f"{channel_name}/session.json", json.dumps(session_data, ensure_ascii=False)) write_session_data(team_id, f"{channel_name}/{pc_id}.json", json.dumps([], ensure_ascii=False))