示例#1
0
        /// <summary>
        /// Overrides Update from BaseClient to trigger advertising in intervals.
        /// </summary>
        public override void Update()
        {
            base.Update();

            // Try send an available WhoXQuery.
            if (WhoXQueryQueue.TryDequeue(out string command))
            {
                SendWhoXQuery(command);
            }

            if (IRCSendQueue.TryDequeue(out IrcMessage ircMessage))
            {
                IrcClient.SendMessage(ircMessage.Message, ircMessage.Name);
            }

            // execute the chatcommands - this is all which work in the 3d client also
            // like tell, say, broadcast - but also "dm", "getplayer" etc.
            while (ChatCommandQueue.TryDequeue(out command))
            {
                ExecChatCommand(command);
            }

            // these are admin textcommands without a prefix, just plain was written in adminconsole
            while (AdminCommandQueue.TryDequeue(out command))
            {
                SendReqAdminMessage(command);
            }
        }
示例#2
0
        /// <summary>
        /// Invoked when a private message was received.
        /// Private messages = admin console
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnLocalUserMessageReceived(object sender, IrcMessageEventArgs e)
        {
            // try get channeluser by name
            IrcChannelUser usr = GetChannelUser(e.Source.Name);

            if (usr == null)
            {
                return;
            }

            // only allow ADMINS from config
            if (!Config.Admins.Contains(e.Source.Name))
            {
                // respond user he can't use this feature
                IrcClient.LocalUser.SendMessage(
                    e.Source.Name,
                    e.Source.Name + " you can't use the admin console - Only admins allowed.");
                return;
            }

            // Must be registered.
            if (!IsUserRegistered(e.Source.Name))
            {
                // respond user he can't use this feature
                IrcClient.LocalUser.SendMessage(
                    e.Source.Name,
                    e.Source.Name + " you can't use the admin console - nickname must be registered.");
                return;
            }

            // invalid
            if (e.Text == null || e.Text == String.Empty)
            {
                return;
            }

            Log("ADM", e.Source.Name + " used the command " + e.Text);

            // Bot admin command?
            if (e.Text.StartsWith("@"))
            {
                // Returns false if nothing handled the admin command.
                if (!IRCAdminBotCommand.ParseAdminCommand(e.Source.Name, e.Text, this))
                {
                    IrcClient.LocalUser.SendMessage(e.Source.Name,
                                                    "Couldn't find a handler for admin command " + e.Text);
                }

                return;
            }

            // get first space in text
            int firstspace = e.Text.IndexOf(' ');

            // either use first part up to first space or full text if no space
            string comtype =
                (firstspace > 0) ? e.Text.Substring(0, firstspace) : comtype = e.Text;

            // check if commandtype is allowed
            if (Config.AdminCommands.Contains(comtype))
            {
                // Record this admin as recent.
                if (!RecentAdmins.Contains(e.Source.Name))
                {
                    RecentAdmins.Add(e.Source.Name);
                }
                // enqueue it for execution
                AdminCommandQueue.Enqueue(e.Text);
            }
            else
            {
                // respond admin he can't use this admincommand
                IrcClient.LocalUser.SendMessage(
                    e.Source.Name,
                    e.Source.Name + " you can't use the admin command '" + comtype + "'");
            }
        }