コード例 #1
0
        /// <summary>
        /// Initializes the message
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
        /// <param name="parameters">The parameters.</param>
        public override void Initialize(MessageReceivedEventArgs e, string[] parameters)
        {
            SenderClientId = e.InvokerClientId;
            var nickname = string.Join(" ", parameters, 1, parameters.Length - 1);

            uint clientDatabaseId;
            if (uint.TryParse(nickname, out clientDatabaseId))
            {
                ClientDatabaseIds.Add(clientDatabaseId);
            }
            else
            {
                var clientIds = Repository.Client.GetClientsFromDatabase().Values
                    .Where(m => m.NickName.ToLower().Contains(nickname.ToLower()))
                    .Select(m => m.DatabaseId).ToList();
                if (clientIds.Any())
                {
                    ClientDatabaseIds = clientIds;
                }
                else
                {
                    ErrorMessage = string.Format("Could not find nickname or database id '{0}'", nickname);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes the message
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
        /// <param name="parameters">The parameters.</param>
        public override void Initialize(MessageReceivedEventArgs e, string[] parameters)
        {
            SenderClientId = e.InvokerClientId;

            string nickname = null;
            if (parameters.Length > 1)
            {
                TimeSpanEntity timeSpanEntity;
                if (TimeSpanEntity.TryParse(parameters[1], out timeSpanEntity))
                {
                    this.TimeSpan = timeSpanEntity;
                    if (parameters.Length > 2)
                    {
                        nickname = string.Join(" ", parameters, 2, parameters.Length - 2);
                    }
                }
                else if (parameters.Length > 2 && TimeSpanEntity.TryParse(parameters[parameters.Length - 1], out timeSpanEntity))
                {
                    this.TimeSpan = timeSpanEntity;
                    nickname = string.Join(" ", parameters, 1, parameters.Length - 2);
                }
                else
                {
                    nickname = string.Join(" ", parameters, 1, parameters.Length - 1);
                }
            }

            if (nickname != null)
            {
                AllClients = false;

                uint clientDatabaseId;
                if (uint.TryParse(nickname, out clientDatabaseId))
                {
                    ClientDatabaseIds.Add(clientDatabaseId);
                }
                else
                {
                    var clientIds = Repository.Client.GetClientsFromDatabase().Values
                        .Where(m => m.NickName.ToLower().Contains(nickname.ToLower()))
                        .Select(m => m.DatabaseId).ToList();
                    if (clientIds.Any())
                    {
                        ClientDatabaseIds = clientIds;
                    }
                    else
                    {
                        ErrorMessage = string.Format("Could not find nickname or database id '{0}'", nickname);
                    }
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 public override void Invoke(MessageReceivedEventArgs e)
 {
     Help(e);
     Seen(e);
     Files(e);
     Stick(e);
     Unstick(e);
     Hour(e);
     Moderator(e);
     SeenGroup(e);
     SeenModerator(e);
     Punish(e);
     Unpunish(e);
     SelfGroupAdd(e);
     SelfGroupRemove(e);
 }
コード例 #4
0
 /// <summary>
 /// Determines whether this instance can invoke the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 /// <returns>
 ///   <c>true</c> if this instance can invoke the specified e; otherwise, <c>false</c>.
 /// </returns>
 public override bool CanInvoke(MessageReceivedEventArgs e)
 {
     return CanInvoke(new ISettings[]
                          {
                              Repository.Settings.Control.Help,
                              Repository.Settings.Control.Seen,
                              Repository.Settings.Control.Files,
                              Repository.Settings.Control.Stick,
                              Repository.Settings.Control.Hours,
                              Repository.Settings.Control.Moderator,
                              Repository.Settings.Control.SeenGroup,
                              Repository.Settings.Control.SeenModerator,
                              Repository.Settings.Control.Punish,
                              Repository.Settings.Control.SelfGroup
                          });
 }
コード例 #5
0
        //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);
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Initializes the message
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
        /// <param name="parameters">The parameters.</param>
        public override void Initialize(MessageReceivedEventArgs e, string[] parameters)
        {
            SenderClientId = e.InvokerClientId;

            uint serverGroup;
            if (uint.TryParse(parameters[1], out serverGroup))
            {
                ServerGroup = serverGroup;
                ClientDatabaseIds = Repository.Client.GetClientsByServerGroup(serverGroup).ToList();
                if (!ClientDatabaseIds.Any())
                {
                    ErrorMessage = string.Format("Could not find server group id '{0}'", serverGroup);
                }
            }
            else
            {
                ErrorMessage = string.Format("Could not find server group id '{0}'", parameters[1]);
            }
        }
        /// <summary>
        /// Initializes the message
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
        /// <param name="parameters">The parameters.</param>
        public override void Initialize(MessageReceivedEventArgs e, string[] parameters)
        {
            SenderClientId = e.InvokerClientId;
            var serverGroup = parameters.Last();

            uint serverGroupId;
            if (uint.TryParse(serverGroup, out serverGroupId))
            {
                if (this.Repository.Settings.Control.SelfGroup.AllowedServerGroups.Contains(serverGroupId))
                {
                    this.ServerGroupIds.Add(serverGroupId);
                }
                else
                {
                    ErrorMessage = string.Format("The server group '{0}' is not allowed.", serverGroup);
                }
            }
            else
            {
                var serverGroups = Repository.Server.GetServerGroups().Where(m => m.Name.Equals(serverGroup, StringComparison.InvariantCultureIgnoreCase)).Select(m => m.Id).ToList();
                if (serverGroups.Any())
                {
                    if (serverGroups.All(s => this.Repository.Settings.Control.SelfGroup.AllowedServerGroups.Contains(s)))
                    {
                        this.ServerGroupIds = serverGroups;
                    }
                    else
                    {
                        ErrorMessage = string.Format("The server group '{0}' is not allowed.", serverGroup);
                    }
                }
                else
                {
                    ErrorMessage = string.Format("Could not find server group by name or id '{0}'", serverGroup);
                }
            }
        }
コード例 #8
0
ファイル: TeamSpeak.cs プロジェクト: Arefu/Kokujin
 private void CommandToChannel(MessageReceivedEventArgs EventArgs, string Message)
 {
     switch (Message.ToLower())
     {
         case "!register":
             QueryRunner.SendTextMessage(MessageTarget.Client, EventArgs.InvokerClientId, "Failed On Permission: i_group_register_steam.");
             break;
         case "!drop":
             QueryRunner.SendTextMessage(MessageTarget.Client, EventArgs.InvokerClientId, "Failed On Permission: i_group_drop_steam.");
             break;
         case "!salt":
             QueryRunner.SendTextMessage(MessageTarget.Client, EventArgs.InvokerClientId, "Failed On Permission: i_group_member_add_power.");
             break;
         case "!afk":
             QueryRunner.SendTextMessage(MessageTarget.Client, EventArgs.InvokerClientId, "Failed On Permission: i_member_move_power.");
             break;
         case "!help":
             QueryRunner.SendTextMessage(MessageTarget.Client, EventArgs.InvokerClientId, "Failed On Permission: i_member_message_power.");
             break;
         case "!getid":
             QueryRunner.SendTextMessage(MessageTarget.Client, EventArgs.InvokerClientId, "Failed On Permission: i_member_message_power.");
             break;
     }
 }
コード例 #9
0
ファイル: TeamSpeak.cs プロジェクト: Arefu/Kokujin
 private void Commands(MessageReceivedEventArgs EventArgs, string Message)
 {
     switch (Message.ToLower())
     {
         case "!register":
             Command_Handler.Register(EventArgs);
             break;
         case "!drop":
             Command_Handler.Drop(EventArgs);
             break;
         case "!salt":
             Command_Handler.Salt(EventArgs);
             break;
         case "!afk":
             Command_Handler.Afk(EventArgs);
             break;
         case "!help":
             Command_Handler.Help(EventArgs);
             break;
         case "!getid":
             Command_Handler.GetID(EventArgs);
             break;
     }
 }
コード例 #10
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 public virtual void Invoke(MessageReceivedEventArgs e)
 {
 }
コード例 #11
0
 /// <summary>
 /// Determines whether this instance can invoke the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 /// <returns>
 ///   <c>true</c> if this instance can invoke the specified e; otherwise, <c>false</c>.
 /// </returns>
 public virtual bool CanInvoke(MessageReceivedEventArgs e)
 {
     return false;
 }
コード例 #12
0
        /// <summary>
        /// Validates the Unstick message.
        /// </summary>
        /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
        protected void Unstick(MessageReceivedEventArgs e)
        {
            if (!Repository.Settings.Control.Stick.Enabled) return;

            if (MessageHelper.CanBeMessage<UnstickMessage>(e.Message) &&
                Repository.Client.GetClientInfo(e.InvokerClientId).ServerGroups
                    .Any(m => PermissionHelper.IsGranted(Repository.Settings.Control.Stick, m)))
            {
                Execute(MessageHelper.GetMessageInformation<UnstickMessage>(e, e.Message));
            }
        }
コード例 #13
0
 /// <summary>
 /// Invokes the specified e.
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 public virtual void Invoke(MessageReceivedEventArgs e)
 {
     Manager.Where(m => m.CanInvoke(e)).ForEach(m => m.Invoke(e));
 }
コード例 #14
0
 /// <summary>
 /// Initializes the message
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 /// <param name="parameters">The parameters.</param>
 public override void Initialize(MessageReceivedEventArgs e, string[] parameters)
 {
     SenderClientId = e.InvokerClientId;
     this.TimeSpan = TimeSpanEntity.Parse(parameters.Length > 1 ? parameters[1] : null);
 }
コード例 #15
0
 /// <summary>
 /// Handles the MessageReceived event of the Teamspeak Server.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 public void Notifications_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     try
     {
         ManagerFactory.Invoke(e);
     }
     catch (Exception ex)
     {
         LogService.Error(ex.ToString());
     }
 }
コード例 #16
0
ファイル: TeamSpeak.cs プロジェクト: Arefu/Kokujin
 private void Notifications_ServerMessageReceived(object sender, MessageReceivedEventArgs e)
 {
     if (e.InvokerNickname != "Obama")
     {
         string Message = e.Message;
         if (e.Message.Length > 1)
         {
             if (e.Message.Remove(1) == "!")
             {
                 if (e.Message.Contains(" "))
                 {
                     Message = e.Message.Remove(e.Message.IndexOf(" "));
                 }
                 Commands(e, Message);
             }
         }
     }
 }
コード例 #17
0
ファイル: AddonBaseOld.cs プロジェクト: qvazzler/Lyralei
 public virtual void onChannelMessage(object sender, TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs e)
 {
 }
コード例 #18
0
ファイル: AddonBaseOld.cs プロジェクト: qvazzler/Lyralei
 public virtual void onClientMessage(object sender, TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs e /*, BotCommandInput input, BotCommandPreface preface*/)
 {
 }
コード例 #19
0
 //Channel message
 private void Notifications_ChannelMessageReceived(object sender, TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs e)
 {
     //addonManager.addons.ForEach(f => f.onChannelMessage(sender, e));
 }
 /// <summary>
 /// Initializes the message
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 /// <param name="parameters">The parameters.</param>
 public override void Initialize(MessageReceivedEventArgs e, string[] parameters)
 {
     SenderClientId = e.InvokerClientId;
     ServerGroup = Repository.Settings.Control.SeenModerator.ServerGroup;
     ClientDatabaseIds = Repository.Client.GetClientsByServerGroup(Repository.Settings.Control.SeenModerator.ServerGroup);
 }
コード例 #21
0
 /// <summary>
 /// Initializes the message
 /// </summary>
 /// <param name="e">The <see cref="TS3QueryLib.Core.Server.Notification.EventArgs.MessageReceivedEventArgs"/> instance containing the event data.</param>
 /// <param name="parameters">The parameters.</param>
 public virtual void Initialize(MessageReceivedEventArgs e, string[] parameters)
 {
     SenderClientId = e.InvokerClientId;
 }
コード例 #22
0
        /// <summary>
        /// Validates the SelfGroupRemove message.
        /// </summary>
        /// <param name="e">The <see cref="MessageReceivedEventArgs" /> instance containing the event data.</param>
        protected void SelfGroupRemove(MessageReceivedEventArgs e)
        {
            if (!Repository.Settings.Control.SelfGroup.Enabled) return;
            if (Repository.Settings.Control.SelfGroup.AllowedServerGroups == null) return;

            if (MessageHelper.CanBeMessage<SelfGroupRemoveMessage>(e.Message) &&
                Repository.Client.GetClientInfo(e.InvokerClientId).ServerGroups
                    .Any(m => PermissionHelper.IsGranted(Repository.Settings.Control.SelfGroup, m)))
            {
                Execute(MessageHelper.GetMessageInformation<SelfGroupRemoveMessage>(e, e.Message));
            }
        }