1 Star 0 Fork 0

惊鸿一回车/QQ_Transmit

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
web.py 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
洛枫 提交于 2019-09-20 14:31 . Add files via upload
# coding:utf-8
from flask import Flask, request
from flask import make_response
import json
import re
import requests
app = Flask(__name__)
BOSS = 0
SEND = 0
URL = r'http://127.0.0.1:5700/send_private_msg?'
def sendMsg(user_id, message):
for i in user_id:
url = URL + 'user_id=%s&message=%s' % (i, message)
statcode = requests.get(url).status_code
if statcode == 200:
print('>> 发给[%s]完成' % i)
print('')
def Process(contents):
receiveQQ = contents['sender']['user_id']
receiveMSG = contents['message']
try:
receiveGROUP = contents['group_id']
except:
receiveGROUP = ''
if 'CQ:image' in receiveMSG: # 图片
receiveMSG = re.findall("url=(.*)\]", receiveMSG)[0]
# receiveCQ = re.findall("\[CQ:(.*)\]", receiveMSG)[0]
# print("CQ:", receiveCQ)
print("GROUP:", receiveGROUP)
print("QQ:", receiveQQ)
print("消息:", receiveMSG)
sendMsg(SEND, receiveMSG)
@app.route('/', methods=['POST'])
def receive():
global BOSS, SEND
contents = json.loads(request.get_data().decode('utf-8'))
print("原始:", contents)
receiveQQ = contents['sender']['user_id']
if receiveQQ == BOSS:
Process(contents)
return make_response(''), 200
if __name__ == '__main__':
BOSS = input('输入要接收的QQ: ').strip() or '1061700625'
BOSS = int(BOSS)
SEND = input('输入要发送的QQ,英文逗号分隔: ').strip() or '1061700625'
SEND = SEND.split(',')
for i in range(len(SEND)):
SEND[i] = int(SEND[i])
print('*' * 50)
print('>> 接收:', BOSS)
print('>> 发送:', SEND)
print('*' * 50)
print()
app.run() # debug=True
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/songxf1024/QQ_Transmit.git
git@gitee.com:songxf1024/QQ_Transmit.git
songxf1024
QQ_Transmit
QQ_Transmit
master

搜索帮助