/// <summary> /// Logs the specified message. /// </summary> /// <param name="logLevel">The log level.</param> /// <param name="setting">The setting.</param> /// <param name="message">The message.</param> protected void Log(LogLevel logLevel, ISettings setting, string message) { LogService.Debug(message); if (setting.LogEnabled) { QueryRunner.AddLogEntry(new LogEntryLight(logLevel, message)); } }
/// <summary> /// Inits the credential. /// </summary> private void InitCredential() { TcpDispatcher = new SyncTcpDispatcher(BotInstance.Settings); QueryRunner = new QueryRunner(TcpDispatcher); QueryRunner.Login(BotInstance.Settings.TeamSpeak.Username, BotInstance.Settings.TeamSpeak.Password); if (BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault() > 0) { QueryRunner.SelectVirtualServerByPort(BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault()); } else { QueryRunner.SelectVirtualServerById(BotInstance.Settings.TeamSpeak.Instance.GetValueOrDefault()); } Self = QueryRunner.SendWhoAmI(); WorkerTcpDispatcher = new SyncTcpDispatcher(BotInstance.Settings); WorkerQueryRunner = new QueryRunner(WorkerTcpDispatcher); WorkerQueryRunner.Login(BotInstance.Settings.TeamSpeak.Username, BotInstance.Settings.TeamSpeak.Password); if (BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault() > 0) { WorkerQueryRunner.SelectVirtualServerByPort(BotInstance.Settings.TeamSpeak.InstancePort.GetValueOrDefault()); } else { WorkerQueryRunner.SelectVirtualServerById(BotInstance.Settings.TeamSpeak.Instance.GetValueOrDefault()); } WorkerQueryRunner.UpdateCurrentQueryClient(new ClientModification { Nickname = BotInstance.Settings.Global.BotNickname }); SelfWorker = WorkerQueryRunner.SendWhoAmI(); WorkerQueryRunner.AddLogEntry(new LogEntryLight(LogLevel.Info, string.Format("TS3-Bot '{0}' connected.", BotInstance.Settings.Global.BotNickname))); NotificationTcpDispatcher = new AsyncTcpDispatcher(BotInstance.Settings); NotificationQueryRunner = new QueryRunner(NotificationTcpDispatcher); NotificationTcpDispatcher.ServerClosedConnection += notificationDispatcher_ServerClosedConnection; NotificationTcpDispatcher.ReadyForSendingCommands += notificationDispatcher_ReadyForSendingCommands; NotificationQueryRunner.Notifications.ClientJoined += BotInstance.Notifications_ClientJoined; NotificationQueryRunner.Notifications.ClientMoved += BotInstance.Notifications_ClientMoved; NotificationQueryRunner.Notifications.ClientMoveForced += BotInstance.Notifications_ClientMoveForced; NotificationQueryRunner.Notifications.ClientDisconnect += BotInstance.Notifications_ClientDisconnect; NotificationQueryRunner.Notifications.ClientConnectionLost += BotInstance.Notifications_ClientConnectionLost; NotificationQueryRunner.Notifications.ServerMessageReceived += BotInstance.Notifications_MessageReceived; NotificationQueryRunner.Notifications.ChannelMessageReceived += BotInstance.Notifications_MessageReceived; NotificationQueryRunner.Notifications.ClientMessageReceived += BotInstance.Notifications_MessageReceived; TcpDispatcher.Connect(); WorkerTcpDispatcher.Connect(); NotificationTcpDispatcher.Connect(); Initialized = true; }
/// <summary> /// Logs the specified log level. /// </summary> /// <param name="logLevel">The log level.</param> /// <param name="message">The message.</param> protected void Log(LogLevel logLevel, string message) { QueryRunner.AddLogEntry(new LogEntryLight(logLevel, message)); }