//BanAction public static void ProcessAction(Client client, Player player, BanAction action) { var target = DbInterface.GetPlayer(action.Name); if (target != null) { if (string.IsNullOrEmpty(Ban.CheckBan(target.User, ""))) { if (action.BanIp == true) { Ban.Add( target.User, action.DurationDays, action.Reason, player.Name, target.Client?.GetIp() ?? "" ); } else { Ban.Add(target.User, action.DurationDays, action.Reason, player.Name, ""); } target.Client?.Disconnect(); PacketSender.SendChatMsg(player, Strings.Account.banned.ToString(target.Name), Color.Red); } else { PacketSender.SendChatMsg(player, Strings.Account.alreadybanned.ToString(target.Name), Color.Red); } } else { PacketSender.SendChatMsg(player, Strings.Player.offline); } }
void OnReceiveRealConditions(object sender, _DKHOpenAPIEvents_OnReceiveRealConditionEvent e) { if (e.strType.Equals("I") && Pick.Contains(e.sTrCode) && Ban.Contains(e.sTrCode) == false && Strategics.Any(o => o.Code.Equals(e.sTrCode)) == false && Connect.HoldingStock.ContainsKey(e.sTrCode) == false && int.TryParse(axAPI.GetMasterLastPrice(e.sTrCode), out int price)) { new Task(() => { var sc = new SatisfyConditionsAccordingToTrends { Code = e.sTrCode, Short = AccordingToTrends.Short, Long = AccordingToTrends.Long, Trend = AccordingToTrends.Trend, ReservationSellUnit = AccordingToTrends.ReservationSellUnit, ReservationSellQuantity = AccordingToTrends.ReservationSellQuantity, ReservationSellRate = AccordingToTrends.ReservationSellRate, ReservationBuyUnit = AccordingToTrends.ReservationBuyUnit, ReservationBuyQuantity = AccordingToTrends.ReservationBuyQuantity, ReservationBuyRate = AccordingToTrends.ReservationBuyRate, TradingSellInterval = price / AccordingToTrends.TradingSellInterval, TradingSellQuantity = AccordingToTrends.TradingSellQuantity, TradingSellRate = AccordingToTrends.TradingSellRate, TradingBuyInterval = price / AccordingToTrends.TradingBuyInterval, TradingBuyQuantity = AccordingToTrends.TradingBuyQuantity, TradingBuyRate = AccordingToTrends.TradingBuyRate }; if (Strategics.Add(sc) && Ban.Add(e.sTrCode)) { var count = SetStrategics(sc); SendMessage(string.Concat(e.strConditionName, '_', count), e.sTrCode); SendConditions?.Invoke(this, new SendSecuritiesAPI(SetSatisfyConditions(sc), sc)); } }).Start(); } }
//BanAction public static void ProcessAction(Client client, Player player, BanAction action) { var target = Player.Find(action.Name); if (target != null) { if (string.IsNullOrEmpty(Ban.CheckBan(target.User, ""))) { if (action.BanIp == true) { Ban.Add( target.User, action.DurationDays, action.Reason, player.Name, target.Client?.GetIp() ?? "" ); } else { Ban.Add(target.User, action.DurationDays, action.Reason, player.Name, ""); } UserActivityHistory.LogActivity(target?.UserId ?? Guid.Empty, target?.Id ?? Guid.Empty, target?.Client?.GetIp(), UserActivityHistory.PeerType.Client, UserActivityHistory.UserAction.DisconnectBan, $"{target.User?.Name},{target.Name}"); target.Client?.Disconnect(); PacketSender.SendChatMsg(player, Strings.Account.banned.ToString(target.Name), Enums.ChatMessageType.Admin, Color.Red); } else { PacketSender.SendChatMsg(player, Strings.Account.alreadybanned.ToString(target.Name), Enums.ChatMessageType.Admin, Color.Red); } } else { PacketSender.SendChatMsg(player, Strings.Player.offline, Enums.ChatMessageType.Admin); } }
static async Task Main(string[] args) { RongCloud rongCloud = RongCloud.GetInstance(appKey, appSecret); //自定义 api地址方式 //RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api); Ban ban = rongCloud.Chatroom.ban; /** * API 文档: http://www.rongcloud.cn/docs/server_sdk_api/chatroom/ban.html#add * 添加聊天室全局禁言 * */ ChatroomMember[] members = { new ChatroomMember() { Id = "qawr34h" }, new ChatroomMember() { Id = "qawr35h" } }; ChatroomModel chatroom = new ChatroomModel() { Members = members, Minute = 5 }; ResponseResult result = await ban.Add(chatroom); Console.WriteLine("addGagUser: "******"ListGagUser: "******"removeBanUser: " + removeResult); Console.ReadLine(); }
//BanAction public static void ProcessAction(Client client, Player player, BanAction action) { var target = Player.Find(action.Name); if (target != null) { if (string.IsNullOrEmpty(Ban.CheckBan(target.User, ""))) { if (action.BanIp == true) { Ban.Add( target.User, action.DurationDays, action.Reason, player.Name, target.Client?.GetIp() ?? "" ); } else { Ban.Add(target.User, action.DurationDays, action.Reason, player.Name, ""); } using (var logging = DbInterface.LoggingContext) { logging.UserActivityHistory.Add( new UserActivityHistory { UserId = target.UserId, PlayerId = target.Id, Ip = target.Client?.GetIp(), Peer = UserActivityHistory.PeerType.Client, Action = UserActivityHistory.UserAction.DisconnectBan, Meta = $"{target.User?.Name},{target.Name}" } ); } target.Client?.Disconnect(); PacketSender.SendChatMsg(player, Strings.Account.banned.ToString(target.Name), Enums.ChatMessageType.Admin, Color.Red); } else { PacketSender.SendChatMsg(player, Strings.Account.alreadybanned.ToString(target.Name), Enums.ChatMessageType.Admin, Color.Red); } } else { PacketSender.SendChatMsg(player, Strings.Player.offline, Enums.ChatMessageType.Admin); } }
protected override void HandleClient(ServerContext context, Client target, int duration, bool ip, string reason) { if (target.Entity == null) { Console.WriteLine($@" {Strings.Player.offline}"); return; } // TODO: Refactor the global/console messages into ModeratorActionCommand var name = target.Entity.Name; if (string.IsNullOrEmpty(Ban.CheckBan(target.User, ""))) { Ban.Add(target, duration, reason, Strings.Commands.banuser, ip ? target.GetIp() : ""); target.Disconnect(); PacketSender.SendGlobalMsg(Strings.Account.banned.ToString(name)); Console.WriteLine($@" {Strings.Account.banned.ToString(name)}"); } else { Console.WriteLine($@" {Strings.Account.alreadybanned.ToString(name)}"); } }
private object DoAdminActionOnUser( Func <Tuple <Client, User> > fetch, Func <HttpResponseMessage> onError, AdminActions adminAction, AdminActionParameters actionParameters ) { var(client, user) = fetch(); if (user == null) { return(onError()); } var player = client?.Entity; var targetIp = client?.GetIp() ?? ""; switch (adminAction) { case AdminActions.Ban: if (string.IsNullOrEmpty(Ban.CheckBan(user, ""))) { Ban.Add( user.Id, actionParameters.Duration, actionParameters.Reason ?? "", actionParameters.Moderator ?? @"api", actionParameters.Ip ? targetIp : "" ); client?.Disconnect(); PacketSender.SendGlobalMsg(Strings.Account.banned.ToString(user.Name)); return(Request.CreateMessageResponse( HttpStatusCode.OK, Strings.Account.banned.ToString(user.Name) )); } else { return(Request.CreateMessageResponse( HttpStatusCode.BadRequest, Strings.Account.alreadybanned.ToString(user.Name) )); } case AdminActions.UnBan: Ban.Remove(user.Id, false); PacketSender.SendGlobalMsg(Strings.Account.unbanned.ToString(user.Name)); return(Request.CreateMessageResponse( HttpStatusCode.OK, Strings.Account.unbanned.ToString(user.Name) )); case AdminActions.Mute: if (string.IsNullOrEmpty(Mute.FindMuteReason(user.Id, ""))) { Mute.Add( user, actionParameters.Duration, actionParameters.Reason ?? "", actionParameters.Moderator ?? @"api", actionParameters.Ip ? targetIp : "" ); PacketSender.SendGlobalMsg(Strings.Account.muted.ToString(user.Name)); return(Request.CreateMessageResponse( HttpStatusCode.OK, Strings.Account.muted.ToString(user.Name) )); } else { return(Request.CreateMessageResponse( HttpStatusCode.BadRequest, Strings.Account.alreadymuted.ToString(user.Name) )); } case AdminActions.UnMute: Mute.Remove(user); PacketSender.SendGlobalMsg(Strings.Account.unmuted.ToString(user.Name)); return(Request.CreateMessageResponse( HttpStatusCode.OK, Strings.Account.unmuted.ToString(user.Name) )); case AdminActions.WarpTo: if (player != null) { var mapId = actionParameters.MapId == Guid.Empty ? player.MapId : actionParameters.MapId; player.Warp(mapId, (byte)player.X, (byte)player.Y); return(Request.CreateMessageResponse( HttpStatusCode.OK, $@"Warped '{player.Name}' to {mapId} ({player.X}, {player.Y})." )); } break; case AdminActions.WarpToLoc: if (player != null) { var mapId = actionParameters.MapId == Guid.Empty ? player.MapId : actionParameters.MapId; player.Warp(mapId, actionParameters.X, actionParameters.Y, true); return(Request.CreateMessageResponse( HttpStatusCode.OK, $@"Warped '{player.Name}' to {mapId} ({actionParameters.X}, {actionParameters.Y})." )); } break; case AdminActions.Kick: if (client != null) { client.Disconnect(actionParameters.Reason); PacketSender.SendGlobalMsg(Strings.Player.serverkicked.ToString(player?.Name)); return(Request.CreateMessageResponse( HttpStatusCode.OK, Strings.Player.serverkicked.ToString(player?.Name) )); } break; case AdminActions.Kill: if (client != null && client.Entity != null) { lock (client.Entity.EntityLock) { client.Entity.Die(); } PacketSender.SendGlobalMsg(Strings.Player.serverkilled.ToString(player?.Name)); return(Request.CreateMessageResponse( HttpStatusCode.OK, Strings.Commandoutput.killsuccess.ToString(player?.Name) )); } break; case AdminActions.WarpMeTo: case AdminActions.WarpToMe: return(Request.CreateErrorResponse( HttpStatusCode.BadRequest, $@"'{adminAction.ToString()}' not supported by the API." )); case AdminActions.SetSprite: case AdminActions.SetFace: case AdminActions.SetAccess: default: return(Request.CreateErrorResponse(HttpStatusCode.NotImplemented, adminAction.ToString())); } return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Strings.Player.offline)); }
public async Task <bool> MassMention(SocketUserMessage msg, SocketTextChannel channel) { if (msg.MentionedUsers.Distinct().Where(x => x != msg.Author).Where(x => x.IsBot == false).Count() + msg.MentionedRoles.Distinct().Where(x => x.IsMentionable == true).Count() >= 10) { SocketGuildUser user = channel.Guild.GetUser(msg.Author.Id); EmbedAuthorBuilder auth = new EmbedAuthorBuilder() { Name = $"Case {Ban.CaseCount(channel.Guild.Id) + 1} | Mute | {user.Username}#{user.Discriminator}", IconUrl = user.GetAvatarUrl(), }; EmbedBuilder embed = new EmbedBuilder() { Color = new Color(255, 0, 0), Author = auth }; EmbedFooterBuilder footer = new EmbedFooterBuilder() { Text = $"ID: {user.Id}" }; SocketTextChannel banlog = user.Guild.GetTextChannel(263474494327226388); SocketRole role = user.Guild.GetRole(308331455602229268); RequestOptions options = new RequestOptions() { AuditLogReason = $"Muting User | Reason: Auto - Mass mention | Mod: {Client.CurrentUser.Username}#{Client.CurrentUser.Discriminator}" }; await user.AddRoleAsync(role, options); embed.WithCurrentTimestamp(); embed.WithFooter(footer); embed.AddField(y => { y.Name = "User"; y.Value = user.Mention; y.IsInline = true; }); embed.AddField(y => { y.Name = "Moderator"; y.Value = Client.CurrentUser.Mention; y.IsInline = true; }); embed.AddField(y => { y.Name = "Length"; y.Value = $"10 minutes"; y.IsInline = true; }); embed.AddField(y => { y.Name = "Reason"; y.Value = "Auto - Mass mention"; y.IsInline = true; }); string content = Format.Sanitize(msg.Content).Length > 252 ? Format.Sanitize(msg.Content).SplitInParts(252).ElementAt(0) + "..." : Format.Sanitize(msg.Content); embed.AddField(y => { y.Name = "Message"; y.Value = $"**{content}**"; y.IsInline = true; }); Ban ban = new Ban() { GuildID = long.Parse(channel.Guild.Id.ToString()), Case = Ban.CaseCount(channel.Guild.Id) + 1, UserID = long.Parse(user.Id.ToString()), Username = user.Username + "#" + user.Discriminator, Type = "Mute", ModeratorID = long.Parse(Client.CurrentUser.Id.ToString()), Moderator = Client.CurrentUser.Username + "#" + Client.CurrentUser.Discriminator, Reason = "Auto - Mass mention - " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToUniversalTime().ToShortTimeString() }; Ban.Add(ban); try { await user.SendMessageAsync($"You have been muted in **{Format.Sanitize(channel.Guild.Name)}** by {Client.CurrentUser.Mention} for **mass mentioning** and for a length of **10** minutes."); } catch (Discord.Net.HttpException) { //cant send message } MutedUser.Add(channel.Guild.Id, user.Id); await channel.SendMessageAsync($"**{user.Username}#{user.Discriminator}** was muted."); await banlog.SendMessageAsync("", false, embed.Build()); Task task = Task.Run(async() => { await Task.Delay(600000); SocketGuildUser usr = user as SocketGuildUser; if (usr.Roles.Any(e => e.Name.ToUpperInvariant() == "Muted".ToUpperInvariant())) { options.AuditLogReason = "Unmuting User | Reason: Mute expired"; await user.RemoveRoleAsync(role, options); EmbedAuthorBuilder auth2 = new EmbedAuthorBuilder() { Name = $"Case {Ban.CaseCount(channel.Guild.Id) + 1} | Unmute | {user.Username}#{user.Discriminator}", IconUrl = user.GetAvatarUrl(), }; EmbedBuilder embed2 = new EmbedBuilder() { Color = new Color(0, 255, 0), Author = auth2 }; EmbedFooterBuilder footer2 = new EmbedFooterBuilder() { Text = $"ID: {user.Id}" }; embed2.WithCurrentTimestamp(); embed2.WithFooter(footer2); embed2.AddField(y => { y.Name = "User"; y.Value = user.Mention; y.IsInline = true; }); embed2.AddField(y => { y.Name = "Moderator"; y.Value = Client.CurrentUser.Mention; y.IsInline = true; }); embed2.AddField(y => { y.Name = "Reason"; y.Value = "Auto"; y.IsInline = true; }); await banlog.SendMessageAsync("", false, embed2.Build()); try { await user.SendMessageAsync($"You are now unmuted in **{Format.Sanitize(channel.Guild.Name)}**."); } catch (Discord.Net.HttpException) { //cant send message } ban.Type = "Unmute"; ban.Reason = "Auto - " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToUniversalTime().ToShortTimeString(); Ban.Add(ban); MutedUser.Remove(channel.Guild.Id, user.Id); } else { MutedUser.Remove(channel.Guild.Id, user.Id); } }); return(true); } else if (msg.MentionedUsers.Distinct().Where(x => x != msg.Author).Where(x => x.IsBot == false).Count() + msg.MentionedRoles.Distinct().Where(x => x.IsMentionable == true).Count() >= 5) { return(true); } return(false); }