-
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
39 changed files
with
817 additions
and
104 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
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 @@ | ||
# drift-bottle | ||
|
||
throw and pick bottles | ||
|
||
**Version:** 1.0.0 | ||
**Author:** himeno | ||
**License:** GPL-3.0 | ||
**Front Plugin:** grouper | ||
|
||
## List of command | ||
|
||
- /print <...content> - send a message on privates#^^ | ||
- /echo <...message> - send a message on group\*^^ | ||
|
||
## Config | ||
|
||
```ts | ||
export default { | ||
maxNum: 3, | ||
}; | ||
``` | ||
|
||
## Lang Support | ||
|
||
- ja_JP | ||
- en_US | ||
- 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,9 @@ | ||
{ | ||
"drift_bottle.descr.pick": "Pick up a drift bottle", | ||
"drift_bottle.msg.pick.none": "No drift bottles available at the moment", | ||
"drift_bottle.msg.pick.info": "Message in bottle: {0}\nTime: {1}\nSource group: {2}", | ||
"drift_bottle.descr.throw": "Throw a drift bottle~", | ||
"drift_bottle.msg.throw.info": "{0} Your bottle has been thrown into the sea~", | ||
"drift_bottle.msg.throw.fail": "{0} You have already thrown {1} bottles today, come back tomorrow~", | ||
"drift_bottle.msg.throw.empty": "{0} Message cannot be empty" | ||
} |
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,9 @@ | ||
{ | ||
"drift_bottle.descr.pick": "漂流瓶を拾う", | ||
"drift_bottle.msg.pick.none": "現在利用可能な漂流瓶はありません", | ||
"drift_bottle.msg.pick.info": "瓶の中身: {0}\n時間: {1}\n出所グループ番号: {2}", | ||
"drift_bottle.descr.throw": "漂流瓶を投げる~", | ||
"drift_bottle.msg.throw.info": "{0} あなたの瓶が海に投げられました~", | ||
"drift_bottle.msg.throw.fail": "{0} 今日の投げる回数は{1}回超えています。明日また来てね~", | ||
"drift_bottle.msg.throw.empty": "{0} 内容を空にすることはできません" | ||
} |
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,9 @@ | ||
{ | ||
"drift_bottle.descr.pick": "捡取一个漂流瓶", | ||
"drift_bottle.msg.pick.none": "暂时还没有一个漂流瓶", | ||
"drift_bottle.msg.pick.info": "瓶子内容:{0}\n时间:{1}\n来源群号:{2}", | ||
"drift_bottle.descr.throw": "投掷一个漂流瓶~", | ||
"drift_bottle.msg.throw.info": "{0}你的瓶子已投掷大海~", | ||
"drift_bottle.msg.throw.fail": "{0}今天的投掷次数已超过 {1} 次,明天再来吧~", | ||
"drift_bottle.msg.throw.empty": "{0}内容不能为空" | ||
} |
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,9 @@ | ||
{ | ||
"drift_bottle.descr.pick": "撿取壹個漂流瓶", | ||
"drift_bottle.msg.pick.none": "暫時還沒有壹個漂流瓶", | ||
"drift_bottle.msg.pick.info": "瓶子內容:{0}\n時間:{1}\n來源群號:{2}", | ||
"drift_bottle.descr.throw": "投擲壹個漂流瓶~", | ||
"drift_bottle.msg.throw.info": "{0}妳的瓶子已投擲大海~", | ||
"drift_bottle.msg.throw.fail": "{0}今天的投擲次數已超過 {1} 次,明天再來吧~", | ||
"drift_bottle.msg.throw.empty": "{0}內容不能爲空" | ||
} |
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,35 @@ | ||
{ | ||
"name": "kotori-plugin-drift-bottle", | ||
"version": "1.0.0", | ||
"description": "throw and pick bottles", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "tsc --build" | ||
}, | ||
"keywords": [ | ||
"kotori", | ||
"chatbot", | ||
"kotori-plugin" | ||
], | ||
"license": "GPL-3.0", | ||
"files": [ | ||
"lib", | ||
"locales", | ||
"LICENSE", | ||
"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,56 @@ | ||
import { Context, MessageScope, Tsu, getRandomInt } from 'kotori-bot'; | ||
|
||
export const lang = [__dirname, '../locales']; | ||
|
||
export const inject = ['file']; | ||
|
||
export const config = Tsu.Object({ | ||
max: Tsu.Number().default(4) | ||
}); | ||
|
||
type Bottle = [string, number, number | string, (number | string)?]; | ||
|
||
const getZero = () => { | ||
const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()); | ||
today.setHours(0); | ||
today.setMinutes(0); | ||
today.setSeconds(0); | ||
today.setMilliseconds(0); | ||
return today.getTime(); | ||
}; | ||
|
||
export function main(ctx: Context, conf: Tsu.infer<typeof config>) { | ||
const getBottle = (platform: string) => ctx.file.load(`${platform}.json`, 'json', []) as Bottle[]; | ||
const setBottle = (platform: string, data: Bottle[]) => ctx.file.save(`${platform}.json`, data, 'json'); | ||
|
||
ctx | ||
.command('throw <content> - drift_bottle.descr.throw') | ||
.action((data, session) => { | ||
const at = session.el.at(session.userId); | ||
if (!data.args[1]) return ['drift_bottle.msg.throw.empty', [at]]; | ||
const bottles = getBottle(session.api.adapter.platform); | ||
const zero = getZero(); | ||
let count = 0; | ||
bottles.forEach((Element) => { | ||
if (Element[3] !== session.userId) return; | ||
if (Element[1] < zero) return; | ||
count += 1; | ||
}); | ||
if (count > conf.max) return ['drift_bottle.msg.throw.fail', [at, conf.max]]; | ||
bottles.push([data.args[1] as string, new Date().getTime(), session.groupId!, session.userId!]); | ||
setBottle(session.api.adapter.platform, bottles); | ||
return ['drift_bottle.msg.throw.info', [at]]; | ||
}) | ||
.help('') | ||
.scope(MessageScope.GROUP); | ||
|
||
ctx | ||
.command('pick - drift_bottle.descr.pick') | ||
.action((_, session) => { | ||
const data = getBottle(session.api.adapter.platform); | ||
if (!data || data.length < 0) return 'drift_bottle.msg.pick.none'; | ||
const bottle = data[getRandomInt(data.length - 1)]; | ||
return ['drift_bottle.msg.pick.info', [bottle[0], session.i18n.time(new Date(bottle[1])), bottle[2]]]; | ||
}) | ||
.scope(MessageScope.GROUP); | ||
} |
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,12 @@ | ||
{ | ||
"extends": "../../tsconfig.node.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./lib" | ||
}, | ||
"references": [ | ||
{ | ||
"path": "../../packages/kotori" | ||
} | ||
] | ||
} |
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
File renamed without changes.
Oops, something went wrong.