protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } ParentChannelId = list.GetParameterValue <uint>("pid"); Name = list.GetParameterValue("channel_name"); Topic = list.GetParameterValue("channel_topic"); Description = list.GetParameterValue("channel_description"); PasswordHash = list.GetParameterValue("channel_password"); Codec = list.GetParameterValue <ushort>("channel_codec"); CodecQuality = list.GetParameterValue <double>("channel_codec_quality"); MaxClients = list.GetParameterValue <int>("channel_maxclients"); MaxFamilyClients = list.GetParameterValue <int>("channel_maxfamilyclients"); Order = list.GetParameterValue <uint>("channel_order"); IsDefaultChannel = list.GetParameterValue("channel_flag_default").ToBool(); IsPasswordProtected = list.GetParameterValue("channel_flag_password").ToBool(); IsPermanent = list.GetParameterValue("channel_flag_permanent").ToBool(); IsSemiPermanent = list.GetParameterValue("channel_flag_semi_permanent").ToBool(); IsMaxClientsUnlimited = list.GetParameterValue("channel_flag_maxclients_unlimited").ToBool(); IsMaxFamilyClientsUnlimited = list.GetParameterValue("channel_flag_maxfamilyclients_unlimited").ToBool(); IsMaxFamilyClientsInherited = list.GetParameterValue("channel_flag_maxfamilyclients_inherited").ToBool(); FilePath = list.GetParameterValue("channel_filepath"); NeededTalkPower = list.GetParameterValue <uint>("channel_needed_talk_power"); ForcedSilence = list.GetParameterValue("channel_forced_silence").ToBool(); PhoneticName = list.GetParameterValue("channel_name_phonetic"); IconId = list.GetParameterValue <uint>("channel_icon_id"); }
void INotificationHandler.HandleResponse(IQueryClient queryClient, string responseText) { CommandParameterGroupList parameterGroupList = CommandParameterGroupList.Parse(responseText); int?reasonId = parameterGroupList.GetParameterValue <int?>("reasonid") ?? (int)ClientLeftReason.Disconnect; switch ((ClientLeftReason)reasonId.Value) { case ClientLeftReason.Kicked: Kicked?.Invoke(queryClient, new ClientKickEventArgs(parameterGroupList)); break; case ClientLeftReason.Banned: Banned?.Invoke(queryClient, new ClientBanEventArgs(parameterGroupList)); break; case ClientLeftReason.ConnectionLost: ConnectionLost?.Invoke(queryClient, new ClientConnectionLostEventArgs(parameterGroupList)); break; case ClientLeftReason.Disconnect: Disconnected?.Invoke(queryClient, new ClientDisconnectEventArgs(parameterGroupList)); break; } }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } FileTransferBandwidthSent = list.GetParameterValue <uint>("connection_filetransfer_bandwidth_sent"); FileTransferBandwidthReceived = list.GetParameterValue <uint>("connection_filetransfer_bandwidth_received"); PacketsSentTotal = list.GetParameterValue <ulong>("connection_packets_sent_total"); PacketsReceivedTotal = list.GetParameterValue <ulong>("connection_bytes_sent_total"); BytesSentTotal = list.GetParameterValue <ulong>("connection_packets_received_total"); BytesReceivedTotal = list.GetParameterValue <ulong>("connection_bytes_received_total"); BandwidthSentLastSecond = list.GetParameterValue <uint>("connection_bandwidth_sent_last_second_total"); BandwidthSentLastMinute = list.GetParameterValue <uint>("connection_bandwidth_sent_last_minute_total"); BandwidthReceivedLastSecond = list.GetParameterValue <uint>("connection_bandwidth_received_last_second_total"); BandwidthReceivedLastMinute = list.GetParameterValue <uint>("connection_bandwidth_received_last_minute_total"); ConnectionDuration = TimeSpan.FromMilliseconds(list.GetParameterValue <uint>("connection_connected_time")); FileTransferBytesSentTotal = list.GetParameterValue <ulong>("connection_filetransfer_bytes_sent_total"); FileTransferBytesReceivedTotal = list.GetParameterValue <ulong>("connection_filetransfer_bytes_received_total"); PacketLossTotal = list.GetParameterValue <double>("connection_packetloss_total"); Ping = list.GetParameterValue <double>("connection_ping"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } Uptime = TimeSpan.FromSeconds(list.GetParameterValue <ulong>("INSTANCE_UPTIME")); UtcTimeStamp = new DateTime(1970, 1, 1).AddSeconds(list.GetParameterValue <ulong>("HOST_TIMESTAMP_UTC")); VirtualServersCount = list.GetParameterValue <uint>("VIRTUALSERVERS_RUNNING_TOTAL"); FileTransferBandwidthSent = list.GetParameterValue <ulong>("CONNECTION_FILETRANSFER_BANDWIDTH_SENT"); FileTransferBandwidthReceived = list.GetParameterValue <ulong>("CONNECTION_FILETRANSFER_BANDWIDTH_RECEIVED"); AmountOfPacketsSendTotal = list.GetParameterValue <ulong>("CONNECTION_PACKETS_SENT_TOTAL"); AmountOfPacketsReceivedTotal = list.GetParameterValue <ulong>("CONNECTION_PACKETS_RECEIVED_TOTAL"); AmountOfBytesSendTotal = list.GetParameterValue <ulong>("CONNECTION_BYTES_SENT_TOTAL"); AmountOfBytesReceivedTotal = list.GetParameterValue <ulong>("CONNECTION_BYTES_RECEIVED_TOTAL"); BandWidthSentLastSecondTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_SENT_LAST_SECOND_TOTAL"); BandWidthReceivedLastSecondTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_RECEIVED_LAST_SECOND_TOTAL"); BandWidthSentLastMinuteTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_SENT_LAST_MINUTE_TOTAL"); BandWidthReceivedLastMinuteTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_RECEIVED_LAST_MINUTE_TOTAL"); TotalMaxClients = list.GetParameterValue <uint>("virtualservers_total_maxclients"); TotalClientsOnline = list.GetParameterValue <uint>("virtualservers_total_clients_online"); TotalChannelsOnline = list.GetParameterValue <uint>("virtualservers_total_channels_online"); FileTransferBytesSentTotal = list.GetParameterValue <ulong>("connection_filetransfer_bytes_sent_total"); FileTransferBytesReceivedTotal = list.GetParameterValue <ulong>("connection_filetransfer_bytes_received_total"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { base.FillFrom(responseText, additionalStates); CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); LastIP = list.GetParameterValue("client_lastip"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { base.FillFrom(responseText, additionalStates); CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } Version = list.GetParameterValue("client_version"); Platform = list.GetParameterValue("client_platform"); InputMuted = list.GetParameterValue("client_input_muted").ToBool(); OutputMuted = list.GetParameterValue("client_output_muted").ToBool(); OuputOnlyMuted = list.GetParameterValue("client_outputonly_muted").ToBool(); HasInputHardware = list.GetParameterValue("client_input_hardware").ToBool(); HasOutputHardware = list.GetParameterValue("client_output_hardware").ToBool(); IsRecording = list.GetParameterValue("client_is_recording").ToBool(); IsAway = list.GetParameterValue("client_away").ToBool(); IsTalker = list.GetParameterValue("client_is_talker").ToBool(); IsPrioritySpeaker = list.GetParameterValue("client_is_priority_speaker").ToBool(); AwayMessage = list.GetParameterValue("client_away_message"); DefaultChannel = list.GetParameterValue("client_default_channel"); MetaData = list.GetParameterValue("client_meta_data"); LoginName = list.GetParameterValue("client_login_name"); TalkRequestMessage = list.GetParameterValue("client_talk_request_msg"); NicknamePhonetic = list.GetParameterValue("client_nickname_phonetic"); FileTransferBandwidthSent = list.GetParameterValue <ulong>("CONNECTION_FILETRANSFER_BANDWIDTH_SENT"); FileTransferBandwidthReceived = list.GetParameterValue <ulong>("CONNECTION_FILETRANSFER_BANDWIDTH_RECEIVED"); AmountOfPacketsSendTotal = list.GetParameterValue <ulong>("CONNECTION_PACKETS_SENT_TOTAL"); AmountOfPacketsReceivedTotal = list.GetParameterValue <ulong>("CONNECTION_PACKETS_RECEIVED_TOTAL"); AmountOfBytesSendTotal = list.GetParameterValue <ulong>("CONNECTION_BYTES_SENT_TOTAL"); AmountOfBytesReceivedTotal = list.GetParameterValue <ulong>("CONNECTION_BYTES_RECEIVED_TOTAL"); BandWidthSentLastSecondTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_SENT_LAST_SECOND_TOTAL"); BandWidthReceivedLastSecondTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_RECEIVED_LAST_SECOND_TOTAL"); BandWidthSentLastMinuteTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_SENT_LAST_MINUTE_TOTAL"); BandWidthReceivedLastMinuteTotal = list.GetParameterValue <ulong>("CONNECTION_BANDWIDTH_RECEIVED_LAST_MINUTE_TOTAL"); DatabaseId = list.GetParameterValue <uint>("client_database_id"); ChannelId = list.GetParameterValue <uint>("cid"); ChannelGroupId = list.GetParameterValue <uint>("client_channel_group_id"); ServerGroups = list.GetParameterValue("client_servergroups").ToIdList(); Type = list.GetParameterValue <uint>("client_type"); TalkPower = list.GetParameterValue <uint>("client_talk_power"); TalkRequests = list.GetParameterValue <uint>("client_talk_request"); NeededServerQueryViewPower = list.GetParameterValue <uint>("client_needed_serverquery_view_power"); Avatar = list.GetParameterValue("client_flag_avatar"); IdleTime = TimeSpan.FromMilliseconds(list.GetParameterValue <uint>("client_idle_time")); ConnectedTime = TimeSpan.FromMilliseconds(list.GetParameterValue <uint>("connection_connected_time")); ClientIP = list.GetParameterValue("connection_client_ip"); ClientCountry = list.GetParameterValue("client_country"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) return; ClientUniqueId = list.GetParameterValue("cluid"); NickName = list.GetParameterValue("name"); ClientId = list.GetParameterValue<uint>("clid"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } Path = list.GetParameterValue("path"); Password = list.GetParameterValue("password"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } ClientId = list.GetParameterValue <uint>("clid"); ChannelId = list.GetParameterValue <uint>("cid"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0 || additionalStates == null || additionalStates.Length == 0) { Value = default(T); return; } Value = list.GetParameterValue(additionalStates[0].ToString()).ChangeTypeInvariant(default(T)); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } Version = list.GetParameterValue("version"); Build = list.GetParameterValue("build"); Platform = list.GetParameterValue("platform"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } ServerId = list.GetParameterValue <uint>("sid"); ServerPort = list.GetParameterValue <ushort>("virtualserver_port"); Token = list.GetParameterValue("token"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } PermissionId = list.GetParameterValue <uint>("permid"); PermissionName = list.GetParameterValue("permsid"); PermissionValue = list.GetParameterValue <int>("permvalue"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } ClientFileTransferId = list.GetParameterValue <uint?>("clientftfid"); ServerFileTransferId = list.GetParameterValue <uint?>("serverftfid"); FileTransferKey = list.GetParameterValue("ftkey"); FileTransferPort = list.GetParameterValue <ushort?>("port"); FileSize = list.GetParameterValue <ulong?>("size"); }
private void DetermineErrorDetails(string statusLine) { CommandParameterGroupList list = CommandParameterGroupList.Parse(statusLine); if (list.Count == 0) { return; } ErrorId = list.GetParameterValue <uint>("id"); ErrorMessage = list.GetParameterValue("msg"); BanExtraMessage = list.GetParameterValue("extra_msg"); FailedPermissionId = list.GetParameterValue <uint?>("failed_permid"); IsBanned = ErrorId == 3329 || ErrorId == 3331; }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } MessageId = list.GetParameterValue <uint>("msgid"); SenderUniqueId = list.GetParameterValue("cluid"); Subject = list.GetParameterValue("subject"); Created = new DateTime(1970, 1, 1).AddSeconds(list.GetParameterValue <ulong>("timestamp")); WasRead = list.GetParameterValue("flag_read").ToBool(); }
private void QueryRunner_UnknownNotificationReceived(object sender, EventArgs <string> e) { CommandParameterGroupList parameterGroupList = CommandParameterGroupList.Parse(e.Value); if (parameterGroupList.Count == 0) { return; } Action <CommandParameterGroupList> handler; if (NotificationHandlers.TryGetValue(parameterGroupList[0][0].Name, out handler)) { handler(parameterGroupList); } }
//Client message private void Notifications_ClientMessageReceived(object sender, TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs e) { //Bot Commands if (e.InvokerClientId != whoAmI.ClientId) { if (e.Message.StartsWith("!")) { string cmd = e.Message.Remove(0, 1); // Invoke the (now deprecated) BotCommandAttempt method var cmdPGL = CommandParameterGroupList.Parse(cmd); foreach (CommandParameterGroup cmdPG in cmdPGL) { BotCommandAttempt.Invoke(this, cmdPG, e); } } } }
public static ClientDbEntryListResponse Parse(string responseText) { ClientDbEntryListResponse response = new ClientDbEntryListResponse(); response.Assign(Parse(responseText, ClientDbEntry.Parse)); if (!response.IsErroneous) { CommandParameterGroupList list = CommandParameterGroupList.Parse(response.BodyText); CommandParameterGroup firstCommandParameterGroup = list.Count == 0 ? null : list[0]; if (firstCommandParameterGroup != null) { response.TotalClientsInDatabase = firstCommandParameterGroup.GetParameterValue <uint?>("count"); } } return(response); }
protected virtual void FillFrom(string responseText, Func <CommandParameterGroup, CommandParameterGroup, T> parseMethod, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0 || ((additionalStates == null || additionalStates.Length == 0) && parseMethod == null)) { Values = new List <T>(); return; } if (parseMethod != null) { CommandParameterGroup first = list.Count == 0 ? null : list[0]; Values = list.Select(x => parseMethod(x, first)).ToList(); } else { Values = list.Select(cpg => cpg.GetParameterValue(additionalStates[0].ToString()).ChangeTypeInvariant(default(T))).ToList(); } }
void INotificationHandler.HandleResponse(IQueryClient queryClient, string responseText) { CommandParameterGroupList parameterGroupList = CommandParameterGroupList.Parse(responseText); MessageTarget messageTarget = (MessageTarget)parameterGroupList.GetParameterValue <uint>("targetmode"); switch (messageTarget) { case MessageTarget.Client: ReceivedFromClient?.Invoke(queryClient, new MessageReceivedEventArgs(parameterGroupList)); break; case MessageTarget.Channel: ReceivedFromChannel?.Invoke(queryClient, new MessageReceivedEventArgs(parameterGroupList)); break; case MessageTarget.Server: ReceivedFromServer?.Invoke(queryClient, new MessageReceivedEventArgs(parameterGroupList)); break; } }
void INotificationHandler.HandleResponse(IQueryClient queryClient, string responseText) { CommandParameterGroupList parameterGroupList = CommandParameterGroupList.Parse(responseText); int?invokerId = parameterGroupList.GetParameterValue <int?>("invokerid"); if (!invokerId.HasValue) { JoiningChannel?.Invoke(queryClient, new ClientMovedEventArgs(parameterGroupList)); return; } if (invokerId == 0) { CreatingTemporaryChannel?.Invoke(queryClient, new ClientMovedEventArgs(parameterGroupList)); } else { JoiningChannelForced?.Invoke(queryClient, new ClientMovedByClientEventArgs(parameterGroupList)); } }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } string statusString = list.GetParameterValue("virtualserver_status"); VirtualServerStatus = VirtualServerStatusHelper.Parse(statusString); ClientId = list.GetParameterValue <uint>("client_id"); VirtualServerUniqueId = list.GetParameterValue("virtualserver_unique_identifier"); VirtualServerId = list.GetParameterValue <uint>("virtualserver_id"); ChannelId = list.GetParameterValue <uint>("client_channel_id"); ClientDatabaseId = list.GetParameterValue <uint>("client_database_id"); ClientNickName = list.GetParameterValue("client_nickname"); ClientLoginName = list.GetParameterValue("client_login_name"); ClientUniqueId = list.GetParameterValue("client_unique_identifier"); ServerPort = list.GetParameterValue <ushort>("virtualserver_port"); OriginServerId = list.GetParameterValue <uint>("client_origin_server_id"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } UniqueId = list.GetParameterValue("client_unique_identifier"); Nickname = list.GetParameterValue("client_nickname"); DatabaseId = list.GetParameterValue <uint>("client_database_id"); Created = new DateTime(1970, 1, 1).AddSeconds(list.GetParameterValue <ulong>("client_created")); LastConnected = new DateTime(1970, 1, 1).AddSeconds(list.GetParameterValue <ulong>("client_lastconnected")); TotalConnections = list.GetParameterValue <uint>("client_totalconnections"); Description = list.GetParameterValue("client_description"); MonthBytesUploaded = list.GetParameterValue <ulong>("client_month_bytes_uploaded"); MonthBytesDonwloaded = list.GetParameterValue <ulong>("client_month_bytes_downloaded"); TotalBytesUploaded = list.GetParameterValue <ulong>("client_total_bytes_uploaded"); TotalBytesDownloaded = list.GetParameterValue <ulong>("client_total_bytes_downloaded"); IconId = list.GetParameterValue <uint?>("client_icon_id"); HashedUniqueId = list.GetParameterValue("client_base64HashClientUID"); }
protected override void FillFrom(string responseText, params object[] additionalStates) { CommandParameterGroupList list = CommandParameterGroupList.Parse(BodyText); if (list.Count == 0) { return; } DatabaseVersion = list.GetParameterValue <uint>("SERVERINSTANCE_DATABASE_VERSION"); GuestServerQueryGroupId = list.GetParameterValue <uint>("SERVERINSTANCE_GUEST_SERVERQUERY_GROUP"); TemplateServerAdminGroupId = list.GetParameterValue <uint>("SERVERINSTANCE_TEMPLATE_SERVERADMIN_GROUP"); TemplateServerDefaultGroupId = list.GetParameterValue <uint>("serverinstance_template_serverdefault_group"); TemplateChannelAdminGroupId = list.GetParameterValue <uint>("serverinstance_template_channeladmin_group"); TemplateChannelDefaultGroupId = list.GetParameterValue <uint>("serverinstance_template_channeldefault_group"); FileTransferPort = list.GetParameterValue <ushort>("SERVERINSTANCE_FILETRANSFER_PORT"); MaxDownloadTotalBandWidth = list.GetParameterValue <ulong>("SERVERINSTANCE_MAX_DOWNLOAD_TOTAL_BANDWIDTH"); MaxUploadTotalBandWidth = list.GetParameterValue <ulong>("SERVERINSTANCE_MAX_UPLOAD_TOTAL_BANDWIDTH"); ServerQueryFloodCommandsCount = list.GetParameterValue <uint>("serverinstance_serverquery_flood_commands"); ServerQueryFloodRatingDuration = TimeSpan.FromSeconds(list.GetParameterValue <double>("serverinstance_serverquery_flood_time")); ServerQueryBanDuration = TimeSpan.FromSeconds(list.GetParameterValue <double>("serverinstance_serverquery_ban_time")); }
public ChannelEditedEventArgs(string source) { Parse(CommandParameterGroupList.Parse(source)); }
void INotificationHandler.HandleResponse(IQueryClient queryClient, string responseText) { CommandParameterGroupList commandParameterGroupList = CommandParameterGroupList.Parse(responseText); Triggered?.Invoke(queryClient, new UnknownNotificationEventArgs(commandParameterGroupList.First()?.First()?.Name, commandParameterGroupList, responseText)); }
static void Main(string[] args) { CommandParameterGroupList cmds; cmds = CommandParameterGroupList.Parse(String.Join(" ", args)); SynchronizationContext ctx = new SynchronizationContext(); SynchronizationContext.SetSynchronizationContext(ctx); List <BotConnection> botConnections = new List <BotConnection>(); ////DB connectionstring-adding, not a good option because it won't let you use Add-Migration / Update-Database //var cmd_connectionstring = cmds.Where(cmdPG => cmdPG.Exists(cmdP => cmdP.Name == "connectionstring")); //foreach (var cmd in cmd_connectionstring) //{ // CoreContext.connectionString = cmd.SingleOrDefault(x => x.Name.ToLower() == "connectionstring").Value; // string test2 = cmd.SingleOrDefault(x => x.Name.ToLower() == "connectionstring").EncodedValue; //} using (var db = new CoreContext()) { //Database deletion switch var cmds_deldb = cmds.Where(cmdPG => cmdPG.Exists(cmdP => cmdP.Name == "deletedb")); if (cmds_deldb.Count() > 0) { db.Database.EnsureDeleted(); logger.Info("Database deleted!"); } } using (var db = new CoreContext()) { //Subscribers reset switch var cmds_rs = cmds.Where(cmdPG => cmdPG.Exists(cmdP => cmdP.Name == "resetsubscribers")); if (cmds_rs.Count() > 0) { db.Subscribers.Clear(); db.SaveChanges(); logger.Info("Subscribers removed!"); } //Subscriber-adding var cmds_dc = cmds.Where(cmdPG => cmdPG.Exists(cmdP => cmdP.Name == "subscriber")); foreach (var cmd in cmds_dc) { try { Core.ServerQueryConnection.Models.Subscribers sub = new Core.ServerQueryConnection.Models.Subscribers() { ServerIp = cmd.SingleOrDefault(x => x.Name.ToLower() == "serverip").Value, AdminPassword = cmd.SingleOrDefault(x => x.Name.ToLower() == "adminpassword").Value, AdminUsername = cmd.SingleOrDefault(x => x.Name.ToLower() == "adminusername").Value, ServerPort = Convert.ToInt16(cmd.SingleOrDefault(x => x.Name.ToLower() == "serverport").Value), VirtualServerId = Convert.ToInt32(cmd.SingleOrDefault(x => x.Name.ToLower() == "virtualserverid").Value), SubscriberUniqueId = cmd.SingleOrDefault(x => x.Name.ToLower() == "uniqueid").Value, BotNickName = cmd.SingleOrDefault(x => x.Name.ToLower() == "botnickname").Value }; var search = db.Subscribers.SingleOrDefault(x => x.SubscriberUniqueId == sub.SubscriberUniqueId && x.VirtualServerId == sub.VirtualServerId); if (search == null) { db.Subscribers.Add(sub); } else { search.ServerIp = sub.ServerIp; search.AdminPassword = sub.AdminPassword; search.AdminUsername = sub.AdminUsername; search.ServerPort = Convert.ToInt16(sub.ServerPort); search.VirtualServerId = Convert.ToInt32(sub.VirtualServerId); search.SubscriberUniqueId = sub.SubscriberUniqueId; search.BotNickName = sub.BotNickName; } var count = db.SaveChanges(); logger.Info("Subscriber {0} saved to database", sub.ToString(true)); } catch (Exception ex) { logger.Warn(ex, "Failed to add a subscriber from command line"); } } foreach (var subscriber in db.Subscribers) { logger.Info("Setting up subscriber {0}..", subscriber.ToString(true)); botConnections.Add(new BotConnection(subscriber)); } } while (true) { Thread.Sleep(1000); } }
void INotificationHandler.HandleResponse(IQueryClient queryClient, string responseText) { Triggered?.Invoke(queryClient, new ChannelCreatedEventArgs(CommandParameterGroupList.Parse(responseText))); }
public void Parse(string source) { Parse(CommandParameterGroupList.Parse(source)); }