2.2.0 • Published 3 months ago

koishi-plugin-mediawiki v2.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

MediaWiki for koishi.js

Koishi.js 的 MediaWiki 插件,将您的群聊与 wiki 站点紧密连接!

如何安装

SDK 玩家(推荐)

作者平时都这么玩,一般会确保这个方法是可用的

Add the package:

# Using pnpm
pnpm add koishi-plugin-mediawiki
# Yarn? Sure.
yarn add koishi-plugin-mediawiki
# Or just npm
npm i koishi-plugin-mediawiki

Then in your entry file:

// Import the plugin
import PluginMediawiki from 'koishi-plugin-mediawiki'
// the `app` is koishi App instance
app.plugin(PluginMediawiki, {
  // configs here...
})

CLI 玩家(也还行,就是配置自定义信息框的时候会很抽象)

koishi.yml

plugins:
  mediawiki:
    # configs here...

控制台玩家(我不好说,大概兼容吧……)

在插件中心搜索koishi-plugin-mediawiki

特色功能

您正在经营 MediaWiki 网站的附属群聊?为您的 koishi 机器人添加“wiki”指令吧,实用 wiki 功能一网打尽!

便捷绑定

一键配置 wiki 与群组连接,无需写死在配置文件

页面链接及详情

自动识别消息里的 wiki 链接,兼容中文简繁转换,此外还可以输出页面摘要(为防止刷屏预设关闭)

还能正确处理锚点

处理特殊页面,防止暴露敏感信息

即使页面不存在也不会爆炸

以及其他超酷的功能

  • 搜索 wiki,并给出前几个匹配项的摘要
  • 请求条目不存在时,自动使用关键字进行搜索(预设关闭)
  • 发送条目的信息框(Infobox)截图(内置萌娘百科、灰机、Fandom 支持,其他 wiki 可能需要自行配置,见下方说明)

都看到这了,快去安装吧

配置选项

interface Config {
  // 指令用户权限
  cmdAuthWiki: number // 1
  cmdAuthConnect: number // 2
  cmdAuthSearch: number // 1
  // 页面不存在时自动搜索(预设关闭)
  searchIfNotExist: boolean
  // wiki 指令附带页面摘要(预设关闭)
  showDetailsByDefault: boolean
  // 额外信息框配置
  customInfoboxes: InfoboxDefinition[]
}

自定义信息框配置

SDK 玩家(推荐)

// 举个例子
app.plugin(PluginMediawiki, {
  customInfoboxes: [
    {
      // URL匹配规则
      match: (url: URL) => url.host.endsWith('fandom.com'),
      // infobox 选择器列表
      selector: ['.mw-parser-output aside.portable-infobox'],
      // 额外 css
      injectStyles: '.foo { display: none } .bar { display: block }',
    },
  ],
})

CLI/控制台玩家

写正则表达式的时候得小心点,它真的很抽象,但是我确实没有更好的办法兼容它了

plugins:
  plugins:
    mediawiki:
      # URL匹配规则,一个正则表达式字符串
      match: '^https?:\/\/.+?\.fandom\.com'
      # infobox 选择器列表
      selector:
        - '.mw-parser-output aside.portable-infobox'
      # 额外 css
      injectStyles: |
        .foo { display: none }
        .bar { display: block }

系统需求

  • koishi 主程序版本 ^4.16.0
  • 需要数据库支持 koishi-database-*
  • 截图功能需要 koishi-plugin-puppeteer

Copyright 2021 Dragon-Fish

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
2.2.0

3 months ago

2.1.0

10 months ago

2.0.3

1 year ago

2.0.0-alpha.3

1 year ago

2.0.2

1 year ago

2.0.0-alpha.0

1 year ago

2.0.0-alpha.1

1 year ago

2.0.0-alpha.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

2 years ago

0.1.0

2 years ago

0.0.5

2 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago