-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
c934ce2
commit 72ae919
Showing
5 changed files
with
127 additions
and
13 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,35 @@ | ||
import { Context } from 'koishi' | ||
|
||
import { MinecraftBot } from '@/plugins/adapter-minecraft' | ||
|
||
import BasePlugin from '~/_boilerplate' | ||
|
||
export class MinecraftConnect extends BasePlugin { | ||
constructor( | ||
public ctx: Context, | ||
options | ||
) { | ||
super(ctx, options, 'mc-connect') | ||
|
||
const QQ_GROUP = process.env.CHANNEL_QQ_NGNL_MINECRAFT | ||
|
||
const qqBot = ctx.bots.find((bot) => | ||
['onebot', 'red'].includes(bot.platform) | ||
) | ||
const qqCtx = ctx.channel(QQ_GROUP, process.env.CHANNEL_QQ_SANDBOX) | ||
const mcBot = ctx.bots.find( | ||
(bot) => bot.platform === 'minecraft' | ||
) as MinecraftBot<Context> | ||
const mcCtx = ctx.platform('minecraft') | ||
|
||
mcCtx.on('message', (session) => { | ||
qqBot.sendMessage( | ||
QQ_GROUP, | ||
`[MC] ${session.username}:\n${session.content}` | ||
) | ||
}) | ||
qqCtx.on('message', (session) => { | ||
mcBot.sendMessageAs(session.username, session.content) | ||
}) | ||
} | ||
} |
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