go-cqhttp API typing annoations, return data models and utils for nonebot

Overview

Nonebot-plugin-gocqapi

通过 pydantic 为 go-cqhttp 的 API 添加了完善的类型注解和返回值models

目前还在测试阶段

安装与使用

并不需要作为nonebot的插件安装

poetry add gocqapi
# 或使用
pip install gocqapi

仅连接单机器人使用

from gocqapi import api

await api.xxxxxx()

多机器人指定调用某个机器人

from gocqapi import API

api = API(bot_id)
await api.xxxxxx()

使用类型Models

from gocqapi.models import *  # 已使用__all__限制能够引入的Model
# 或使用
from gocqapi.models import Xxxxx

Example

# 范例
foo = await api.get_group_system_msg()
for joinreq in foo.join_requests:
    print(foo.message)
You might also like...
CDIoU and CDIoU loss is like a convenient plug-in that can be used in multiple models. CDIoU and CDIoU loss have different excellent performances in several models such as Faster R-CNN, YOLOv4, RetinaNet and . There is a maximum AP improvement of 1.9% and an average AP of 0.8% improvement on MS COCO dataset, compared to traditional evaluation-feedback modules. Here we just use as an example to illustrate the code.
BioThings API framework - Making high-performance API for biological annotation data

BioThings SDK Quick Summary BioThings SDK provides a Python-based toolkit to build high-performance data APIs (or web services) from a single data sou

Official Python client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Python apps.

MonkeyLearn API for Python Official Python client for the MonkeyLearn API. Build and run machine learning models for language processing from your Pyt

Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API.

Tg_PHub_Bot Telegram PHub Bot using ARQ Api and Pyrogram. This Bot can Download and Send PHub HQ videos in Telegram using ARQ API. OS Support All linu

🚧 finCLI's own News API. No more limited API calls. Unlimited credible and latest information on BTC, Ethereum, Indian and Global Finance.
🚧 finCLI's own News API. No more limited API calls. Unlimited credible and latest information on BTC, Ethereum, Indian and Global Finance.

🚧 finCLI's own News API. No more limited API calls. Unlimited credible and latest information on BTC, Ethereum, Indian and Global Finance.

Python API for working with RESQML models

resqpy: Python API for working with RESQML models Introduction resqpy is a pure python package which provides a programming interface (API) for readin

Backtest 1000s of minute-by-minute trading algorithms for training AI with automated pricing data from: IEX, Tradier and FinViz. Datasets and trading performance automatically published to S3 for building AI training datasets for teaching DNNs how to trade. Runs on Kubernetes and docker-compose. >150 million trading history rows generated from +5000 algorithms. Heads up: Yahoo's Finance API was disabled on 2019-01-03 https://developer.yahoo.com/yql/
Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id

Bot Hadith-API on Telegram The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id Built With Python Asynchronous HTTP protocol client

Comments
  • 引入时报错:TypeError

    引入时报错:TypeError

    具体报错信息如下:

    Traceback (most recent call last):
      File "E:/python2/QQToVenir/demo.py", line 1, in <module>
        from gocqapi import api
      File "E:\pythonvenv\Nonebot\lib\site-packages\gocqapi\__init__.py", line 3, in <module>
        from .info import InfoAPI
      File "E:\pythonvenv\Nonebot\lib\site-packages\gocqapi\info.py", line 3, in <module>
        from ._api import BaseAPI
      File "E:\pythonvenv\Nonebot\lib\site-packages\gocqapi\_api.py", line 8, in <module>
        class BaseAPI:
      File "E:\pythonvenv\Nonebot\lib\site-packages\gocqapi\_api.py", line 16, in BaseAPI
        async def call(self, api: str, **kwargs: Any) -> dict[Any, Any]:
    TypeError: 'type' object is not subscriptable
    

    报错代码:

    from gocqapi import api
    
    opened by InEase 5
  • AssertionError: assert _bot is Bot

    AssertionError: assert _bot is Bot

    assert _bot is Bot这个写法有点奇怪,这里想表达的是不是isinstance(bot, Bot)

    复现代码:

    msg_id = ...
    api = API(bot.self_id)
    await api.delete_msg(msg_id)
    

    报错:

    Traceback (most recent call last):
      File "/usr/local/bin/gunicorn", line 8, in <module>
        sys.exit(run())
      File "/usr/local/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
        WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
      File "/usr/local/lib/python3.10/site-packages/gunicorn/app/base.py", line 231, in run
        super().run()
      File "/usr/local/lib/python3.10/site-packages/gunicorn/app/base.py", line 72, in run
        Arbiter(self).run()
      File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 202, in run
        self.manage_workers()
      File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 551, in manage_workers
        self.spawn_workers()
      File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 622, in spawn_workers
        self.spawn_worker()
      File "/usr/local/lib/python3.10/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
        worker.init_process()
      File "/usr/local/lib/python3.10/site-packages/uvicorn/workers.py", line 66, in init_process
        super(UvicornWorker, self).init_process()
      File "/usr/local/lib/python3.10/site-packages/gunicorn/workers/base.py", line 142, in init_process
        self.run()
      File "/usr/local/lib/python3.10/site-packages/uvicorn/workers.py", line 98, in run
        return asyncio.run(self._serve())
      File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 142, in _check_matcher
        await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
    > File "/usr/local/lib/python3.10/site-packages/nonebot/message.py", line 188, in _run_matcher
        await matcher.run(bot, event, state, stack, dependency_cache)
      File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 727, in run
        await self.simple_run(bot, event, state, stack, dependency_cache)
      File "/usr/local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 702, in simple_run
        await handler(
      File "/usr/local/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 108, in __call__
        return await cast(Callable[..., Awaitable[R]], self.call)(**values)
      File "/usr/local/lib/python3.10/site-packages/nonebot_plugin_revoke/__init__.py", line 21, in _
        await api.delete_msg(reply_msg_id)
      File "/usr/local/lib/python3.10/site-packages/gocqapi/message.py", line 159, in delete_msg
        await self.call("delete_msg", message_id=message_id)
      File "/usr/local/lib/python3.10/site-packages/gocqapi/_api.py", line 42, in call
        raise e
      File "/usr/local/lib/python3.10/site-packages/gocqapi/_api.py", line 36, in call
        assert _bot is Bot
    AssertionError
    
    opened by ssttkkl 0
Owner
风屿
风屿
A qq bot based on nonebot2 and go-cqhttp

Asoul-bot A qq bot based on nonebot and go-cqhttp 你可以将bot部署在本地,也可以加入bot测试群:784280070(全体禁言) 你可以通过临时会话的方式向bot发送指令,输入help获取帮助菜单 本地部署请参考:https://zhuanlan.

null 11 Sep 23, 2022
Go-cqhttp Plugin for EFB QQ Slave.

efb-qq-plugin-go-cqhttp efb-qq-plugin-go-cqhttp 是 efb-qq-slave 的插件,需要配合 efb-qq-slave 使用,使用前请先阅读 efb-qq-slave 的文档。

XYenon 26 Dec 11, 2022
A QQ(Tencent) robot created by go-cqhttp & nonebot2

绘梨花(胶布)Bot|ErikaBot ✨ 基于NoneBot2的绘梨花多功能 Bot ,自用 ✨ 快速开始 参考go-cqhttp项目文档,配置好机器人的相关设置,以及反向ws客户端 参考nonebot2项目文档,添加必要的.env相关设置 安装本项目相关的依赖库(依赖清单) git clone本

null 10 Aug 9, 2022
A Telegram Bot to return Youtube Video Tags Using YoutubeTags API

YouTube-TagFind-Bot A Telegram Bot to return Youtube Video Tags Using YoutubeTags API YoutubeTags API Wrapper YoutubeTags is a python third-party api

Nuhman Pk 9 Aug 25, 2022
Telegram bot that search for the classrooms status of the chosen day and then return all the free classrooms using your preferred time slot

Aule Libere Polimi Since the PoliMi site no longer allows people to search for free classrooms this bot was necessary! It simply search for the classr

Daniele Ferrazzo 16 Nov 9, 2022
This bot is created by AJTimePyro and It accepts direct downloading url & then return file as telegram file.

URL Uploader Bot This is the source code of URL Uploader Bot. And the developer of this bot is AJTimePyro, His Telegram Channel & Group. You can use t

Abhijeet 23 Nov 13, 2022
a discord bot for searching your movies, and bot return movie url for you :)

IMDb Discord Bot how to run this bot. the first step you must create prefixes.json file the second step you must create a virtualenv if you use window

Mehdi Radfar 6 Dec 20, 2022
A reddit.com bot that will return reference links from official python documentation site for the standard library.

Python Docs Bot A reddit.com bot that will return documentation links for the library and language reference sections of the python docs website. The

Trevor Miller 2 Sep 14, 2021
A python to scratch API connector. Can fetch data from the API and send it back in cloud variables.

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857 Installation

null 20 Jun 18, 2022
Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Antônio Oliveira 1 Nov 21, 2021