1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-05 02:30:23 +08:00
2023-11-22 22:42:59 +09:00
2023-10-16 00:26:04 +09:00
2023-11-16 01:31:07 +09:00
2023-11-22 21:42:08 +09:00
2023-10-16 00:26:04 +09:00
2023-11-16 22:57:47 +09:00
2023-11-22 21:42:08 +09:00
2023-11-22 22:36:13 +09:00
2023-10-18 15:17:30 +09:00
2023-10-16 00:26:04 +09:00
2023-11-22 21:53:24 +09:00
2023-10-16 00:26:04 +09:00
2023-11-17 14:02:54 +09:00
2023-11-17 14:02:54 +09:00
2023-11-16 22:57:47 +09:00
2023-10-13 00:45:21 +09:00
2023-11-22 22:31:41 +09:00
2023-10-12 01:00:38 +09:00
2023-11-12 15:56:40 +09:00
2023-11-16 01:32:31 +09:00
2023-10-16 22:56:51 +09:00
2023-10-10 10:45:55 +09:00
2023-10-16 22:56:51 +09:00
2023-10-16 00:26:04 +09:00
2023-11-16 22:57:47 +09:00
2023-10-15 01:07:38 +09:00
2023-10-12 00:36:23 +09:00
2023-10-14 13:37:45 +09:00
2023-10-13 00:36:03 +09:00
2023-10-14 00:37:43 +09:00
2023-10-12 00:43:15 +09:00
2023-10-17 00:42:18 +09:00
2023-10-15 17:12:16 +09:00
2023-10-14 01:09:46 +09:00
2023-10-14 01:09:46 +09:00
2023-10-11 23:52:49 +09:00
2023-10-13 00:36:03 +09:00
2023-11-22 22:42:59 +09:00
2023-10-14 01:09:46 +09:00
2023-10-12 00:43:15 +09:00
2023-10-14 01:09:46 +09:00
2023-10-11 17:50:57 +09:00
2023-10-13 21:39:49 +09:00
2023-11-16 22:57:47 +09:00
2023-11-22 17:50:36 +09:00
2023-11-16 22:57:47 +09:00
2023-11-16 01:31:07 +09:00
2023-11-16 22:57:47 +09:00
2023-10-19 00:55:14 +09:00
2023-11-22 21:42:08 +09:00
2023-11-16 23:49:29 +09:00
2023-11-22 21:42:08 +09:00
2023-10-16 00:26:04 +09:00
2023-10-16 00:26:04 +09:00
2023-10-16 00:26:04 +09:00

东云名乃

NanoBot

类ZeroBot的官方QQ频道/群聊全域机器人框架, 简单易用


Instructions

Note: This framework is built mainly for Chinese users thus may display hard-coded Chinese prompts during the interaction.

参见 QQ 官方文档

快速开始(基于插件)

查看example文件夹以获取更多信息

开始响应 服务列表 查看用法

启用禁用

package main

import (
	_ "github.com/fumiama/NanoBot/example/echo"

	nano "github.com/fumiama/NanoBot"
	log "github.com/sirupsen/logrus"
)

func main() {
	log.SetLevel(log.DebugLevel)
	nano.OpenAPI = nano.SandboxAPI
	nano.OnMessageFullMatch("help").SetBlock(true).
		Handle(func(ctx *nano.Ctx) {
			_, _ = ctx.SendPlainMessage(false, "echo string")
		})
	nano.Run(nil, &nano.Bot{
		AppID:      "你的AppID",
		Token:      "你的Token",
		Secret:     "你的Secret, 可以不填 (QQ群Bot必须填写)",
		Intents:    nano.IntentPublic,
		SuperUsers: []string{"用户ID1", "用户ID2"},
	})
}

更多选择(传统的事件驱动)

如果声明了 Handler, 所有插件将被禁用

event-based example

package main

import (
	"strings"

	nano "github.com/fumiama/NanoBot"
	log "github.com/sirupsen/logrus"
)

func main() {
	log.SetLevel(log.DebugLevel)
	nano.OpenAPI = nano.SandboxAPI
	nano.Run(nil, &nano.Bot{
		AppID:   "你的AppID",
		Token:   "你的Token",
		Secret:  "你的Secret, 可以不填 (QQ群Bot必须填写)",
		Intents: nano.IntentPublic,
		Handler: &nano.Handler{
			OnAtMessageCreate: func(s uint32, bot *nano.Bot, d *nano.Message) {
				u := ""
				if len(d.Attachments) > 0 {
					u = d.Attachments[0].URL
					if !strings.HasPrefix(u, "http") {
						u = "http://" + u
					}
				}
				_, err := bot.PostMessageToChannel(d.ChannelID, &nano.MessagePost{
					Content:        "您发送了: " + d.Content,
					Image:          u,
					ReplyMessageID: d.ID,
					MessageReference: &nano.MessageReference{
						MessageID: d.ID,
					},
				})
				if err != nil {
					bot.PostMessageToChannel(d.ChannelID, &nano.MessagePost{
						Content:        "[ERROR]: " + err.Error(),
						ReplyMessageID: d.ID,
					})
				}
			},
		},
	})
}

Thanks

Languages
Go 100%