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