Code Monkey home page Code Monkey logo

python-cqhttp's People

Contributors

stdrc avatar supermariosf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-cqhttp's Issues

机器人无法匿名发消息

if str(user_id) == "943359205":
    ...
elif str(user_id) == "80000000":
    return bot.send(context,
                    message="""[CQ:anonymous,ignore=true] , 匿名清屏."""))

群是支持 匿名的 , 机器人可以发出消息来 ,但不是匿名发送.

无法收取到消息,但能够正常发出消息。撤回功能存在问题。

运行环境

HTTP API release 3.3.5
运行于 酷Q Pro 5.11.4 (180106)
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32)
HTTP API Python SDK 版本 1.1.0 (来自pip安装)
bottle 版本 0.12.13 (来自pip安装)
requests 版本 2.18.3 (来自pip安装)

症状

通过bot.on_message()装饰器绑定了处理函数,但这个处理函数始终都没有被调用过。从酷Q的日志里能看到酷Q收到了消息。测试的消息由群消息和私聊消息。
项目自带的demo.py也未能正常工作。

但发消息的部分正常工作。只是撤回消息时遇到了 status_code=200 retcode=100 的问题。(待撤回消息在2分钟内)

备注

如果需要帮助测试的话我很乐意帮助你测试关于酷Q Pro相关的部分。

功能请求: Python SDK退出功能和手动绑定、解绑处理函数的功能

由于一些需求,我需要能够在Python SDK中手动通过CQHttp类的方法来绑定和解绑处理函数,并且无法使用装饰器。
此外,由于相同的需求,我需要能够正确停止掉Python SDK的全部线程。目前是一旦初始化CQHttp对象并调用了run()方法,Bottle总是会有一个线程在后面持续运行不退出,结果导致必须按Ctrl+C终止。

以下是一些方法命名与参数的建议,如果起名困难的话可以参考一下这里。
更新: 重新阅读源码之后发现给出的建议参数列表中有一些不妥之处,已修改。

from typing import Callable, Iterable

class CQHttp(...):
    # 停止本地SDK的线程,如需重新启动bot则需重新启动CQHttp.run()。
    def sdk_local_stop() -> None:
        pass

    # 通过方法注册处理函数
    def set_handler(post_type: str, handler: Callable, types: Iterable=None) -> None:
        pass

    # 通过方法解除已经注册的函数
    def unset_handler(post_type: str, types: Iterable=None) -> None:
        pass

感谢你对本功能请求的关注。

delete_msg报错cqhttp.Error: (200, -99)

文档内提到:
status 字段如果是 failed 则表示操作失败,此时 retcode 有两种情况:当大于 0 时,表示是 HTTP API 插件判断出的失败;小于 0 时,为调用酷 Q 函数的返回码,具体含义直接参考 Pro/开发/Error 和酷 Q 的日志。
但在 Pro/开发/Error 这里并没有找到关于-99的报错原因。

代码如下,马赛克群号:
from cqhttp import CQHttp

bot = CQHttp(api_root='http://127.0.0.1:5700/')

global last_message

last_message = ""

@bot.on_message()
def handle_msg(context):
global last_message

new_message = context['message']
message_id = context["message_id"]
if context["group_id"] == 733***010:
    if last_message == new_message:
        print(message_id)
        bot.delete_msg(message_id=message_id)

    last_message = new_message

return {'reply': None,
        'at_sender': False}

bot.run(host='127.0.0.1', port=8080, debug=True)

事件上报地址无法访问

pic

如图,sdk也写了,配置也改了,但是事件上报时无法访问上报地址。。。


环境:

  • win server 2012r2
  • 酷qAir 5.11.10A(180130)
  • HTTP API 3.4.0
  • cqhttp 1.1.0
  • python 3.6 + requests 2.18.4

加群处理失败

@bot.on_request('group')
async def handle_group_request(context):
    group_id = context['group_id']
    if str(group_id) in {"432987409":'PyQt5小组'}:
        print(context['comment'])
        if context['comment']!= '是':
            # 如果插件版本是 3.x,这里需要使用 context.message
            # 验证信息不符,拒绝
            return {'approve':False, 'reason': '请填写答案 是'}
        else:
            return {'approve':True}

这里context['comment'] 会把问题也包含进去。

使用cqhttp_helper.py后调用.send()后报错

因为cqhttp的send()会调用self.send_msg(**context),但是cqhttp_helper.py中的CQHttp中具体实现了send_msg()方法,并且规定了参数,但context中存在没有该方法的参数,如font等,因此调用send会报错

传输图片

请问 在酷Q pro上可以用你的api传输图片吗?

使用问题 我需要怎么做监听一个正则信息?

http api
{ "host": "127.0.0.1", "port": 5700, "use_http": true, "ws_host": "[::]", "ws_port": 6700, "use_ws": false, "ws_reverse_url": "", "ws_reverse_api_url": "", "ws_reverse_event_url": "", "ws_reverse_reconnect_interval": 3000, "ws_reverse_reconnect_on_code_1000": true, "use_ws_reverse": true, "post_url": "", "access_token": "", "secret": "", "post_message_format": "string", "serve_data_files": false, "update_source": "github", "update_channel": "stable", "auto_check_update": false, "auto_perform_update": false, "show_log_console": false, "log_level": "info" }

``from cqhttp import CQHttp, Error

bot = CQHttp(api_root='http://127.0.0.1:5700/')

@bot.on_message()
def handle_msg(context):
print(context['message'])

bot.run(host='127.0.0.1', port=8080)``

打印收到的信息 运行起来没有反应的? 是我哪里配置错了?
`` * Serving Flask app "cqhttp" (lazy loading)

  • Environment: production
    WARNING: Do not use the development server in a production environment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
    ``

新人入群如何@并发送欢迎消息?

您好!
在新增群成员事件中:
bot.send(context, message='欢迎新人~', auto_escape=True) # 发送欢迎新人
如何同时@新人呢?或者说,如何@指定的QQ号呢?
谢谢!

新版支持

bot.send(context, message='欢迎{}~'.format(name))
这句无法在4.4版协议上运行

HTTP上报地址无法访问

环境

  1. 以为是post_url的配置不正确,使用docker命令输入的参数作为环境变量
    docker run -ti --rm --name cqhttp-test \ -v $(pwd)/coolq:/home/user/coolq \ -p 9000:9000 \ -p 5700:5700 \ -p 8080:8080 \ -e FORCE_ENV=true \ -e COOLQ_ACCOUNT=1549894933 \ -e CQHTTP_POST_URL=http://127.0.0.1:8080 \ -e CQHTTP_SERVE_DATA_FILES=yes \richardchien/cqhttp:latest
  2. 如1,以为是docker不能访问容器内部,于是绑定了端口8080
  3. postman对本地8080端口发包是有作用的,状态码500

context 如何获取群号

你好,
在处理context的时候,如何获取所在群的群号?
context['user_id'] 可以获得QQ号,
但是context['group_id']就会报错KeyError: 'group_id'
谢谢~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.