聊天:精简群推工具方法
This commit is contained in:
@@ -17,7 +17,7 @@ import { updateWarStar, checkBattleHeroes, roleLevelup } from '../../../services
|
||||
import { checkDungeonNum, checkDungeonAndIncrease } from '../../../services/dungeonService';
|
||||
import { switchOnFunc } from '../../../services/funcSwitchService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { pushMysteryFirstMsg, pushTowerMsg, pushVestigeFirstMsg, shouldPushTowerMsg } from '../../../services/chatService';
|
||||
import { pushMysteryFirstMsg, pushTowerMsg, pushVestigeFirstMsg } from '../../../services/chatService';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new NormalBattleHandler(app);
|
||||
|
||||
@@ -84,8 +84,8 @@ export class ChatHandler {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const msgData = await createGroupMsg(roleId, roleName, channel, channelId, type, MSG_SOURCE.ROLE_SEND_TEXT, content, targetRoleId, targetMsgCode);
|
||||
await pushGroupMsgToRoom(groupRoomId(channel, channelId), msgData);
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,9 @@ export async function createGroupMsg(roleId: string, roleName: string, channel:
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function pushGroupMsgToRoom(roomId: string, msg: GroupMessageType) {
|
||||
export async function pushGroupMsgToRoom(msg: GroupMessageType) {
|
||||
if (!msg) return;
|
||||
const roomId = msg.roomId!;
|
||||
const channelSid = await channelServer(roomId);
|
||||
await pinus.app.rpc.chat.chatRemote.sendGroupMsg.toServer(channelSid, roomId, msg);
|
||||
}
|
||||
@@ -230,8 +232,7 @@ async function pushNormalHeroInfoBySource(roleId: string, roleName: string, serv
|
||||
const hero = pick(heroInfo, ['hName', 'hid', 'seqId', 'quality', 'star', 'starStage', 'colorStar', 'colorStarStage']);
|
||||
const content = JSON.stringify({ roleId, roleName, hero });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||
const roomId = groupRoomId(CHANNEL_PREFIX.SYS, serverId);
|
||||
await pushGroupMsgToRoom(roomId, msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
}
|
||||
|
||||
export async function pushHeroQualityUpMsg(roleId: string, roleName: string, serverId: number | string, heroInfo: Partial<HeroType>) {
|
||||
@@ -258,8 +259,7 @@ export async function pushGuildNoticeUpdateMsg(roleId: string, roleName: string,
|
||||
const { code, notice } = guildInfo;
|
||||
if (!code || !isString(notice)) return null;
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, code, MSG_TYPE.TEXT, MSG_SOURCE.GUILD_NOTICE, notice, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, code), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
@@ -269,8 +269,7 @@ export async function pushGuildUpStructureMsg(roleId: string, roleName: string,
|
||||
const guild = pick(guildInfo, ['code', 'structure']);
|
||||
const content = JSON.stringify({ roleId, roleName, guild });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, code, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_STRUCTURE_LV_UP, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, code), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
@@ -278,8 +277,7 @@ export async function pushGuildTrainSucMsg(roleId: string, roleName: string, gui
|
||||
if (!guildCode) return null;
|
||||
const content = JSON.stringify({ hid });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_TRAIN_SUC, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
@@ -287,8 +285,7 @@ export async function pushGuildBossSucMsg(roleId: string, roleName: string, guil
|
||||
const boss = pick(bossInstance, ['warId', 'bossLv']);
|
||||
const content = JSON.stringify({ boss });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GUILD, guildCode, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GUILD_BOSS_SUC, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
@@ -296,32 +293,14 @@ export async function pushEquipRefineSucMsg(roleId: string, roleName: string, se
|
||||
const data = pick(eplace, ['id', 'lv', 'refineLv']);
|
||||
const content = JSON.stringify({ eplace: data });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_REFINE_SUC, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
export async function pushNormalEquipMsg(roleId: string, roleName: string, serverId: number, source: number, id: number, name: string) {
|
||||
const content = JSON.stringify({ id, name });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
export async function pushEquipComposeSuitMsg(roleId: string, roleName: string, serverId: number, id: number, name: string) {
|
||||
const content = JSON.stringify({ id, name });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_COMPOSE_SUIT, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
export async function pushEquipComposeOrangeMsg(roleId: string, roleName: string, serverId: number, id: number, name: string) {
|
||||
const content = JSON.stringify({ id, name });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_COMPOSE_SUIT, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
@@ -329,16 +308,14 @@ export async function pushTowerMsg(roleId: string, roleName: string, serverId: n
|
||||
if (!shouldPushTowerMsg(lv)) return null;
|
||||
const content = JSON.stringify({ lv });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
async function pushGKFirstMsg(roleId: string, roleName: string, serverId: number, source: number, warType: number, warId: number) {
|
||||
const content = JSON.stringify({ warType, warId });
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, source, content, null, null);
|
||||
if (!msgData) return null;
|
||||
await pushGroupMsgToRoom(groupRoomId(CHANNEL_PREFIX.SYS, serverId), msgData);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
return msgData;
|
||||
}
|
||||
|
||||
@@ -408,7 +385,7 @@ export async function recentGuildMsgs(guildCode: string, count?: number) {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function shouldPushTowerMsg(lv: number) {
|
||||
function shouldPushTowerMsg(lv: number) {
|
||||
// 100 层之后每 50 层触发
|
||||
return lv >= 100 && lv % 50 === 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user