private void button8_Click(object sender, EventArgs e) { foreach (KeyValuePair <string, GGUserInfo> item in OnlineUserUtils.GetAllOnlineClients()) { string index = cmbUserList.SelectedText; GGUserInfo GGUserInfo = OnlineUserUtils.GetSingleOnlineClient(index); GGUserInfo user = item.Value; if (user.userId == GGUserInfo.userId) { toInfo.msgType = MsgType.开启禁言; toInfo.content = GGUserInfo.userNickName + "已被禁言"; //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //发送给其他客户端 toInfo.content = "系统:你已被禁言"; SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), toInfo); this.RefreshCanSpeak(); break; } } }
public static void Testcontains(User user, string itemstr, string ingredientstr) { Item item = Item.Get(itemstr); Item ingredient = Item.Get(ingredientstr); if (item != null && ingredient != null) { if (item.HasIngredient(ingredient.Type)) { ChatUtils.SendMessage(user, item.DisplayName + " contains " + ingredient.DisplayName); } else { ChatUtils.SendMessage(user, item.DisplayName + " does not contain " + ingredient.DisplayName); } } else { ChatUtils.SendMessage(user, "ERROR"); } }
private void UpdateLastMessage() { if (this.m_chatLogFrame != null) { this.HideLastMessage(); } else { BnetWhisper whisper = this.FindLastWhisperFromReceiver(); if (whisper == null) { this.HideLastMessage(); } else { this.m_LastMessageText.gameObject.SetActive(true); this.m_LastMessageText.Text = ChatUtils.GetMessage(whisper); TransformUtil.SetPoint((Component)this.m_LastMessageText, Anchor.BOTTOM_LEFT, (Component)this.m_Bones.m_LastMessage, Anchor.TOP_LEFT); this.m_ReceiverNameText.gameObject.SetActive(true); if (this.m_receiver.IsOnline()) { this.m_ReceiverNameText.TextColor = GameColors.PLAYER_NAME_ONLINE; } else { this.m_ReceiverNameText.TextColor = GameColors.PLAYER_NAME_OFFLINE; } this.m_ReceiverNameText.Text = FriendUtils.GetUniqueName(this.m_receiver); TransformUtil.SetPoint((Component)this.m_ReceiverNameText, Anchor.BOTTOM_LEFT, (Component)this.m_LastMessageText, Anchor.TOP_LEFT); this.m_LastMessageShadow.SetActive(true); Bounds textWorldSpaceBounds = this.m_LastMessageText.GetTextWorldSpaceBounds(); Bounds bounds2 = this.m_ReceiverNameText.GetTextWorldSpaceBounds(); float num = Mathf.Max(textWorldSpaceBounds.max.y, bounds2.max.y); float num2 = Mathf.Min(textWorldSpaceBounds.min.y, bounds2.min.y); float num3 = num - num2; float z = (num3 * this.m_initialLastMessageShadowScaleZ) / this.m_initialLastMessageTextHeight; TransformUtil.SetLocalScaleZ(this.m_LastMessageShadow, z); } } }
public void OnEvent(ShPlayer player, string message) { if (message.StartsWith(CommandHandler.Prefix)) { return; } Core.Instance.Logger.LogInfo($"[GLOBAL] {player.username}: {message}"); switch (player.GetExtendedPlayer().CurrentChat) { case Chat.StaffChat: ChatUtils.SendStaffChatMessage(player, message); return; case Chat.Disabled: player.TS("chat_disabled"); return; default: ChatUtils.SendToAllEnabledChat(ChatUtils.FormatMessage(player, message), false); return; } }
public void Invoke(ShPlayer player, string target, string reason) { if (EntityCollections.TryGetPlayerByNameOrID(target, out var shTarget)) { shTarget.AddWarn(player, reason); ChatUtils.SendToAllEnabledChatT("all_warned", player.username.CleanerMessage(), shTarget.username.CleanerMessage(), reason.CleanerMessage()); player.TS("player_warn", shTarget.username.CleanerMessage(), reason.CleanerMessage()); shTarget.TS("target_warn", shTarget.username.CleanerMessage(), reason.CleanerMessage()); return; } if (Core.Instance.SvManager.TryGetUserData(target, out var user)) { user.AddWarn(player, reason); ChatUtils.SendToAllEnabledChatT("all_warned", player.username.CleanerMessage(), target.CleanerMessage(), reason.CleanerMessage()); player.TS("player_warn", target.CleanerMessage(), reason.CleanerMessage()); Core.Instance.SvManager.database.Users.Upsert(user); return; } player.TS("user_not_found", target.CleanerMessage()); }
JSONValue JSONValuable.ToJSON() { var json = new JSONObject() { ["user"] = User, ["name"] = Name, ["id"] = ChatUtils.GetSummonerId(User) }; if (IsOnline) { json["show"] = Status.Show; json["message"] = Status.Message; if (Status.GameStatus != null) { json["status"] = new JSONObject { ["display"] = Status.GameStatus.Display, ["id"] = Status.GameStatus.Key } } ; } if (IsMobile && Status.LastOnline.HasValue) { json["lastonline"] = Status.LastOnline.Value; } if (IsInGame) { json["game"] = new JSONObject { ["start"] = CurrentGame?.gameStartTime ?? Status.TimeStamp, ["exact"] = CurrentGame != null, ["type"] = CurrentGame?.gameQueueConfigId ?? -1 }; } return(json); }
private void button13_Click(object sender, EventArgs e) { try { string path = textBox2.Text; if (string.IsNullOrEmpty(path)) { return; } string fileContent = File.ReadAllText(path, Encoding.Default); string fileName = Path.GetFileName(path); toInfo.fileType = FileUtils.GetFileExtendName(Path.GetExtension(fileName)); toInfo.msgType = MsgType.群发文件; toInfo.content = "系统给所有人发送了文件 [ " + fileName + " ] "; if (toInfo.fileType == 0) { MessageBox.Show(fileName + "的文件类型为:" + Path.GetExtension(fileName) + ",该文件类型不允许发送"); return; } using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { byte[] buffer = new byte[1024 * 1024 * 5]; int fileLength = fs.Read(buffer, 0, buffer.Length); toInfo.buffer = buffer; toInfo.fileLength = fileLength; } //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //发送给其他客户端 SocketUtils.SendFileToMutilClient(OnlineUserUtils.GetAllOnlineClients(), toInfo); } catch (Exception ex) { MessageBox.Show("群发文件" + ex.Message); } }
public ChatMessage CreateEnchantSystemMessage(string systemMessage) { return(_dispatcher.InvokeAsync(() => { var msg = CreateMessage(ChatChannel.Enchant); var e = ""; if (systemMessage.Contains("enchantCount:")) { var s = systemMessage.IndexOf("enchantCount:", StringComparison.InvariantCultureIgnoreCase); var ench = systemMessage.Substring(s + "enchantCount:".Length, 1); e = $"+{ench} "; } var prm = ChatUtils.SplitDirectives(systemMessage); if (prm == null) { return msg; } msg.Author = prm["UserName"]; var txt = "{ItemName}"; txt = ChatUtils.ReplaceParameters(txt, prm, true); txt = txt.Replace("{", ""); txt = txt.Replace("}", ""); var mp = MessagePieceBuilder.BuildSysMsgItem(txt); var sb = new StringBuilder(); sb.Append("<"); sb.Append(e); sb.Append(mp.Text.Substring(1)); mp.Text = sb.ToString(); msg.AddPiece(new SimpleMessagePiece("Successfully enchanted ", App.Settings.FontSize, false, "cccccc")); msg.AddPiece(mp); return msg; }).Result); }
public static void SetMaxSuperSkills(User user, int maxallowed = int.MinValue) { if (maxallowed == -1) { maxallowed = int.MaxValue; } string currentallowedstr = (REYmodSettings.Obj.Config.Maxsuperskills != int.MaxValue) ? REYmodSettings.Obj.Config.Maxsuperskills.ToString() : "Infinite"; if (maxallowed == int.MinValue || maxallowed == REYmodSettings.Obj.Config.Maxsuperskills) { ChatUtils.SendMessage(user, "Max allowed Superskills: " + currentallowedstr); return; } else { string newallowedstr = (maxallowed != int.MaxValue) ? maxallowed.ToString() : "Infinite"; REYmodSettings.Obj.Config.Maxsuperskills = maxallowed; REYmodSettings.Obj.SaveConfig(); ChatUtils.SendMessage(user, "Changed the amount of allowed Superskills from " + currentallowedstr + " to " + newallowedstr); ChatUtils.SendMessageToAll(user.UILink() + "changed the amount of allowed Superskills from " + currentallowedstr + " to " + newallowedstr); // ConfigHandler.UpdateConfigFile(); } }
public static void Tp(User user, string username = "") { if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only { ChatUtils.SendMessage(user, "Not Authorized to use this command!"); return; } User usertoteleport = UserManager.FindUserByName(username); if (usertoteleport == null) { usertoteleport = user; } string panelcontent = "Select Player: <br><br>"; foreach (User onlineuser in UserManager.OnlineUsers) { panelcontent += new Button(player => { usertoteleport.Player.SetPosition(onlineuser.Player.Position); IOUtils.WriteCommandLog(user, "Tp", usertoteleport.Name + " -> " + onlineuser.Name); }, text: onlineuser.Name, singleuse: true, clickdesc: "Click to teleport " + usertoteleport.Name + " to " + onlineuser.Name).UILink(); panelcontent += "<br>"; } user.Player.OpenInfoPanel("Teleporting " + usertoteleport.Name, panelcontent); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { DialogResult dr = MessageBox.Show("是否退出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { foreach (KeyValuePair <string, GGUserInfo> item in OnlineUserUtils.GetAllOnlineClients()) { toInfo.msgType = MsgType.关闭服务器; toInfo.content = "服务器已关闭 "; //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //发送个所有客户端 SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), toInfo); } this.notifyIcon1.Visible = false; this.notifyIcon1.Dispose(); Application.Exit(); } else { e.Cancel = true; } string file = Application.StartupPath + @"\FrmClient.exe"; foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses()) { string name = p.ProcessName; if (name == (this.GetType().Namespace)) { p.Kill(); } } }
public void Operation() { _containerInterfaces.SystemOutput.Print("All chats group chats"); List <ChatMessageModel> allChats = _serverHandler.GetAllChatGroupModels(); _containerInterfaces.SystemOutput.Print(ChatUtils.GetChatsResponse(allChats)); _containerInterfaces.SystemOutput.Print("Please enter the group name you want to remove to | CLICK --stop for stop type OR exit for exit option-- EXIT"); string groupName = _containerInterfaces.SystemInput.StringInput(); while (groupName != "stop") { if (groupName == "exit") { return; } if (allChats.Any(c => c.GroupName == groupName)) { break; } _containerInterfaces.SystemOutput.Print("Please enter the group name you want to add to | CLICK --stop for stop type OR exit for exit option-- EXIT"); groupName = _containerInterfaces.SystemInput.StringInput(); } var body = new GroupChatMessageModel { RequestType = MessageType.ExitChat, lsUsers = new List <string>() { _clientname }, GroupName = groupName }; _serverHandler.UpdateChat(body); }
private void OnPlayerChangeExp(S_PLAYER_CHANGE_EXP m) { if (Game.Me.Level == 70) { return; } var msg = ChatUtils.Font("You gained ") + ChatUtils.Font($"{m.GainedTotalExp - m.GainedRestedExp:N0}", Colors.GoldColor.ToHex()); if (m.GainedRestedExp > 0) { msg += ChatUtils.Font(" + ") + ChatUtils.Font($"{m.GainedRestedExp:N0}", Colors.ChatMegaphoneColor.ToHex()); } msg += ChatUtils.Font($" ("); msg += ChatUtils.Font($"{m.GainedTotalExp / (double)m.NextLevelExp:P3}", Colors.GoldColor.ToHex()); msg += ChatUtils.Font($") XP. Total: "); msg += ChatUtils.Font($"{m.LevelExp / (double)m.NextLevelExp:P3}", Colors.GoldColor.ToHex()); msg += ChatUtils.Font($"."); AddChatMessage(Factory.CreateMessage(ChatChannel.Exp, "System", msg)); }
private void button12_Click(object sender, EventArgs e) { string index = cmbUserList.SelectedText; if (string.IsNullOrEmpty(index)) { MessageBox.Show("请选择用户"); return; } string path = textBox2.Text; string extendName = Path.GetExtension(path); FileType fileType = FileUtils.GetFileExtendName(extendName); using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { foreach (KeyValuePair <string, GGUserInfo> item in OnlineUserUtils.GetAllOnlineClients()) { byte[] buffer = new byte[1024 * 1024 * 5]; int fileLength = fs.Read(buffer, 0, buffer.Length); GGUserInfo user = OnlineUserUtils.GetSingleOnlineClient(index); toInfo.msgType = MsgType.私发文件; toInfo.content = "系统给" + GGUserUtils.ShowNickAndId(user) + "发送了文件"; toInfo.fileType = fileType; toInfo.buffer = buffer; toInfo.fileLength = fileLength; toInfo.toId = user.userId; toInfo.toUser = user; //显示到服务器端 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //发送给其他客户端 SocketUtils.SendFileToSingleClient(toInfo); //ToolUtils.ServerSendMsgToClients(GGUserInfo.UserSocket1, Convert.ToByte(MsgType.私发文件), "", Convert.ToByte(fileType), buffer, fileLength); } } }
public static void SpawnNPC(ushort zoneId, uint templateId, ulong entityId, bool v, bool villager, int remainingEnrageTime) { #pragma warning disable CS8602 // Dereferenziamento di un possibile riferimento Null. if (Game.DB.MonsterDatabase.TryGetMonster(templateId, zoneId, out var m)) #pragma warning restore CS8602 // Dereferenziamento di un possibile riferimento Null. { if (TccUtils.IsWorldBoss(zoneId, templateId)) { if (m.IsBoss) { var msg = ChatManager.Instance.Factory.CreateMessage(ChatChannel.WorldBoss, "System", $"{ChatUtils.Font(m.Name)}{ChatUtils.Font(" is nearby.", "cccccc", 15)}"); ChatManager.Instance.AddChatMessage(msg); } } Game.NearbyNPC[entityId] = m.Name; FlyingGuardianDataProvider.InvokeProgressChanged(); if (villager) { return; } if (m.IsBoss) { WindowManager.ViewModels.NpcVM.AddOrUpdateNpc(entityId, m.MaxHP, m.MaxHP, m.IsBoss, HpChangeSource.CreatureChangeHp, templateId, zoneId, v, remainingEnrageTime); } else { if (App.Settings.NpcWindowSettings.HideAdds) { return; } WindowManager.ViewModels.NpcVM.AddOrUpdateNpc(entityId, m.MaxHP, m.MaxHP, m.IsBoss, HpChangeSource.CreatureChangeHp, templateId, zoneId, false, remainingEnrageTime); } } }
public static void LeaderPassLaw(User user) { if (user != Legislation.Government.LeaderUser)//leader only { ChatUtils.SendMessage(user, "Not Authorized to use this command!"); return; } string panelcontent = "Click on the law you want to pass: <br><br>"; if (Legislation.Laws.AllNonFailedLaws.Where(x => !x.InEffect).Count() != 0) { Legislation.Laws.AllNonFailedLaws.Where(x => !x.InEffect).ToList().ForEach(x => { panelcontent += new Button(player => { MiscUtils.SoftPassLaw(x, user); }, tooltip: x.Tooltip(), text: x.Title, singleuse: true, clickdesc: "Click to try to enact this law").UILink(); panelcontent += "<br>"; }); } else { panelcontent = "No pending laws!"; } user.Player.OpenInfoPanel("Passlaw Menu", panelcontent); }
public void Run() { _requests.SendStringMessage(_client, ClientOptions.GLOBAL_CHAT.ToString()); try { Thread thread = new Thread(GetMessage); thread.Start(); while (!endConnection) { _system.Write("enter message, if you wand to exist global chat enter: 0"); message = _system.ReadString(); if (message == "0") { endConnection = true; _requests.SendStringMessage(_client, message); break; } else { if (!ChatUtils.SendMessageByType(_requests, _client, message)) { endConnection = true; } } } } catch (Exception e) { } endConnection = false; }
private void GetMessage() { ChatUtils.GetMessage(_requests, _system, _client); }
public static void SetTitle(User user, User target, string title) { target.SetState("CustomTitle", title); ChatUtils.SendMessage(user, "Set " + target.Name + "'s title to: \"" + title + "\""); }
private static void Timer_Elapsed(object sender, ElapsedEventArgs e, User user) { ChatUtils.SendMessage(user, "Timer elapsed!"); (sender as Timer).Dispose(); }
public static async void UnclaimPlayerAsync(User user, User owner = null) { bool inactive = true; bool confirmed = false; double inactivetime; if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only { ChatUtils.SendMessage(user, "Not Authorized to use this command!"); return; } if (owner == null) { if (PropertyManager.GetPlot(user.Position.XZi) != null) { owner = PropertyManager.GetPlot(user.Position.XZi).Owner; } } if (owner == null) { user.Player.SendTemporaryMessageAlreadyLocalized("Plot not owned"); return; } inactivetime = (WorldTime.Seconds - owner.LogoutTime); if (inactivetime < REYmodSettings.Obj.Config.Maxinactivetime * 3600) { inactive = false; } if (owner.LoggedIn) { inactivetime = 0; } IEnumerable <Deed> allDeeds = PropertyManager.GetAllDeeds(); IEnumerable <Deed> targetDeeds = allDeeds.Where(x => x.OwnerUser == owner); int ownedplots = PropertyManager.PropertyForUser(owner).Count(); int ownedvehicles = targetDeeds.Sum(x => x.OwnedObjects.Count) - ownedplots; string textbox = ""; textbox += "You are going to unclaim all property of " + owner.UILink() + "<br>"; textbox += "Owned Plots: " + ownedplots + "<br>"; textbox += "Owned Vehicles: " + ownedvehicles + "<br>"; textbox += "<br>Player offline for " + TimeFormatter.FormatSpan(inactivetime); if (!inactive) { textbox += "<br>WARNING! Player not inactive!".Color("red"); } textbox += "<br><br>"; if (!inactive && !user.IsAdmin) { textbox += "<b><color=red>You can't unclaim this player! Not inactive for long enough.</color></b>"; user.Player.PopupOKBoxLoc(Localizer.DoStr(textbox)); return; } else { // textbox += new Button(x => { MiscUtils.UnclaimUser(owner, user); IOUtils.WriteCommandLog(user, "UnclaimUser", "Unclaimed " + owner.Name + " (" + ownedplots + " plots/" + ownedvehicles + " vehicles)" + "Inactive for " + TimeFormatter.FormatSpan(inactivetime)); }, "", "Click here to unclaim all property of " + owner.UILink(), "Confirm Unclaiming".Color("green")).UILink(); FormattableString textboxformattable = FormattableStringFactory.Create(textbox); confirmed = await user.Player.PopupConfirmBoxLoc(textboxformattable); } if (confirmed) { MiscUtils.UnclaimUser(owner, user); IOUtils.WriteCommandLog(user, "UnclaimUser", "Unclaimed " + owner.Name + " (" + ownedplots + " plots/" + ownedvehicles + " vehicles)" + "Inactive for " + TimeFormatter.FormatSpan(inactivetime)); } //user.Player.OpenInfoPanel("Unclaim Player", textbox); }
private void SendMessagesHistory() { ChatUtils.SendMessagesHistory(_data.ClientsInGlobalChat.MessagesHistory, _client, _requests); }
/// <summary> /// 服务器获取客户端发来的信息 /// </summary> public void GetClientMsg() { while (true) { try { if (!this.currentUser.socket.Connected) { toInfo.msgType = MsgType.系统消息; //信息显示到服务器 toInfo.content = GGUserUtils.ShowNickAndId(this.currentUser) + " 客户端失去连接"; ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); SoundUtils.playSound(toInfo.content, EndPointEnum.务器); break; } string json = ToolUtils.GetString(this.currentUser.socket); MessageInfo fromInfo = SerializerUtil.JsonToObject <MessageInfo>(json); if (fromInfo == null) { //信息显示到服务器 MessageInfo tmpInfo = new MessageInfo(); tmpInfo.msgType = MsgType.异常报告; tmpInfo.content = GGUserUtils.ShowNickAndId(this.currentUser) + " 未获取到信息"; ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, tmpInfo); SoundUtils.playSound(toInfo.content, EndPointEnum.务器); break; } toInfo = new MessageInfo() { msgType = fromInfo.msgType, socket = this.currentUser.socket, content = fromInfo.content, fromId = fromInfo.fromId, toId = fromInfo.toId, fromUser = fromInfo.fromUser, toUser = fromInfo.toUser, dateTime = DateTime.Now }; if (!string.IsNullOrEmpty(fromInfo.toId) && OnlineUserUtils.CheckClientIsOnline(fromInfo.toId) && true) { toInfo.socket = OnlineUserUtils.GetSingleOnlineClient(fromInfo.toId).socket; } if (fromInfo.msgType == MsgType.移动好友) { int oldGroupAutoId = Convert.ToInt32(fromInfo.oldGroupAutoId); int newGroupAutoId = Convert.ToInt32(fromInfo.newGroupAutoId); int friendAutoId = Convert.ToInt32(fromInfo.toId); GGGroup oldGroupInfo = ChatDBUtils.GetSingeGroupByAutoId(oldGroupAutoId); GGGroup newGroupInfo = ChatDBUtils.GetSingeGroupByAutoId(newGroupAutoId); GGUserInfo userInfo = ChatDBUtils.GetPerInfoByAutoId(friendAutoId); ChatDBUtils.MoveGroup(oldGroupAutoId, newGroupAutoId, friendAutoId); toInfo.content = "成功将好友" + GGUserUtils.ShowNickAndId(userInfo) + "从[ " + oldGroupInfo.groupName + " ] 移动到 [ " + newGroupInfo.groupName + " ]"; SocketUtils.SendToSingleClient(toInfo); } else if (fromInfo.msgType == MsgType.私发红包) { if (OnlineUserUtils.CheckClientIsOnline(fromInfo.toId)) { SocketUtils.SendToSingleClient(toInfo); } toInfo.content = GGUserUtils.ShowNickAndId(fromInfo.fromUser) + "给" + GGUserUtils.ShowNickAndId(fromInfo.toUser) + "发了" + fromInfo.content + "元的红包"; } else if (fromInfo.msgType == MsgType.私聊) { if (OnlineUserUtils.CheckClientIsOnline(fromInfo.toId)) { //信息转发给指定客户端 SocketUtils.SendToSingleClient(toInfo); //添加聊天记录 ChatDBUtils.AddRecords(fromInfo); } else { //添加离线信息到数据库 ChatDBUtils.AddOfflineMsgToClient(fromInfo); } } else if (fromInfo.msgType == MsgType.用户注册) { GGUserInfo user = SerializerUtil.JsonToObject <GGUserInfo>(json); bool isSuc = ChatDBUtils.RegisterUser(user); if (isSuc) { toInfo.content = GGUserUtils.ShowNickAndId(user) + "注册成功"; } else { toInfo.content = GGUserUtils.ShowNickAndId(user) + "注册失败"; } SocketUtils.SendToSingleClient(toInfo); } else if (fromInfo.msgType == MsgType.创建分组) { GGGroup tmpGroup = ChatDBUtils.GetGroupByName(fromInfo.content); if (tmpGroup != null) { toInfo.content = "分组[" + fromInfo.content + "]已存在,请重新命名"; SocketUtils.SendToSingleClient(toInfo); } else { ChatDBUtils.CreateGroup(fromInfo.fromUser, fromInfo.content); toInfo.content = "分组[" + fromInfo.content + "]创建成功"; SocketUtils.SendToSingleClient(toInfo); } } else if (fromInfo.msgType == MsgType.除分组) { string groupAutoId = fromInfo.content; ChatDBUtils.DelGroup(groupAutoId); toInfo.content = "分组[" + fromInfo.content + "]删除成功"; SocketUtils.SendToSingleClient(toInfo); } else if (fromInfo.msgType == MsgType.修改分组) { string[] arr = fromInfo.content.Split('|'); string groupAutoId = arr[0]; string groupName = arr[1]; ChatDBUtils.UpdateGroup(groupAutoId, groupName); toInfo.content = "分组[" + fromInfo.content + "]修改为[" + groupName + "]"; SocketUtils.SendToSingleClient(toInfo); } else if (fromInfo.msgType == MsgType.除好友) { string friendAutoId = fromInfo.toId; int groupAutoId = Convert.ToInt32(fromInfo.content); GGGroup defaultGroup = ChatDBUtils.GetSingeGroupByAutoId(groupAutoId); bool isSuc = ChatDBUtils.DelFriend(defaultGroup, friendAutoId); //信息转发给指定客户端 toInfo.content = "成功删除好友" + GGUserUtils.ShowNickAndId(fromInfo.toUser); SocketUtils.SendToSingleClient(toInfo); } else if (fromInfo.msgType == MsgType.添加好友) { //检查默认分组 CheckDefaultGroup(fromInfo); GGUserInfo user = ChatDBUtils.GetPerInfoByUserId(fromInfo.toId); GGGroup defaultGroup = ChatDBUtils.GetDefaultGroup(fromInfo.fromId); bool isSuc = ChatDBUtils.AddFriend(defaultGroup, user.userAutoid); //信息转发给指定客户端 toInfo.content = "成功添加" + GGUserUtils.ShowNickAndId(fromInfo.toUser) + "为好友"; SocketUtils.SendToSingleClient(toInfo); } else if (fromInfo.msgType == MsgType.获取好友信息) { List <GGGroup> groupList = ChatDBUtils.GetGroupFriendsInfo(fromInfo.fromId); toInfo.content = SerializerUtil.ObjectToJson <List <GGGroup> >(groupList); //将好友信息发送给制定客户端,刷新好友在线情况 SocketUtils.SendToSingleClient(toInfo); toInfo.content = GGUserUtils.ShowNickAndId(fromInfo.fromUser) + "的好友情况如下:" + ChatDBUtils.GetPerOnlineGroupFriendsStr(fromInfo.fromId); } else if (fromInfo.msgType == MsgType.群发抖动) { //信息分发给其他客户端 SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), fromInfo); } else if (fromInfo.msgType == MsgType.私发抖动) { toInfo.fromUser = OnlineUserUtils.GetSingleOnlineClient(fromInfo.fromId); if (OnlineUserUtils.CheckClientIsOnline(fromInfo.toId)) { toInfo.toUser = OnlineUserUtils.GetSingleOnlineClient(fromInfo.toId); toInfo.content = GGUserUtils.ShowNickAndId(toInfo.fromUser) + " 给你发了一个抖动"; toInfo.socket = toInfo.toUser.socket; SocketUtils.SendToSingleClient(toInfo); } toInfo.content = GGUserUtils.ShowNickAndId(fromInfo.fromUser) + " 给" + GGUserUtils.ShowNickAndId(fromInfo.toUser) + "发了一个抖动"; } else if (fromInfo.msgType == MsgType.退出聊天室) { SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), toInfo); } else if (fromInfo.msgType == MsgType.群发红包) { //信息分发给其他客户端 SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), toInfo); } else if (fromInfo.msgType == MsgType.线) { string userId = fromInfo.fromId; GGUserInfo user = OnlineUserUtils.GetSingleOnlineClient(userId); toInfo.content = GGUserUtils.ShowNickAndId(user) + " 下线了"; //user.socket.Close(); //下线客户端 OnlineUserUtils.RemoveOnlineClient(userId); } else if (fromInfo.msgType == MsgType.线) { //信息分发给其他客户端 SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), toInfo); } else if (fromInfo.msgType == MsgType.群聊) { //信息分发给其他客户端 SocketUtils.SendToMultiClients(OnlineUserUtils.GetAllOnlineClients(), toInfo); } else { toInfo.content = "未知信息:[ " + fromInfo.msgType + " ] " + fromInfo.content; } //信息显示到服务器 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); } catch (Exception ex) { MessageInfo toInfo = new MessageInfo(); toInfo.msgType = MsgType.异常报告; toInfo.content = GGUserUtils.ShowNickAndId(currentUser) + "被强制下线,服务器读取信息时异常:" + ex.Message; //信息显示到服务器 ChatUtils.AppendMsgToServerChatList(this.serverChatRecords, toInfo); //关闭连接并下线客户端 //userInfo.UserSocket1.Close(); OnlineUserUtils.RemoveOnlineClient(currentUser.userId); //currentUser.socket.Close(); SoundUtils.playSound(toInfo.msgType + toInfo.content, EndPointEnum.务器); } } }
/// <summary> /// Расчитывает стоимость инциндента, и изымает её. /// </summary> /// <param name="command">Текстовая команда для чата</param> /// <param name="onliCheck">Только рассчитать, не изымая.</param> /// <error>Ошибка, или результат при onliCheck</error> /// <returns>Строка с количество требуемой стоимости</returns> public static string GetCostOnGameByCommand(string command, bool onliCheck, out string error) { Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand 1 command:" + command); //разбираем аргументы в кавычках '. Удвоенная кавычка указывает на её символ. string cmd; List <string> args; ChatUtils.ParceCommand(command, out cmd, out args); if (args.Count < 3) { error = "OC_Incidents_OCIncident_WrongArg".Translate().ToString(); Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand error:" + error); return(null); } // /call raid '111' 1 10 air tribe //проверка, что денег хватает int cost = OCIncident.CalculateRaidCost(args[0].ToLower(), Int64.Parse(args[2]) , args.Count > 3 ? Int32.Parse(args[3]) : 1 , args.Count > 4 ? args[4].ToLower() : null , args.Count > 5 ? args[5].ToLower() : null); int gold = -1; Map map = null; if (cost > 0) { gold = GameUtils.FindThings(ThingDefOf.Gold, 0, false); } if (cost < 0 || gold < 0 || gold < cost) { error = cost < 0 || gold < 0 ? "OC_Incidents_OCIncident_WealthErr".Translate().ToString() + $" cost={cost} gold={gold}" : "OC_Incidents_OCIncident_GoldErr".Translate(gold, cost, cost - gold).ToString(); Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand error:" + error); return(null); } if (onliCheck) { error = null; return("OC_Incidents_OCIncident_NotEnoughGold".Translate(cost)); } Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand 2"); //отнимаем нужное кол-во денег(золото или серебро... или что-нибудь ещё) GameUtils.FindThings(ThingDefOf.Gold, cost, false); Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand 3"); //принудительное сохранение if (!SessionClientController.Data.BackgroundSaveGameOff) { SessionClientController.SaveGameNow(true); } Loger.Log("IncidentLod ChatController.AfterStartIncident 4"); error = null; return("OC_Incidents_OCIncident_GoldPay".Translate(cost)); }
public void TestChat1() { ChatUtils.RunChat(api); }
private void SendMessagesHistory(GroupChat groupChat) { ChatUtils.SendMessagesHistory(_data.AllGroupsChat.GetAllGroupHistory(groupChat), _client, _requests); }
public void OnEvent(ShPlayer player, string message) { if (chatted.Limit(player)) { return; } Core.Instance.Logger.LogInfo($"[LOCAL] {player.username.CleanerMessage()}: {message.CleanerMessage()}"); if (CommandHandler.OnEvent(player, message)) // 'true' if message starts with command prefix { return; } if (Core.Instance.Settings.General.LocalChatOverHead) { player.svPlayer.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.LocalChatMessage, player.ID, message.CleanerMessage()); } if (Core.Instance.Settings.General.LocalChatInChat) { player.svPlayer.Send(SvSendType.LocalOthers, Channel.Unsequenced, ClPacket.GameMessage, ChatUtils.FormatMessage(player, message, "localformat")); } }
private void SendMessageToEachClient(string message) { ChatUtils.SendMessageToEachClient(message, _data.ClientsInGlobalChat.Clients.Values.ToList(), _requests); }
public void Invoke(ShPlayer player, ShPlayer target, string reason = "No reason provided.") { ChatUtils.SendToAllEnabledChatT("all_kick", player.username.CleanerMessage(), target.username.CleanerMessage(), reason.CleanerMessage()); player.TS("player_kick", target.username.CleanerMessage(), reason.CleanerMessage()); player.svPlayer.SvKick(target, reason); }
public ModelStatus GetModelStatus(ModelPostingChat pc, ServiceContext context) { if (context.PossiblyIntruder) { context.Disconnect("Possibly intruder"); return(null); } var timeNow = DateTime.UtcNow; if (string.IsNullOrEmpty(pc.Message)) { return(new ModelStatus() { Status = 0, Message = null }); } var chat = context.Player.Chats.Keys.FirstOrDefault(ct => ct.Id == pc.IdChat); if (chat == null) { return(new ModelStatus() { Status = 1, Message = "Chat not available" }); } Grants acceptedGrants; PlayerServer player; // обработка команд чата if ("discord".Equals(context.Player.Public.Login.ToLower())) { player = Repository.GetPlayerByLogin(pc.Owner); if (player == null) { return(new ModelStatus() { Status = (int)ChatCmdResult.UserNotFound, Message = $"user {pc.Owner} not found", }); } acceptedGrants = context.Player.Public.Grants & player.Public.Grants; } else { player = context.Player; acceptedGrants = player.Public.Grants; } if (pc.Message[0] == '/') { //разбираем аргументы в кавычках '. Удвоенная кавычка указывает на её символ. string command; List <string> argsM; ChatUtils.ParceCommand(pc.Message, out command, out argsM); var result = ChatManager.TryGetCmdForUser(player.Public.Login, acceptedGrants, command, out IChatCmd cmd); if (result.Status > 0) { return(result); } // аdditionally check Grants for DiscordUser: some commands for example: create chat, get token doesn't permitted from discord return(cmd.Execute(ref player, chat, argsM)); } else { Loger.Log("Server post " + context.Player.Public.Login + ":" + pc.Message); var mmsg = pc.Message; if (mmsg.Length > 2048) { mmsg = mmsg.Substring(0, 2048); } chat.Posts.Add(new ChatPost() { Time = timeNow, Message = mmsg, OwnerLogin = player.Public.Login, DiscordIdMessage = pc.IdDiscordMsg, }); } return(new ModelStatus() { Status = 0, Message = null }); }