影刀+python转发蝙蝠app消息,到企业微信
大致流程使用影刀获取蝙蝠app消息然后转发到本地。本地做过滤后再转发到企业微信python代码如下需要替换你机器人的key机器人key如何创建1.简历企业微信群2.添加群机器人3.复制群机器人key详情参考企业import json from flask import Flask, request, jsonify import requests import logging app Flask(__name__) # ---------- 配置 ---------- # 企业微信机器人 Webhook 地址请替换为您的实际 key WECOM_WEBHOOK https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key输入你机器人的key # 存储上一次接收到的消息用集合存储便于差集运算 last_messages [] # 日志配置 logging.basicConfig(levellogging.INFO, format%(asctime)s - %(levelname)s - %(message)s) # ---------- 企业微信推送 ---------- def send_to_wechat(new_items): 向企业微信推送新增消息列表 if not new_items: return # 构造文本内容每条消息换行 content 检测到新增消息\n \n.join(f- {item} for item in new_items) payload { msgtype: text, text: { content: content } } try: resp requests.post(WECOM_WEBHOOK, jsonpayload, timeout5) if resp.status_code 200: logging.info(企业微信推送成功) else: logging.error(f企业微信推送失败状态码{resp.status_code}, 响应{resp.text}) except Exception as e: logging.error(f企业微信推送异常{e}) def get_new_messages(old_list, new_list): 根据规则提取新列表的一个后缀。 参数 old_list: 老列表 new_list: 新列表 返回 提取出的新列表截取部分如果没有满足条件的则返回空列表。 old_set set(old_list) # 提升查找效率 # 1. 找到第一个不在 old_set 中的元素索引 first_new_idx -1 for idx, item in enumerate(new_list): if item not in old_set: first_new_idx idx break # 若没有新元素返回空 if first_new_idx -1: return [] # 2. 检查该元素是否包含 * if * in str(new_list[first_new_idx]): # 转为字符串以防元素不是字符串 start_idx first_new_idx else: # 向前找第一个包含 * 的元素 start_idx -1 for j in range(first_new_idx - 1, -1, -1): if * in str(new_list[j]): start_idx j break # 如果向前找不到返回空 if start_idx -1: return [] # 3. 截取从 start_idx 到末尾 return new_list[start_idx:] # ---------- Web 接口 ---------- app.route(/update, methods[POST]) def update_messages(): global last_messages data request.get_json() current_msgs data.get(messages, []) if len(current_msgs) 0: new_msgs get_new_messages(last_messages, current_msgs) if len(new_msgs) 0: send_to_wechat(new_msgs) last_messages current_msgs # 更新历史 return str(new_msgs) return jsonify(收到空消息) # ---------- 启动服务 ---------- if __name__ __main__: # 监听 0.0.0.0:5000可根据需要修改 app.run(host0.0.0.0, port5000, debugTrue)影刀代码如下https://www.yingdao.com/client/appstore/topic/?tag其他邀请加入应用市场_影刀RPA影刀中的python片段如下import requests def clean_data(data): result [] i 0 while i len(data): # 如果下一个元素存在、以 *** 结尾且当前元素出现在下一个元素中则跳过当前元素 if (i 1 len(data) and data[i1].endswith(***) and data[i] in data[i1]): i 1 continue result.append(data[i]) i 1 return result # 原始数据 original 消息列表 cleaned clean_data(original) responserequests.post( http://localhost:5000/update, json{messages: cleaned} ) # data response.json()