Skip to content

QQ官方机器人 Java/JVM/kotlin SDK QQ bot sdk qq机器人sdk

License

Notifications You must be signed in to change notification settings

Kloping/qqpd-bot-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qqpd-bot-java

License release

QQ机器人 Java/JVM/kotlin SDK

非官方 可用于 Java 8+

Java SDK主要基于基础 API (opens new window)封装,提供给用户一种简单、高效的使用方式。

Maven

<!-- https://repo1.maven.org/maven2/io/github/kloping/bot-qqpd-java/ -->
<dependency>
    <groupId>io.github.kloping</groupId>
    <artifactId>bot-qqpd-java</artifactId>
    <version>1.5.1-R2</version>
</dependency>

使用前提

  1. https://q.qq.com/ 申请机器人 获得Bot 开发者ID(appid) 和 机器人令牌(token)

2. 发布审核 发布后为公域

使用示例

启动方式

    Starter starter=new Starter("appid","token");
    starter.getConfig().setCode(Intents.PRIVATE_INTENTS.getCode());
    starter.run();

V1.5.0-Beta7+ 注册监听器主机方式 [荐]

starter.registerListenerHost(new ListenerHost(){
    @EventReceiver
    public void onEvent(MessageChannelReceiveEvent event){
        event.send("测试");
    }

    @EventReceiver 
    public void onEvent(MessageDirectReceiveEvent event){
        event.send("测试通过");
    }
});

V1.4.6

事件订阅 默认的事件订阅 不会接收消息事件
需要确定自己的机器人是公域还是私域
来确定 需要 设置订阅事件类型

//单事件订阅方式
starter.getConfig().setCode(Intents.GUILD_MESSAGES.getCode());

//多事件订阅方式
starter.getConfig().setCode(Intents.START.and(Intents.GUILD_MESSAGES,Intents.DIRECT_MESSAGE));

// 公域机器人订阅推荐
starter.getConfig().setCode(Intents.PUBLIC_INTENTS.getCode());

// 私域机器人订阅推荐
starter.getConfig().setCode(Intents.PRIVATE_INTENTS.getCode());

导入指引

import io.github.kloping.qqbot.Starter;
import io.github.kloping.qqbot.api.Intents;
import io.github.kloping.qqbot.api.message.MessageChannelReceiveEvent;
import io.github.kloping.qqbot.api.message.MessageDirectReceiveEvent;
import io.github.kloping.qqbot.impl.ListenerHost;

更多使用方式参考查看 test

SDK尚在完善中...

About

QQ官方机器人 Java/JVM/kotlin SDK QQ bot sdk qq机器人sdk

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages