示例#1
0
        bool cmdBounce(VPServices app, Avatar who, string data)
        {
            who.SetSetting(settingBounce, true);
            app.Bot.Avatars.Teleport(who.Session, app.World, who.Position);

            return Log.Info(Name, "Bounced user {0}", who.Name);
        }
        bool cmdMute(VPServices app, Avatar who, string target, bool muting)
        {
            // Mute IRC
            if (target == "")
            {
                who.SetSetting(settingMuteIRC, muting);
                app.Notify(who.Session, msgMuteIRC, muting ? "hidden from" : "shown to");
                return true;
            }

            // Reject invalid names
            if ( target.Contains(',') )
            {
                app.Warn(who.Session, "Cannot mute that name; commas not allowed");
                return true;
            }

            var muteList = who.GetSetting(settingMuteList);
            var muted    = ( muteList ?? "" ).TerseSplit(',').ToList();
            target       = target.ToLower();

            if (muting)
            {
                if ( muted.Contains(target) )
                {
                    app.Warn(who.Session, msgMuted, "already");
                    return true;
                }

                muted.Add(target);
                app.Notify(who.Session, msgMuteUser, target, "hidden");
            }
            else
            {
                if ( !muted.Contains(target) )
                {
                    app.Warn(who.Session, msgMuted, "not");
                    return true;
                }

                muted.Remove(target);
                app.Notify(who.Session, msgMuteUser, target, "shown");
            }

            muteList = string.Join(",", muted);
            who.SetSetting(settingMuteList, muteList);
            return true;
        }
示例#3
0
 void onLeave(Instance sender, Avatar who)
 {
     // Keep track of LastExit to prevent annoying users
     who.SetSetting(settingLastExit, DateTime.Now);
 }
示例#4
0
        bool cmdToggle(VPServices app, Avatar who, string data, string key)
        {
            string msg    = null;
            bool   toggle;

            if ( data != "" )
            {
                // Try to parse user given boolean; reject command on failure
                if ( !VPServices.TryParseBool(data, out toggle) )
                    return false;
            }
            else
                toggle = !who.GetSettingBool(key);

            who.SetSetting(key, toggle);
            switch (key)
            {
                case SettingGreetMe:
                    msg = toggle ? msgGreetMe : msgGreetMeNot;
                    break;

                case SettingShowGreets:
                    msg = toggle ? msgShowGreets : msgHideGreets;
                    break;
            }

            app.Notify(who.Session, msg);
            return Log.Debug(Name, "Toggled greet-me for {0} to {1}", who.Name, toggle);
        }
示例#5
0
 void initialHealth(Avatar who)
 {
     if (who.GetSettingInt(keyHealth) <= 0)
         who.SetSetting(keyHealth, 100);
 }
示例#6
0
        bool cmdTogglePVP(VPServices app, Avatar who, string data)
        {
            var  lastSwitch = who.GetSettingDateTime(keyLastSwitch);
            bool toggle     = false;

            // Reject if too soon
            if ( lastSwitch.SecondsToNow() < 60 )
            {
                var timeLeft = 60 - lastSwitch.SecondsToNow();
                app.Warn(who.Session, msgTooSoon, timeLeft);
                return true;
            }

            if ( data != "" )
            {
                // Try to parse user given boolean; silently ignore on failure
                if ( !VPServices.TryParseBool(data, out toggle) )
                    return false;
            }
            else
                toggle = !who.GetSettingBool(keyMode);

            // Set new boolean, timeout and if new, health
            who.SetSetting(keyMode, toggle);
            who.SetSetting(keyLastSwitch, DateTime.Now);
            initialHealth(who);

            var verb = toggle ? "enabled" : "disabled";
            app.NotifyAll(msgToggle, verb, who.Name);
            return true;
        }