添加免费礼物感谢开关
This commit is contained in:
parent
7cf982baec
commit
dcb617f43d
@ -8,7 +8,7 @@ interface Message {
|
||||
data: any;
|
||||
}
|
||||
|
||||
const server = new WebSocketServer(config.api.port);
|
||||
const server: WebSocketServer = new WebSocketServer(config.api.port);
|
||||
const authedClientSet: Set<WebSocketClient> = new Set();
|
||||
|
||||
class APIMsgHandler extends EventEmitter {
|
||||
|
@ -27,6 +27,7 @@ interface ConfigStruct {
|
||||
cold_down_time: number
|
||||
advertiseing_cold_down: number
|
||||
api: api_config
|
||||
free_gift_action: boolean
|
||||
}
|
||||
|
||||
const decoder = new TextDecoder('utf-8')
|
||||
|
@ -17,11 +17,13 @@ export function receiveGift(data: any) {
|
||||
return
|
||||
}
|
||||
logFile.writeSync(Encoding.UTF8.getBytes(`${getTimeString()} ${data.uname} 投喂了${data.super_gift_num}个 ${data.giftName} 价值${data.price / 1000 * data.super_gift_num}元\n`))
|
||||
sendDanmaku({
|
||||
msg: FormatString(config.danmakus.gift, { name: data.uname, gift: data.giftName })
|
||||
})
|
||||
thanksColdDownSet.add(data.uname)
|
||||
setTimeout(() => {thanksColdDownSet.delete(data.uname)}, config.cold_down_time)
|
||||
if (config.free_gift_action || data.super_gift_num > 0) {
|
||||
sendDanmaku({
|
||||
msg: FormatString(config.danmakus.gift, { name: data.uname, gift: data.giftName })
|
||||
})
|
||||
thanksColdDownSet.add(data.uname)
|
||||
setTimeout(() => { thanksColdDownSet.delete(data.uname) }, config.cold_down_time)
|
||||
}
|
||||
}
|
||||
|
||||
export function onTotalGift(data: any) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { brotli, EventEmitter } from "./Deps.ts";
|
||||
import { brotli, EventEmitter, WebSocketClient } from "./Deps.ts";
|
||||
import config from "./Config.ts";
|
||||
import { printLog } from "./utils/mod.ts";
|
||||
import { server as apiServer } from './APIServer.ts'
|
||||
@ -125,7 +125,7 @@ export class DanmakuReceiver extends EventEmitter {
|
||||
const data = JSON.parse(decoder.decode(packetData));
|
||||
const cmd = data.cmd.split(":")[0];
|
||||
this.emit(cmd, data.info || data.data);
|
||||
apiServer.clients.forEach((client) => {
|
||||
apiServer.clients.forEach((client: WebSocketClient) => {
|
||||
client.send(JSON.stringify({ cmd, data: data.info || data.data }))
|
||||
})
|
||||
offset += length;
|
||||
|
@ -3,5 +3,4 @@ import * as events from 'https://deno.land/x/events@v1.0.0/mod.ts'
|
||||
const EventEmitter = events.default
|
||||
export { EventEmitter }
|
||||
export * as brotli from 'https://deno.land/x/brotli@v0.1.4/mod.ts'
|
||||
export { WebSocketServer } from "https://deno.land/x/websocket@v0.1.4/mod.ts";
|
||||
export type { WebSocketClient } from "https://deno.land/x/websocket@v0.1.4/mod.ts";
|
||||
export { WebSocketServer, type WebSocketClient } from 'https://deno.land/x/websocket@v0.1.4/mod.ts';
|
||||
|
Loading…
x
Reference in New Issue
Block a user