示例#1
0
        public override void OnCommand(BotShell bot, CommandArgs e)
        {
            switch (e.Command)
            {
            case "announce":
            case "mass":
                bool invite = (e.Command == "mass");
                if (e.Words.Length < 1)
                {
                    bot.SendReply(e, "Correct Usage: " + e.Command + " [message]");
                    return;
                }
                string message = e.Words[0].Trim();
                string group   = bot.Configuration.GetString(this._client.InternalName, "group", bot.Character);
                bot.SendReply(e, "Contacting the Vhanet announce system. Please stand by...");

                int           messageID;
                MessageResult messageResult;
                messageResult = bot.SendRemotePluginMessage(this.InternalName, "vhanet@rubika", "VhanetMassInviteHost", "announce", out messageID, group, bot.Character, e.Sender, message);

                if (messageResult != MessageResult.Success)
                {
                    bot.SendReply(e, "Unable to contact the Vhanet announce system. Return code was: " + HTML.CreateColorString(bot.ColorHeaderHex, messageResult.ToString()));
                    return;
                }
                ReplyMessage messageReply = bot.GetReplyMessage(messageID, 60000);
                if (messageReply == null)
                {
                    bot.SendReply(e, "Didn't receive a reply from the Vhanet announce system");
                    return;
                }
                string[] members = (string[])messageReply.Args[0];
                if (invite)
                {
                    List <string> massed = new List <string>();
                    foreach (string member in members)
                    {
                        if (!bot.PrivateChannel.IsOn(member))
                        {
                            bot.PrivateChannel.Invite(member);
                            massed.Add(member);
                        }
                    }
                    RichTextWindow window = new RichTextWindow(bot);
                    window.AppendTitle("Members");
                    window.AppendHighlight(string.Join(", ", massed.ToArray()));
                    bot.SendReply(e, "Sending out an mass invite to " + HTML.CreateColorString(bot.ColorHeaderHex, massed.Count.ToString()) + " members »» ", window);
                }
                break;
            }
        }