✨ feat(gvg): 添加城池排行榜定时推送
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
import { addGVGHistoryAreas, addGVGHistoryAreaTeam, addRedisChannel, getGVGHistoryAreas, getGVGHistoryAreaTeam, redisChannelServer } from './redisService';
|
||||
import { addGVGHistoryAreas, addGVGHistoryAreaTeam, addGVGHistoryCityTeam, addRedisChannel, delGVGHistoryAreas, delGVGHistoryAreaTeam, delGVGHistoryCityTeam, getGVGHistoryAreas, getGVGHistoryAreaTeam, getGVGHistoryCityTeam, redisChannelServer } from './redisService';
|
||||
import { groupRoomId } from './chatService';
|
||||
import { pinus } from 'pinus';
|
||||
import { crc32 } from 'crc';
|
||||
@@ -75,6 +75,11 @@ export async function addRoleToAreaTeamChannel(roleId: string, groupId: number,
|
||||
await addGVGHistoryAreaTeam(roleId, groupId, serverType, areaId);
|
||||
}
|
||||
|
||||
export async function addRoleToGVGCityChannel(roleId: string, groupId: number, serverType: number, cityId: number, sid: string) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_CITY, `${groupId}_${serverType}_${cityId}`);
|
||||
await addRoleToChannel(roomId, roleId, sid);
|
||||
await addGVGHistoryCityTeam(roleId, groupId, serverType, cityId);
|
||||
}
|
||||
async function leaveChannel(roomId: string, roleId: string, sid: string) {
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.leaveChannel.toServer(channelSid, roomId, roleId, sid);
|
||||
@@ -122,6 +127,7 @@ export async function leaveGVGAreaChannel(roleId: string, sid: string) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREAS, key);
|
||||
await leaveChannel(roomId, roleId, sid);
|
||||
}
|
||||
await delGVGHistoryAreas(roleId);
|
||||
}
|
||||
|
||||
export async function leaveGVGAreaTeamChannel(roleId: string, sid: string) {
|
||||
@@ -130,6 +136,16 @@ export async function leaveGVGAreaTeamChannel(roleId: string, sid: string) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_AREA_BY_TEAM, channelName);
|
||||
await leaveChannel(roomId, roleId, sid);
|
||||
}
|
||||
await delGVGHistoryAreaTeam(roleId);
|
||||
}
|
||||
|
||||
export async function leaveGVGCityTeamChannel(roleId: string, sid: string) {
|
||||
let channelName = await getGVGHistoryCityTeam(roleId);
|
||||
if(channelName) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_CITY, channelName);
|
||||
await leaveChannel(roomId, roleId, sid);
|
||||
}
|
||||
await delGVGHistoryCityTeam(roleId);
|
||||
}
|
||||
|
||||
export async function getWorldChannelSid(serverId: number) {
|
||||
@@ -180,6 +196,12 @@ export async function getGVGAreaTeamChannelSid(groupId: number, serverType: numb
|
||||
return channelSid;
|
||||
}
|
||||
|
||||
export async function getGVGCityTeamChannelSid(groupId: number, serverType: number, cityId: number) {
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.GVG_CITY, `${groupId}_${serverType}_${cityId}`);
|
||||
const channelSid = await channelServer(roomId);
|
||||
return channelSid;
|
||||
}
|
||||
|
||||
async function delChannel(roomId: string) {
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.deleteChannel.toServer(channelSid, roomId);
|
||||
|
||||
Reference in New Issue
Block a user