Giter VIP home page Giter VIP logo

koishi's People

Contributors

anillc avatar arily avatar constasj avatar ddele avatar dgck81lnn avatar dragon-fish avatar h4m5ter avatar huanlinoto avatar idlist avatar ilharp avatar jjyyxx avatar koishi-bot avatar maikotan avatar mnixry avatar nn708 avatar nwylzw avatar pentatea avatar purerosefallen avatar reikohaku avatar samnyan avatar seidko avatar sheep2007 avatar shigma avatar shir0ha avatar simon300000 avatar thezzisu avatar undefined-moe avatar wxh06 avatar xxlittlecxx avatar yunyoujun 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  avatar  avatar  avatar  avatar

Watchers

 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

koishi's Issues

koishi 启动时报错

Describe the bug
启动使用 koishi 编写的项目后,打印出了下面这些报错:
(node:3361) UnhandledPromiseRejectionWarning: Error: authorization failed at HttpServer._listen (/LF/Robot/FenBin/Main/node_modules/koishi-core/dist/server.js:269:19) at processTicksAndRejections (internal/process/task_queues.js:94:5) (node:3361) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:3361) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

下面是我的配置:
const app = new App({ type: 'http', port: 41007, server: 'http://localhost:41006', secret: '***_2020', token: '************', })

Screenshots
Snipaste_2020-02-08_18-21-44.png

消息能发不能收

Describe the bug
消息能发不能收

To Reproduce
私聊,讨论组,群都不回调,不知道是什么原因,还是我用错了

app.middleware((meta, next) => {
console.log(meta.message)
return next()
})
app.receiver.on('message', (meta) => {
console.log(meta.message)
})

Expected behavior

Screenshots

Versions

  • Node Version: [e.g. 12.10.0]
  • CoolQ Version: [e.g. 5.15.5]
  • CQHTTP Version: [e.g. 4.13.0]
  • Koishi Version: [e.g. 1.1.1]

Additional context
实在分析不出问题在哪,能不能帮忙分析一下?

能否扩展 Meta 对象的属性

比如实现一个 meta.$reply 功能,用于回复某一段消息,如何全局扩展这个 meta 对象,或者未来是否有这个计划

无法发送群组消息

Describe the bug
可以发送私人消息(sender.sendPrivateMsg),
但无法发送群/组消息(sender.sendGroupMsg,sender.sendDiscussMsg)

To Reproduce
采用了官方文档中“调用 Koishi”的安装方式,正常执行程序,如下代码:

const {App} = require('koishi');

const app = new App({
    type: 'http',
    port: ....,
    server: 'http://...:5700',
})

app.start()

app.sender.sendPrivateMsg(823***839, `start qq.`);  // 该行可以正常发送消息
app.sender.sendGroupMsg(931***016, `group: i'm online...`);  // 该行无法发送消息
app.sender.sendDiscussMsg(931***016, `discuss: i'm online...`);  // 该行无法发送消息

在代码中,发送 Group 和 Discuss 消息均无法发送,且无报错;
经测试,可以正常接收到 931***016 的群消息;

Versions

  • OS: [ubuntu 16.04,Docker方式部署]
  • Node Version: [10.16]
  • CoolQ Version: [最新]
  • CQHTTP Version: [最新]
  • Koishi Version: [1.5.0]

请问是配置的问题还是什么原因呢?
如果需要,我可以继续补充信息,谢谢~

commandPrefix使用array做参数会抛出TypeError

Describe the bug
https://koishijs.github.io/guide/command-system.html#指令前缀
根据这里的文档commandPrefix可以提供array来实现多前缀触发指令。
但当我提供array时会抛出错误。
/node_modules/escape-string-regexp/index.js:7
throw new TypeError('Expected a string');

To Reproduce

const app = new App({
...
  commandPrefix: ["!","!"],
})

Expected behavior
数组中提供的所有前缀都可触发bot指令

Screenshots
image

Versions

  • OS:macOS
  • Node Version:12.13.0
  • CoolQ Version:5.15.5A
  • CQHTTP Version:4.12.3
  • Koishi Version: 1.0.0-alpha.8

Additional context

指令系统和中间件之间是否有冲突?链接数据库后为何指令系统失效?

Describe the bug

两个问题

  1. 在不连接数据库的情况下,先注册中间件,再注册指令,此时如果走了指令,在它之前注册的中间件不会触发。如果注册的是前置中间件,则只有中间件会触发,指令完全失效。

  2. 在连接数据库后,指令和中间件都不生效。。。已经在数据库中建了相应的表和字段。

To Reproduce

Expected behavior

Screenshots

Versions

最新的

  • OS: [e.g. iOS]
  • Node Version: [e.g. 10.16.0]
  • CoolQ Version: [e.g. 5.15.4]
  • CQHTTP Version: [e.g. 4.13.2]
  • Koishi Version: [e.g. 1.0.0]

Additional context

教程有误

Describe the bug

npm init -y的时候package中项目名为koishi
下一步安装koishi时会报错
To Reproduce

npm init -y
npm init koishi -D
Expected behavior

建议修改默认项目名称
Screenshots

Versions

  • OS: [e.g. iOS]
  • Node Version: [e.g. 10.16.0]
  • CoolQ Version: [e.g. 5.15.4]
  • CQHTTP Version: [e.g. 4.13.2]
  • Koishi Version: [e.g. 1.0.0]

Additional context

使用websocket报错

Describe the bug
我在创建koishi机器人的时候使用想使用websocket,但是无论是使用cli还是调用koishi都会报错,而使用post的方式就没有问题,请问是bug还是对websocket支持还没有完善

To Reproduce
使用cli的ws选项或者直接调用都会出现这种情况

Expected behavior
正常启动

Screenshots

error TypeError: Cannot destructure property 'pluginMajorVersion' of 'this.version' as it is undefined.
    at WsClient.versionLessThan (/data/data/com.termux/files/home/kbot/node_modules/koishi-core/dist/server.js:176:17)
    at WsClient.listen (/data/data/com.termux/files/home/kbot/node_modules/koishi-core/dist/server.js:186:22)

Versions

  • OS: Android 10 termux和CentOS 7上都试过了
  • Node Version: 12.16.1 和 13.6.0
  • CoolQ Version: 5.15.9
  • CQHTTP Version: 4.14.1
  • Koishi Version: 1.11.1

Additional context

Koishi v2 is coming 🎉

Work Items

Infrastructure

Context API

Session API

  • queued sender
  • session observer
  • command operations
  • session middleware & prompt API

Command API

  • functional user/group fields
  • special options
  • typed options
  • option validators
  • better error display
  • custom terminator

Internal Features

  • built-in user/group fields adjustments
  • built-in help command
  • decouple shortcut API
  • decouple suggestion API
  • decouple validation API

Lifecycle & Modularization

  • single app instance
  • lifecycle event adjustments
  • migrate database to plugins

Utility & CLI

  • logger API integration
  • date API for built-in plugins
  • enhanced process management

Unit Test

  • basic support
  • self-testing
    • koishi-core
    • koishi-utils
    • koishi-test-utils
    • koishi-plugin-common

Documentation

  • handbook
  • API references
  • migration guide

koishi-plugin-mysql

  • custom getters
  • custom type casting
  • automatically creating tables and columns

koishi-plugin-mongo

A lot thanks to @masnn

koishi-plugin-common

  • remove exec/exit command
  • integrate more sender APIs
  • info command update
  • admin command update
  • options.blacklist
  • options.throttle

koishi-plugin-teach

  • basic support
  • support escape character
  • shortcut syntax
  • context mechanism
  • permission system
  • appellation mode
  • regexp matcher
  • command interpolation
  • predecessor and successor
  • throttle and prevent loop
  • static image server
  • review and revert

koishi-plugin-status

  • basic support
  • status server
  • status database

koishi-plugin-schedule

  • basic support
  • support time offset
  • support time unit
  • support max times

getGroupList() 与 getGroupInfo() 被调用之后不返回值

getGroupList()getGroupInfo() 被调用之后不返回值。

const { App: Koishi } = require('koishi');
class Bot {
    constructor(item) {
        this.config = item.config;
        this.app = new Koishi({
            type: 'ws',
            port: 6700,
            server: `ws://${this.config.host || 'localhost'}:${this.config.port || '6700'}`,
            token: this.config.access_token
        });
        this.run();
    }
    async run() {
        this.app.receiver.on('connect', async () => {
            console.log('Connected');
            let groups = await this.app.sender.getGroupList();
            console.log(`Found ${groups.length} groups`); // -> No output
        });
        await this.app.start();
    }
};
let config = require('./config.json');
global.App = new Bot({ config });

CQHTTP 显示 已成功处理一个API请求:get_group_list

Ubuntu 1604
[email protected]
[email protected]
[email protected]
[email protected]

关于mysql数据使用的问题

Describe the bug
我配置好mysql数据库之后,收到消息时,出现了以下问题:

(node:4164) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '_timestamp' of undefined
    at MysqlDatabase.getGroup (F:\WebProject\tool-man\node_modules\koishi-database-mysql\dist\group.js:14:44)
    at MysqlDatabase.observeGroup (F:\WebProject\tool-man\node_modules\koishi-database-mysql\dist\group.js:61:37)
    at Array.App._preprocess (F:\WebProject\tool-man\node_modules\koishi-core\dist\app.js:134:55)
    at next (F:\WebProject\tool-man\node_modules\koishi-core\dist\app.js:199:103)
    at EventEmitter.App._applyMiddlewares (F:\WebProject\tool-man\node_modules\koishi-core\dist\app.js:206:19)
    at EventEmitter.emit (events.js:200:13)
    at App.emitEvent (F:\WebProject\tool-man\node_modules\koishi-core\dist\app.js:348:30)
    at HttpServer.dispatchMeta (F:\WebProject\tool-man\node_modules\koishi-core\dist\server.js:162:17)
    at IncomingMessage.<anonymous> (F:\WebProject\tool-man\node_modules\koishi-core\dist\server.js:249:22)
    at IncomingMessage.emit (events.js:205:15)
(node:4164) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)

下面是我的配置:

const app = new App({
    type: 'http',
    port: 8080,
    server: 'http://localhost:5700',
    database: {
        mysql: {
            host: '*.*.*.*',
            port: 3306,
            user: 'root',
            password: '******',
            database: 'coolq'
        },
    }
})

databases

Additional context
此外,看了一下你之前关于mysql初始化的问题,是不是要手动创建那些你在API里调用的表和字段?

配置 MySQL 后无法启动

在配置文件中配置 MySQL 后无法启动机器人

module.exports = {
  type: "http",
  port: 8080,
  server: "http://localhost:5700",
  plugins: [

  ],
  database: {
    mysql: {
      host: 'x.x.x.x',
      port: 3306,
      user: 'root',
      password: 'xxxxxx',
      database: 'xxx',
    },
  }, 
}

错误信息

error TypeError: Cannot read property '0' of undefined
    at loadEcosystem (/usr/local/lib/node_modules/koishi/dist/worker.js:65:72)
    at prepareApp (/usr/local/lib/node_modules/koishi/dist/worker.js:92:26)
    at Object.<anonymous> (/usr/local/lib/node_modules/koishi/dist/worker.js:111:5)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
  • OS: Ubuntu 20.04
  • Node Version: 10.19.0
  • CoolQ Version: 5.15.10
  • CQHTTP Version: 4.15.0
  • Koishi Version: 1.12.0

Feature request: Docker support

It seems that both CoolQ and CQHTTP have Docker support. Shall we make a Docker image for Koishi to help users deploy Koishi on Linux servers more quickly?

中间件对群消息不执行

Describe the bug
中间件对群消息不执行

To Reproduce
···
app.middleware((meta, next) => {
console.log(meta)
return next()
})
···
对群发送一条消息

Expected behavior

日志输出 meta 对象

Versions

  • OS: Debian 10
  • Node Version: 14.5.0
  • CoolQ Version: Air
  • CQHTTP Version: 4.15.0
  • Koishi Version: 1.12.0

Additional context

这 SDK 是先有文档再有程序的吧

不转换简体/繁体字符

Is your feature request related to a problem? Please describe.

这里会自动把繁体字转换为简体字
$parsed很好用,但希望能不强制转换为简体字

Describe the solution you'd like

options中增加参数阻止繁体字被转换为简体字

Describe alternatives you've considered

不用$parsed.message

Additional context

koishi-plugin-eval 漏洞整理

这个 issue 用于整理 koishi-plugin-eval 中存在的漏洞。对漏洞的定义包括:

  • 修改用户数据的行为
  • 实现沙箱逃逸的行为
  • 获取文件路径的行为
  • 导致主线程崩溃的行为

提交漏洞时请附上代码。

关于指令系统代码的一个建议和疑问

Is your feature request related to a problem? Please describe.
我发现,command是通过context进行构造,也就是说我需要获得context之后再声明这个command。比如我的入口是index.js,这样的话是不是所有command的逻辑和index.js的逻辑都写在一起了?

Describe the solution you'd like
能不能给context增加addCommand()类似的方法,把command的声明和执行的逻辑从index.js中拆分出去。这样我就可以创建一个command的文件夹,然后再把这些command导入index.js,再addCommand()。

或者在当前版本,我如何实现这样的目的?或者有没有更好的方法?

运行时卸载插件

Is your feature request related to a problem? Please describe.

我想在运行时安装卸载一些中间件(使用场景为给每个群安装群特有的中间件,并且可以通过命令禁用)

Describe the solution you'd like

增加一个卸载middleware的api

const middleware = require('my-middleware')
//其实我觉得叫install,use一类会更清楚一些
ctx.plugin(middleware)

ctx.plugin((meta,next) => {
const parsed = meta.$parsed
const tiggered = (
  ['atMe','nickname','prefix'].some(trigger => parsed[trigger]) &&
  parsed.message.startsWith('disable')
)
if (!triggered) return next()
const target = parsed.message.slice(8)
try {
  const middlewareToRemove = require(target)
  //here!
  ctx.remove(middlewareToRemove)
} catch (error) {
  meta.$send('unable to find that.')
}
}

Describe alternatives you've considered

每次增减插件时创建一个新的context安装这些插件,但对插件实现有限制,内部需要无状态,全部通过数据库实现
(我似乎也没找到销毁ctx的方法)
Additional context

koishi-database-memory

When koishi-database-memory installed, (with koishi-plugin-common)
The meta.$user field is still undefined.

const { App: Koishi } = require('koishi');
const config = require('./config');
require('koishi-database-memory');
const App = new Koishi({
    type: 'ws',
    port: 6700,
    server: `ws://${config.host || 'localhost'}:${config.port || '6700'}`,
    token: config.access_token,
    commandPrefix: config.prompt,
    database: {
        memory: {}
    }
});
App.plugin(require('koishi-plugin-common'), {
    admin: true,
    broadcast: false,
    contextify: false,
    echo: false,
    exec: false,
    exit: false,
    help: true,
    info: true
});
App.receiver.on('message', async meta => {
    console.log(meta.$user); // Prints undefined
});
App.start();
{
    "koishi": "^1.11.1",
    "koishi-database-memory": "^1.1.6",
    "koishi-plugin-common": "^2.1.7"
}
  • OS: Ubuntu1604
  • Node Version: 13.3
  • CoolQ Version: 5.15.9A
  • CQHTTP Version: 4.13
  • Koishi Version: 1.11.1

Koishi v2 is coming...... 🎉

image

经过半年多,上万行代码的开发,Koishi v2 终于要跟大家见面了。目前核心功能已经趋于稳定,预计下周出 beta 版本。

[Feature] Logger API

Is your feature request related to a problem? Please describe.

插件需要输出不同重要度的信息,但是目前 Koishi 没有统一的 log level。

Describe the solution you'd like

提供一个内置的 Logger API,仅触发事件,实现由 CLI 提供:

ctx.logger().info(message)
ctx.logger(scope).warn(message)

然后在命令行中增加 --log-level 参数,提供 0-4 共 5 个不同的输出等级。配置文件中可以进一步对信息进行过滤,或指定输出到的文件等。

Describe alternatives you've considered

直接通过事件触发:

ctx.app.emit('info', null, message)
ctx.app.emit('warn', scope, message)

Additional context

N/A

Feature request: session.createSession()

app.command('a').action(({ session }) => {
    session.createSession((session: Session, dispose: Function) => {
        if (session.message === '1') return dispose();
        return session.$send('Input another number');
    });
});

如上,创建session之后所有该用户输入交由提供的函数处理,不进行指令调用等的解析,直到释放;

程序抛出了无法解决的错误

使用以下代码启动之后

const app = new App({
    type: "ws",                         
    server: "127.0.0.1:6700"
})                                      


startAll().catch(e=>{
    console.log(e);
})

获得了这样的错误

TypeError: Cannot read property 'close' of undefined
    at WsClient._close (/node_modules/koishi-core/dist/server.js:360:21)
    at WsClient.close (/node_modules/koishi-core/dist/server.js:206:14)
    at WsClient.listen (/node_modules/koishi-core/dist/server.js:199:18)

请问是否是我的传值错误,或者是由什么引发该错误

有计划实现反向websocket通信么?

Describe the bug

尝试把前端切换到mirai,使用了cqhttp-mirai插件,但是cqhttp-mirai不支持http api,koishi又不支持反向websocket。。。好难办

话说作者有计划支持mirai么?
To Reproduce

Expected behavior

Screenshots

Versions

  • OS: [e.g. iOS]
  • Node Version: [e.g. 10.16.0]
  • CoolQ Version: [e.g. 5.15.4]
  • CQHTTP Version: [e.g. 4.13.2]
  • Koishi Version: [e.g. 1.0.0]

Additional context

MySQL 自动初始化

LevelDB 是不需要自动初始化的,但是 MySQL 需要,所以应该在 bot 连接到数据库的时候自动监测是否存在对应的表,如果不存在则自动进行添加,如果发生缺项的情况也应进行补足。

[Feature] Official Record Plugin

Is your feature request related to a problem? Please describe.
需要记录某些群的聊天记录。

Describe the solution you'd like
编写 koishi-plugin-recorder,按照配置的群号将聊天记录输出到本地文件中,包括消息的文本、发送人、发送时间。

Describe alternatives you've considered
N/A

Additional context
N/A

[Feature] Hot Reload API

Is your feature request related to a problem? Please describe.

我们有时需要在机器人运行时重载代码。

Describe the solution you'd like

提供一个热重载 API,使得 app 可以在运行时重载,同时保持监听事件(并缓存),如果可以的话还可以保留未重载的文件的状态。

Describe alternatives you've considered

关闭子进程,更新文件,重开一个子进程(缺点是状态和过程中的请求会丢失)。

Additional context

Better logging

提供选项,让command执行中遇到错误自动发送 e.message 到群或打印到console
或者command return一个string或Promise也可以作为快捷回复使用

请问可以用pm2跑koishi吗,或者别的解决Unexpected end of JSON input的法子

Describe the bug

C:\Program Files\workspace\acghomebuild\koishi_demo>koishi run info apply plugin common port=8080 info Koishi/1.11.2 CoolQ/Pro CQHTTP/4.15.0 info server listening at 8080 info connected to http://localhost:5701 success bot started successfully in 445 ms. error SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at IncomingMessage.req.on (C:\Users\Administrator\AppData\Roaming\npm\node_modules\koishi\node_modules\koishi-core\dist\server.js:232:35) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1129:12) at process._tickCallback (internal/process/next_tick.js:63:19)
To Reproduce

未知,程序均可以正常运行(可以联系并提供源码),本地win10跑正常无报错。
仅腾讯云的windows server环境下,过一段时间,会出现此问题
Expected behavior

解决这个问题,或者问题出现后依然可以运行项目(比如pm2之类的手段),
或者有排查错误原因的良方
Screenshots

Versions

  • OS: windows server 2016 数据中心版 64位中文版
  • Node Version: v10.16.0
  • CoolQ Version: 1.11.2
  • CQHTTP Version: 4.15.0
  • Koishi Version:
    koishi/1.11.2 win32-x64 node-v10.16.0
    koishi v1.11.2

Additional context

感觉不是我的锅就是腾讯云的锅

请问中间件可以处理加群等事件吗?

看到文档里中间件可以接收到notice或request型的元数据,但是如果我注册中间件并直接console.log(meta),在实际测试中如果有加群申请或者有新成员入群,打印并不触发,意味着meta没有截获到东西,只有正常的message可以触发。

这是否意味着当前这类事件只能通过receiver处理,不能用中间件?如果可以需要怎么使用?

版本信息:Koishi/1.11.2 CoolQ/Air CQHTTP/4.14.2

Is it possible to push messages in QQ group to RSS?

Is your feature request related to a problem? Please describe.

I found it so tired to read through the QQ group list.

我发现翻阅 QQ 群列表的聊天记录很累。

Meanwhile, I get in touch with RSS, and found it save much efforts for me. I just need to add a link, it will monitor the website, and push the new articles to me.

与此同时,我接触了 RSS ,它替我省下了很多精力。只需要添加链接就能推送新文章。

mainly,sometimes it's meaningful to save the chatting record.

主要是,很多时候的聊天记录是值得保存的。

and with RSS, I can easily manage them and read them like newspaper.

并且用了 RSS 后,我能方便地管理它们。

Describe the solution you'd like

for example, it can push the message (maybe specific) stream to a local html. and RSS will do the remaining things.

比如,他可以把消息流推送到一个本地的 html 文件里,RSS 会完成剩下工作。相关图片也许可以推送至 Github 图床(或直接存至本地)

Describe alternatives you've considered

手动整理是非常麻烦的。并且网上似乎也没有相关资料。

Additional context

related issue

不想删了,交了然后 close 掉好了

上下文是不是不可以做到同时满足多个条件

Expected behavior

group / groups / user / users 多个条件组合同时满足
例如 app.group(123) && app.users.except(456) 在群123中除了456以外的用户
不知道现在的版本是否能够做到这个需求?

Versions

1.12.0

对指定的上下文安装命令后执行异常

Describe the bug

对指定的上下文安装命令后,执行正确的命令时出现 你要找的是不是...

To Reproduce

const { App } = require('koishi')
require('koishi-database-mysql')

global.dev=true
const app = new App({
  type: 'http',
  port: 8080,
  server: 'http://localhost:5700'
})

app.start()
app.group(xxx).command('echo <message>')
  .action(({ meta }, message) => meta.$send(message))

在 xxx 这个群发送 echo a

Expected behavior

机器人回复“a”

Screenshots

C936CCB999261852C947E1BBF8ED63A7

Versions

  • OS: Ubuntu 20.04 WSL
  • Node Version: 12.18.2
  • CoolQ Version: 5.15.10
  • CQHTTP Version: 4.15.0
  • Koishi Version: 1.12.0

Koishi 1.0 Roadmap

core

  • 90% coverage
  • scope parser

utils

  • 90% coverage
  • synchronized observer

docs

  • guide: authority management
  • guide: detailed configurations

请问一下有关于插件的例子吗

在插件上下文中使用sender无效

error ctx.sender.sendPrivateMessage is not a function

module.exports.name = 'base'

module.exports.apply = (ctx) => {
  ctx.receiver.on('message', (meta) => {
    ctx.sender.sendPrivateMessage(*, 'Hello world')
  })
  console.log(ctx.sendPrivateMessage)
}

meta.$send 无法发送群组消息

Describe the bug
meta.$send 无法发送群组消息

To Reproduce

const {
    App
} = require('koishi');

const app = new App(require('./koishi.config'));

app.receiver.on('message', (meta) => {
    if (meta.message === '人有多大胆') {
        meta.$send('地有多大产')
    }
})

app.start();

Screenshots
image

Versions

  • OS: [e.g. iOS]
  • Node Version: v12.11.1
  • CoolQ Version: 5.15.10
  • CQHTTP Version: 4.15.0
  • Koishi Version: v1.12.0

Additional context
私聊能收到回复,但是群聊不行,我使用其他库发送群聊消息都能收到(比如 cqhttp),不知道是什么原因。加群已经一年多了,各方面状态都正常,sendGroupMsgsendGroupMsgAsync 也试了,也是发不出去。

Websocket方式下增加自动重连功能

Is your feature request related to a problem? Please describe.
选择Websocket连接方式时,如果与Cqhttp服务器的ws连接断掉,就无法收到消息,必须重启应用。

Describe the solution you'd like
当ws连接断开时,能够有可配置(重试次数,重试策略,Exponential Backoff 之类)的自动重连能力。

交互性 koishi init 指令

修改目前的 koishi init 指令,使之能够通过类似 npm init 的方式提示用户创建配置文件。

根据文档上快速入门教程,执行koishi start报错

Describe the bug

根据文档上快速入门教程,执行koishi start报错
To Reproduce

cd my-bot
npm i koishi -g
koishi init
koishi start

Expected behavior

能够运行,连接上CQHTTP插件
Screenshots

error.png
Versions

nodejs v10.16
koishi v1.12.0
coolq-http-api v4.15.0

  • OS: [e.g. iOS]
  • Node Version: [e.g. 10.16.0]
  • CoolQ Version: [e.g. 5.15.4]
  • CQHTTP Version: [e.g. 4.13.2]
  • Koishi Version: [e.g. 1.0.0]

Additional context

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.