Git Product home page Git Product logo

shinxbot2's Introduction

shinxBot2

一个基于 go-cqhttp Lagrange.Onebot(已迁移,如有bug提issue) 的机器人以及(轻微的(还没写))多机器人管理框架。

做着玩的

是我原来项目shinxBot的C++重构版,

它能做什么?

  • 恶臭数字论证器,来源:itorr

  • 来点二次元。来源:dmoe

  • 首字母缩写识别,来源:itorr

  • 在群或私聊中生成一个假的转发信息。

  • 来点色图:随机色卡

  • 赛博养猫(与 gpt3.5 共同创作)

  • cat image for http code。来源httpcats

  • 图片OCR (qq自带的那个)

  • 图片处理:对称、旋转、万花筒

  • openai的 gpt-3.5-turbo API支持

  • google的 gemini-pro[-vision] API支持,url

  • StableDiffusion的 SDXL-Turbo API支持,url

  • 群友聊天截图保存功能(美图)

  • 龙王提醒

  • 群成员变动提醒

  • 人云亦云(复读)

  • 不同群聊,私聊的消息互相转发

  • 灰名单管理

  • 管理多个bot,并(以后)可以通过广播传递消息

关于源文件

./src/functions 所有功能的代码

./src/inc 功能头文件

./src/interfaces 接口,所有功能继承这个类

./src/utils 一些工具

如何运行这个机器人

需要几个支持库:libcurl + openssl-dev / jsoncpp / base64 / libzip / Magick++

base64: please git clone them into ./lib
libcurl: sudo apt-get install libcurl4-openssl-dev
openssl: sudo apt-get install openssl-dev (or libssl-dev)
jsoncpp: sudo apt-get install libjsoncpp-dev
libzip: sudo apt-get install libzip-dev
Magick++:
    sudo apt-get install libmagick++-dev libmagick++-6.q16hdri-dev
    then remove them (this step actually do dependency install),
    then refer to [Magick++ installing page](https://www.imagemagick.org/Magick++/Install.html) to manually install it. (for a higher version of 7)
maybe it will work

base64 作为子模块在 ./lib 下,请也一并 clone 它。

需要先配置并启动 go-cqhttp。打开 "反向HTTP POST地址",并设置你自己的接收端口。(一般在go-cqhttp目录下的config.yaml)

linux: 运行 build.sh ,自动执行cmake和make编译,使用 start.sh 开始后台运行。主程序作为管理程序,会以子进程方式启动其他bot。

windows:手动通过CMake编译,需要更改TCP连接的头文件(和可能的代码细微差别,包括不限于sleep,file:///)本人没有使用Windows编译过(

如何添加新bot

所有的bot应该继承./src/interfaces/bot.hclass bot。在./config/port.txt中加入你的发送与接收端口。在./src/main.cpp的main()中加入add_new_bot(new yourbot(receive_port[id], send_port[id]));

可以直接复制./src/bots里的mybot,是一个已经接好gocq的类。

如何添加新功能

仅限于class mybot,如果是其他类型bot,可以参考我的功能插件实现。

本节中functions和events可以互换,functions传参仅为消息相关,events传入事件的JSON数据,在收到聊天消息的时候调用 functions 里的方法,在其他提示性消息的时候用 events 的方法。

  1. ./src/functions 下新建目录并把代码放入,写一个类继承 ./src/interfaces/processable.h 中的类并实现virtual方法(可以参考我其他功能的写法,一个简单示例是 functions/getJapaneseImage/Anime_Img.cpp

  2. 继承的 virtual 方法里只要 check() 成功了就会执行 process() 方法

  3. ./src/functions/functions.h 中加入你的.h

  4. ./src/bots/mybot.cpp中 run 函数里加入 functions.push_back(new your_name());

开发提示

  1. 如果使用clang,根目录下.clang-format为你提供了自动格式化设置

  2. dev_tools下的sender.sh可用于向shinxbot发送信息,inspector则截获shinxbot向go-cqhttp发送的数据。inspector不能与go-cqhttp同时运行。这两者在功能上等同于go-cqhttp,为无法运行go-cqhttp的开发者提供了便利。(你可能需要更改inspector.cppsender.sh中的相关路径指向config文件) 例如:

bash sender.sh "bot.help"

TODO

  • 把所有的功能编译成动态库,方便更换和加载

  • 实现bot间消息广播

shinxbot2's People

Contributors

gutaozi avatar jayfeather233 avatar neumoneumo avatar

Stargazers

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

Watchers

 avatar

shinxbot2's Issues

[Feat Req] Add support for real-time bus location in SUSTech

Hello, Jayfeather.

Grasping where the buses are is a pragmatic function for a bot. However, different universities have distinct API calling conventions. And it is not wise to add this functionality as a universal method like hhsh. Instead, implementing it as an optionally compiled dynamic library is probably more appropriate.

Therefore, this issue might involve two steps:

  1. Provide a consistent dynamic library calling convention (as you said in README todo -- 把所有的功能编译成动态库,方便更换和加载)
  2. Add support for real-time bus location in SUSTech

More information about SUSTech:

  1. This API could be used to get the real-time location of buses: https://bus.sustcra.com/api/v2/monitor_osm/
  2. This website is also useful

Open `.ai.change` permission for personal usage

Thanks for your marvelous job to integrate GPT3.5 into shinx 😆
It is reasonable to restrict the permission of the command .ai.change in the group because it will make the bot behave like what the op wants. However, when contact with the shinx personally, we do need to have the permission to change the mode, at least to disable all the pre-prompt by default, for better user experience.
For example, I worried that the translation between languages would impair the accuracy of the technical information in the conversation. But the default mode seems to speak Chinese. And I do not have the permission to disable such a feature.

感谢大大将GPT3.5整合进了shinx 😆
在群聊中对.ai.change的使用权进行限制是合理的,因为这样我们就可以让shinx在群中发挥特定的作用(比如让它做个宝可梦)。但是在私聊中,我们可能确实需要改变模式的能力,或至少能够去除默认的提示语前缀。
比如,我担心中英转换会影响GPT3.5表意的准确性,因此我用英文对话并希望获得技术支持,但默认模式下,shinx是说中文的小猫怪...

Several improving suggestions

Thanks for your wonderful work! Shinxbot helps me a lot to ease my life and improve my study ability.

However, when reviewing the source code, I found some potential coding improvements for this project:

  1. homodata.txt is actually a data file. Placing it with configuration files in config does not look good to me.
  2. Changing part of shinx_message and resend the message to where it comes is somewhat weird though. Imagine that you receive a message in your mobile phone and you just edit some portion and forward to others.
  3. Since you have implemented a log system yourself, why not use it though out the repo. I noticed that std::cout, std::error was used sometimes.
  4. get_log actually means log_init, setlog is actually writing log. Moreover, get_log and setlog have distinct syntax.

SD API

Hello! I'm very interested in the API you use to generate images using Stable Difusion XL Turbo: sd.cuilutech.com

By any chance, you are its creator? Or perhaps you know where there is documentation for it from its creator himself?

Set git submodules always to the master branch

I notice that shinxbot2 retains specific checkouts of its submodules (as shown below) lagging behind the master/main branch development that fixes potential bugs.

Submodule path 'lib/CImg': checked out 'b99d58d9660f82c7c848e58768b85da01286c512'
Submodule path 'lib/base64': checked out 'db7c6834bd4f733899bd93218926247a659d8924'

So, a probably helpful suggestion is to set git submodules always to the master branch instead. Details may be found here.

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.