Git Product home page Git Product logo

ssmjae / pepperbot Goto Github PK

View Code? Open in Web Editor NEW
96.0 6.0 15.0 7.98 MB

An intuitive multi-platform bot framework, easily forward messages among platforms, support QQ, WeChat, Telegram. 一个符合直觉的跨社交平台机器人框架,轻松地在平台间传递消息,支持QQ、微信、Telegram

Home Page: https://SSmJaE.github.io/PepperBot/

License: MIT License

Python 100.00%
qq onebot bot asyncio wechat keaimao cross-platform async framework telegram

pepperbot's Introduction

PepperBot

一个符合直觉的跨社交平台机器人框架,轻松地在平台间传递消息,支持QQ、微信、Telegram

文档 · QQ交流群

生而跨平台

  • QQ 基于 OnebotMirai(待实现)、OPQ(待实现)
  • 微信基于可爱猫
  • Telegram基于Pyrogram
  • 提供了跨平台、易用的消息类型(片段)
  • 通用事件,比如群消息、私聊消息等,提供了统一的接口,只需要写一次代码,就可以无缝应用到各个平台上,跨平台的消息传递从未如此轻松随意
  • 可以跨群、跨平台共享指令(的状态),或者全局锁定用户(不管用户是通过群聊还是私聊)

性能也够用

  • 底层基于异步的 Sanic 框架,目前有一定生态的 python web 框架中,性能最好的
  • 轻量,主要处理消息,对于其他功能,暴露底层接口,方便实现深度定制
  • 几行代码,即可实现多进程负载均衡

自带全家桶

  • 支持 Djangostarlette 风格的集中化路由,或者flaskfastAPI 风格的装饰器式路由
  • 非常灵活的权限系统,支持路由、class、method级别的权限控制
  • Django 类视图风格或Vue 生命周期风格的指令系统
  • 定时任务
  • 日志支持
  • 基于ormar的异步数据库支持(ormar基于sqlalchemy + pydantic)
  • 自带插件市场,可以安装社区指令
  • 提供cli工具,快速创建项目
  • 类似Selenium的事件等待
  • fastAPI风格的依赖注入

接口合语义

  • API 符合直觉,直观,流畅地把想法映射到代码上
  • 基于 python3.6 之后的类型注解,提供了完全的类型提示
  • 大部分可以自动获取的参数,都会自动获取,不需要每次手动提供了
  • 只会动态注入用到的参数,没必要每次写一长串用不到的参数了!
  • 文档中,均有可直接复制使用的代码片段,快速开发

测试文档全

  • 自带linter
    • 通过元编程(AST 之类)手段,对编写的各种代码进行规则检查,并输出易于理解的错误信息,将问题消灭在框架启动之前
  • 文档比较全
  • 测试覆盖比较全面
  • 大量官方示例/指令
  • 来自作者的 QA(加群以获取)

安装

pip install pepperbot

使用

具体使用见文档

示例

六行代码实现消息互转

class WhateverNameYouWant:
    async def group_message(self, bot: UniversalGroupBot, chain: MessageChain):
        if bot.onebot: # 转发qq消息至微信、TG
            await bot.arbitrary.keaimao.group_message("19521241254@chatroom", *chain.segments)
            await bot.arbitrary.telegram.group_message("bot_father", *chain.segments)

        if bot.keaimao: # 转发微信消息至qq、TG
            await bot.arbitrary.onebot.group_message("1041902989", *chain.segments)
            await bot.arbitrary.telegram.group_message("bot_father", *chain.segments)

只需要非常少的代码,就可以实现跨平台的群消息的响应

@register()
class WhateverNameYouWant:

    # 注册跨平台群事件
    async def group_message(self, bot: GroupBot, chain: MessageChain, sender: Sender):
        # chain即为消息链,pure_text是消息中的纯文本,不包含表情、图片等
        if "撤回我" == chain.pure_text:
            await chain.withdraw() # 可以直接“撤回消息”,符合直觉

        if "踢出我" == chain.pure_text:
            await sender.kickout() # 可以直接踢出发言群员

        # 也可以对消息链进行in操作,相当于in chain.pure_text
        if "禁言我" in chain:
            await sender.ban(10) # 可以直接禁言发言群员

        if chain.regex("有人(在|吗|嘛|在吗).?"):
            # 发送一条群消息
            # 接受任意个参数,必须是合法的消息片段,比如Text,Face,Image
            await bot.group_message(
                Text("没人"),
                Image("http://123.jpg"),
            )

生态

插件市场

可以记忆上下文的GPT群聊机器人

pepperbot-ai-query

通过GPT,自动检测群聊中的广告信息

pepperbot's People

Contributors

ssmjae 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pepperbot's Issues

能否支持onebot协议的,直接使用websocket进行发送消息操作?

我留意到文档:https://ssmjae.github.io/PepperBot/docs/%E6%95%99%E7%A8%8B/%E7%8E%AF%E5%A2%83/PepperBot%E5%AF%B9%E6%8E%A5/
中对于onebot协议的支持是: 通过go-cqhttp的反向websocket来实现接受消息, 对于响应则需要通过pepperbot调用go-cqhttp的http接口实现.
想询问一下未来是否有改变这一点的可能? 即: 不需要配置go-cqhttp的http接口, 只通过反向websocket实现和go-cqhttp的对接工作.

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.