Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

session失效或不存在 #237

Open
mcl44 opened this issue Jun 21, 2023 · 1 comment
Open

session失效或不存在 #237

mcl44 opened this issue Jun 21, 2023 · 1 comment

Comments

@mcl44
Copy link

mcl44 commented Jun 21, 2023

代码如下,不知道为什么会报这个错

const { Bot, Message } = require("mirai-js");
const print = console.log;
const bot = new Bot();

// 连接到一个 mirai-api-http 服务
async function conn() {
  await bot.open({
    baseUrl: "http://0.0.0.0:9999",
    verifyKey: "INITKEYHX5of1Nh",
    // 要绑定的 qq,须确保该用户已在 mirai-console 登录
    qq: 2839389290,
  });  
}

async function getGroupMsg() {
  bot.on("GroupMessage", async (data) => {
    await bot.sendMessage({
      group: data.sender.group.id,
      message: new Message().addText("hello world!"),
    });

    // 你可以像这样来判断群成员的权限
    switch (data.sender.permission) {
      case Bot.groupPermission.OWNER:
        // 群主
        break;
      case Bot.groupPermission.ADMINISTRATOR:
        // 管理员
        break;
      case Bot.groupPermission.MEMBER:
        // 普通群成员
        break;
    }
  });
}

async function getFriendMsg() {
    await bot.sendMessage({
        // 好友 qq 号
        friend: '2329894267',
        // Message 实例,表示一条消息
        message: new Message().addText('hello world!').addImageUrl('http://exapmle/image.jpg'),
    });
    // bot.on("FriendRecallEvent", async (ctx) => {
    //   const msg = await bot.getMessageById({
    //     messageId: 1,
    //     target: 2329894267,
    //   });
    //   console.log(msg);
    // });
}

async function run() {
    console.log('111');
    await conn();
    setTimeout(() => {
        getFriendMsg();
    }, 6 * 1000);
    print('222');
    await bot.close({ keepConfig: true });  
}

run();
@Drincann
Copy link
Owner

麻烦提供更多上下文信息,比如 mirai-api-http 的版本号。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants