-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
122 changed files
with
3,810 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Config | ||
|
||
```yaml | ||
kotori: | ||
extends: onebot | ||
master: 10001 | ||
# 连接模式 可选: http ws ws-reverse 推荐首选ws-reverse | ||
mode: ws-reverse | ||
# address: "ws://127.0.0.1" | ||
# WebSocket反向(相对于Gocqhttp) | ||
# port: 8080 # WS反向端口 | ||
# WebSocket正向 | ||
address: ws://127.0.0.1 # WS地址 | ||
port: 8088 # WS端口 | ||
retry: 10 # 同上 | ||
# Http正反向(暂未支持) | ||
# address: "http://localhost" # 正向Http地址 | ||
# port: 8888 # 正向Http端口 | ||
# reverse-port: 8080 # 反向Http端口 | ||
# retry: 10 # 连接断开或失败时尝试重连间隔时间 单位:秒 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { OneBotAdapter } from './adapter'; | ||
import { OnebotAdapter } from './adapter'; | ||
|
||
export default OneBotAdapter; | ||
export default OnebotAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @Blog: https://hotaru.icu | ||
* @Date: 2023-09-29 14:31:09 | ||
* @LastEditors: Hotaru [email protected] | ||
* @LastEditTime: 2024-01-01 16:43:54 | ||
* @LastEditTime: 2024-01-14 17:45:01 | ||
*/ | ||
import { Adapter, AdapterConfig, Context, Tsu, obj } from 'kotori-bot'; | ||
import WebSocket from 'ws'; | ||
|
@@ -26,7 +26,12 @@ export class QQAdapter extends Adapter<QQApi> { | |
|
||
private seq = 0; | ||
|
||
private msg_seq = 0; | ||
/* here need */ | ||
public msg_seq = 0; | ||
|
||
private groupId = ''; | ||
|
||
public imageStack: (string | true)[] = []; | ||
|
||
public readonly config: QQConfig; | ||
|
||
|
@@ -71,6 +76,8 @@ export class QQAdapter extends Adapter<QQApi> { | |
}, | ||
groupId: data.d.group_openid, | ||
}); | ||
this.groupId = data.d.group_openid; | ||
/* here need imporve */ | ||
} else if (data.op === 11) { | ||
this.online(); | ||
// this.offlineCheck(); | ||
|
@@ -100,18 +107,49 @@ export class QQAdapter extends Adapter<QQApi> { | |
return undefined; | ||
} | ||
let address = '/'; | ||
let cancel = false; | ||
let req: obj = {}; | ||
if (action === 'send_group_msg' && 'groupId' in params && 'message' in params && 'id' in params) { | ||
if (!params.message) return null; | ||
this.msg_seq += 1; | ||
address += `groups/${params.groupId}/messages`; | ||
req = { | ||
content: params.message, | ||
msg_type: 0, | ||
msg_id: params.id, | ||
msg_seq: this.msg_seq, | ||
}; | ||
if (this.imageStack[this.msg_seq]) { | ||
cancel = true; | ||
let timerId: NodeJS.Timeout | ||
const timer = () => setTimeout(() => { | ||
if (timerId) clearTimeout(timerId); | ||
if (this.imageStack[this.msg_seq] === true) { | ||
timerId = timer(); | ||
return; | ||
} | ||
req['file_info'] = { file_info: this.imageStack[this.msg_seq] }; | ||
req.msg_type = 7; | ||
this.ctx.http.post(`${API_ADDRESS}${address}`, req, { | ||
headers: { | ||
Authorization: `QQBot ${this.token}`, | ||
'X-Union-Appid': this.config.appid, | ||
}, | ||
validateStatus: () => true, | ||
}); | ||
}, 500); | ||
}; | ||
this.msg_seq += 1; | ||
} else if (action === 'send_group_msg_media' && 'url' in params && 'file_type' in params) { | ||
address += `groups/${this.groupId}/files`; | ||
req = { | ||
file_type: params.file_type, | ||
url: params.url, | ||
srv_send_msg: false, | ||
}; | ||
console.log(req); | ||
this.msg_seq += 1; | ||
} | ||
if (cancel) return undefined; | ||
return this.ctx.http.post(`${API_ADDRESS}${address}`, req, { | ||
headers: { | ||
Authorization: `QQBot ${this.token}`, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Elements, EventDataTargetId, none } from 'kotori-bot'; | ||
import QQAdapter from '.'; | ||
|
||
export class QQElements extends Elements<QQAdapter> { | ||
|
||
public image(url: string) { | ||
const seq = this.adapter.msg_seq; | ||
this.adapter.imageStack[seq] = true;; | ||
this.adapter.send | ||
('send_group_msg_media', { url })?.then(res => { | ||
if (!res || typeof res !== 'object' || !('file_info' in res)) { | ||
delete this.adapter.imageStack[seq] | ||
return; | ||
}; | ||
this.adapter.imageStack[this.adapter.msg_seq] = res.file_info as string; | ||
}) | ||
return ''; | ||
} | ||
} | ||
|
||
export default QQElements; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"bangumi.descr.bgm": "Search games/anime on Bangumi", | ||
"bangumi.descr.bgmc": "Get today's Bangumi schedule", | ||
"bangumi.msg.bgm": "Original Name: %name%\nChinese Name: %name_cn%\nSummary: %summary%\nTags: %tags%\nDetails: %url%\n%image%", | ||
"bangumi.msg.bgm.list": "%num%.%name%%name_cn%\n", | ||
"bangumi.msg.bgm.lists": "%list%Resend command and input [number] to choose corresponding content\nExample: /command content 2", | ||
"bangumi.msg.bgm.fail": "No matching items found: %input%", | ||
"bangumi.msg.bgmc": "Date: %weekday%~%list%", | ||
"bangumi.msg.bgmc.list": "\nOriginal Name: %name%\nChinese Name: %name_cn%\nAir Time: %air_date%\n%image%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"bangumi.descr.bgm": "Bangumiでゲーム/アニメを検索", | ||
"bangumi.descr.bgmc": "今日のBangumiの番組表を取得", | ||
"bangumi.msg.bgm": "オリジナル名: %name%\n中国語名: %name_cn%\n概要: %summary%\nタグ: %tags%\n詳細: %url%\n%image%", | ||
"bangumi.msg.bgm.list": "%num%.%name%%name_cn%\n", | ||
"bangumi.msg.bgm.lists": "%list%コマンドを再送信し、対応するコンテンツを選択するために[番号]を入力してください。\n例: /コマンド コンテンツ 2", | ||
"bangumi.msg.bgm.fail": "一致するアイテムが見つかりません: %input%", | ||
"bangumi.msg.bgmc": "日付: %weekday%~%list%", | ||
"bangumi.msg.bgmc.list": "\nオリジナル名: %name%\n中国語名: %name_cn%\n放送時間: %air_date%\n%image%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"bangumi.descr.bgm": "番组计划搜索游戏/动漫", | ||
"bangumi.descr.bgmc": "获取番组计划今日放送", | ||
"bangumi.msg.bgm": "原名: %name%\n中文名: %name_cn%\n介绍: %summary%\n标签: %tags%\n详情: %url%\n%image%", | ||
"bangumi.msg.bgm.list": "%num%。%name%%name_cn%\n", | ||
"bangumi.msg.bgm.lists": "%list%再次发送指令并传入参数[序号]以选择对应内容\n示例:/指令 内容 2", | ||
"bangumi.msg.bgm.fail": "未找到相关条目: %input%", | ||
"bangumi.msg.bgmc": "日期: %weekday%~%list%", | ||
"bangumi.msg.bgmc.list": "\n原名: %name%\n中文名: %name_cn%\n开播时间: %air_date%\n%image%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"bangumi.descr.bgm": "番组計劃搜索遊戲/動漫", | ||
"bangumi.descr.bgmc": "獲取番組計劃今日放送", | ||
"bangumi.msg.bgm": "原名: %name%\n中文名: %name_cn%\n介紹: %summary%\n標簽: %tags%\n詳情: %url%\n%image%", | ||
"bangumi.msg.bgm.list": "%num%。%name%%name_cn%\n", | ||
"bangumi.msg.bgm.lists": "%list%再次發送指令並傳入參數[序號]以選擇對應內容\n示例:/指令 內容 2", | ||
"bangumi.msg.bgm.fail": "未找到相關條目: %input%", | ||
"bangumi.msg.bgmc": "日期: %weekday%~%list%", | ||
"bangumi.msg.bgmc.list": "\n原名: %name%\n中文名: %name_cn%\n開播時間: %air_date%\n%image%" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "kotori-plugin-bangumi", | ||
"version": "1.1.1", | ||
"description": "bangumi plugin", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "tsc --build" | ||
}, | ||
"license": "GPL-3.0", | ||
"files": [ | ||
"lib", | ||
"README.md" | ||
], | ||
"author": "Himeno <[email protected]>", | ||
"peerDependencies": { | ||
"kotori-bot": "workspace:^" | ||
}, | ||
"kotori": { | ||
"meta": { | ||
"language": [ | ||
"en_US", | ||
"ja_JP", | ||
"zh_TW", | ||
"zh_CN" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Kotori from 'kotori-bot'; | ||
|
||
const headers = { | ||
'user-agent': 'czy0729/Bangumi/6.4.0 (Android) (http://github.com/czy0729/Bangumi)', | ||
}; | ||
|
||
export const http: typeof Kotori.http.get = async (url, params) => | ||
Kotori.http.get(`https://api.bgm.tv/${url}`, params, { headers }); | ||
|
||
export default http; |
Oops, something went wrong.