Exemple #1
0
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "Home: Set", "^sethome$", cmdSetHome,
                    @"Sets user's home position, where they will be teleported to every time they enter the world",
                    @"!sethome"
                ),

                new Command
                (
                    "Home: Teleport", "^home$", cmdGoHome,
                    @"Teleports user to their home position, or ground zero if unset",
                    @"!home"
                ),

                new Command
                (
                    "Home: Clear", "^clearhome$", cmdClearHome,
                    @"Clears user's home position",
                    @"!clearhome"
                ),

                new Command
                (
                    "Teleport: Bounce", "^bounce$", cmdBounce,
                    @"Disconnects and reconnects user to the world; useful for clearing the download queue and fixing some issues",
                    @"!bounce"
                ),
            });

            bot.Avatars.Enter += onEnter;
        }
Exemple #2
0
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "Facts: Add", "^(addfact|af|define)$", cmdAddFact,
                    @"Adds or overwrites a factoid for a topic, allowing it to be locked or alias another topic",
                    @"!addfact [--lock] `topic: [what|@alias]`"
                ),

                new Command
                (
                    "Facts: Delete", "^(del(ete)?fact|df)$", cmdDeleteFact,
                    @"Clears a factoid for a topic",
                    @"!delfact `topic`"
                ),

                new Command
                (
                    "Facts: Get", "^(what(is)?|explain|fact)$", cmdGetFact,
                    @"Explains a given topic",
                    "!what `topic`"
                ),
            });

            app.Routes.Add(new WebRoute("Facts", "^(list)?facts?$", webListFacts,
                @"Provides a list of defined facts"));

            this.connection = app.Connection;
        }
Exemple #3
0
 public void onAvatarLeave(Instance sender, Avatar avatar)
 {
     // Write to log
     userStream.WriteLine("leave,{0},{1}",
         avatar.Name,
         (int)DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
 }
Exemple #4
0
 public void Init(VPServices app, Instance bot)
 {
     bot.Property.ObjectCreate += onObjChange;
     bot.Property.ObjectChange += onObjChange;
     bot.Avatars.Enter += onAvatarEnter;
     bot.Avatars.Leave += onAvatarLeave;
 }
        public void Init(VPServices app, Instance bot)
        {
            this.app = app;

            app.Commands.AddRange( new[] {
                new Command
                (
                    "Swordfight: Toggle", "^swordfight", cmdTogglePVP,
                    @"Toggles or sets swordfighting (PVP) mode for you",
                    @"!swordfight `[true|false]`"
                ),

                new Command
                (
                    "Swordfight: Punchbag", "^punchbag", cmdPunchbag,
                    @"Brings me to user's location to practise swordfighting",
                    @"!punchbag", 5
                ),

                new Command
                (
                    "Swordfight: Health", "^health", cmdHealth,
                    @"Notifys the user of their health",
                    @"!health"
                )
            });

            app.Bot.Property.CallbackObjectCreate += onCreate;
            app.Bot.Avatars.Clicked               += onClick;
            app.AvatarEnter                       += onEnter;
        }
Exemple #6
0
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "IRC: Connect", "^irc(start|connect)$",
                    (s,a,d) => { return connect(); },
                    @"Starts the IRC-VP bridge", "!ircstart", 60
                ),

                new Command
                (
                    "IRC: Disconnect", "^irc(end|disconnect)$",
                    (s,a,d) => { return disconnect(); },
                    @"Stops the IRC-VP bridge", "!ircend", 60
                )
            });

            config = app.Settings.Configs["IRC"] ?? app.Settings.Configs.Add("IRC");

            this.app  = app;
            host      = config.Get("Server", "irc.ablivion.net");
            port      = config.GetInt("Port", 6667);
            channel   = config.Get("Channel", "#vp");
            bot.Chat += onWorldChat;

            if (config.GetBoolean("Autoconnect", false))
                connect();
        }
Exemple #7
0
        public void Init(VPServices app, Instance bot)
        {
            bot.Data.GetWorldSetting += onWorldSetting;

            app.Routes.Add(new WebRoute("WorldSettings", "^worldsettings?$", webWorldSettings,
                @"Provides a key-value list of the settings of the bot's world"));
        }
        void onAvatarsChange(Instance sender, Avatar avatar)
        {
            var user = GetUser(avatar.Session);
            user.Position = avatar.Position;

            if ( AvatarChange != null )
                AvatarChange(sender, avatar);
        }
Exemple #9
0
 public InstanceData(Instance instance)
 {
     this.instance = instance;
     instance.SetNativeEvent(Events.WorldList, OnWorldList);
     instance.SetNativeEvent(Events.WorldSetting, OnWorldSetting);
     instance.SetNativeEvent(Events.WorldSettingsChanged, OnWorldSettingsChanged);
     instance.SetNativeEvent(Events.UserAttributes, OnUserAttributes);
 }
Exemple #10
0
 public InstanceAvatars(Instance instance)
 {
     this.instance = instance;
     instance.SetNativeEvent(Events.AvatarAdd, OnAvatarAdd);
     instance.SetNativeEvent(Events.AvatarChange, OnAvatarChange);
     instance.SetNativeEvent(Events.AvatarDelete, OnAvatarDelete);
     instance.SetNativeEvent(Events.AvatarClick, OnAvatarClicked);
 }
Exemple #11
0
 //TODO: unix epoch constant
 void onObjChange(Instance sender, int sessionId, VPObject o)
 {
     buildStream.WriteLine("{0},{1},{2},{3}",
         Math.Round(o.Position.X, 3),
         Math.Round(o.Position.Y, 2),
         Math.Round(o.Position.Z, 3),
         (int)DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
 }
        void onChat(Instance sender, ChatMessage chat)
        {
            var user = GetUser(chat.Session);
            if ( user == null )
                return;

            if (Chat != null)
                Chat(sender, user, chat.Message);
        }
        void onWorldDisconnect(Instance sender)
        {
            Log.Warn("Network", "Disconnected from world! Reconnecting...");

            lock (SyncMutex)
                Users.Clear();

            ConnectToWorld();
        }
        void onUniverseDisconnect(Instance sender)
        {
            Log.Warn("Network", "Disconnected from universe! Reconnecting...");

            lock (SyncMutex)
                Users.Clear();

            ConnectToUniverse();
        }
Exemple #15
0
        public override void main()
        {
            Console.WriteLine("Creating new instance, connecting and entering");
            bot = new Instance("VP Bot")
                .Login(VPNetExamples.Username, VPNetExamples.Password)
                .Enter(VPNetExamples.World);

            bot.Say("!bounce");
            bot.Wait(0);
        }
Exemple #16
0
        public void Init(VPServices app, Instance bot)
        {
            bot.Property.ObjectCreate += (s,i,o) => { objectEvent(o, sqlBuildType.Create); };
            bot.Property.ObjectChange += (s,i,o) => { objectEvent(o, sqlBuildType.Modify); };
            bot.Property.ObjectDelete += onObjDelete;
            app.AvatarEnter           += (s,a) => { userEvent(a, sqlUserType.Enter); };
            app.AvatarLeave           += (s,a) => { userEvent(a, sqlUserType.Leave); };

            this.connection = app.Connection;
        }
        void onAvatarAdd(Instance sender, Avatar avatar)
        {
            TConsole.WriteLineColored(ConsoleColor.Cyan, "*** {0} [SID#{1}] enters", avatar.Name, avatar.Session);

            lock (SyncMutex)
                Users.Add(avatar);

            if ( AvatarEnter != null )
                AvatarEnter(sender, avatar);
        }
        void onAvatarLeave(Instance sender, Avatar avatar)
        {
            TConsole.WriteLineColored(ConsoleColor.Cyan, "*** {0} [SID#{1}] leaves", avatar.Name, avatar.Session);

            var user = GetUser(avatar.Session);
            if ( AvatarLeave != null )
                AvatarLeave(sender, avatar);

            lock (SyncMutex)
                Users.Remove(user);
        }
Exemple #19
0
        public override void main()
        {
            Console.WriteLine("Creating new instance, connecting and entering");
            bot = new Instance("VP Bot")
                .Login(VPNetExamples.Username, VPNetExamples.Password)
                .Enter(VPNetExamples.World);

            Console.WriteLine("Saying hello");
            bot.GoTo();
            bot.Say("Hello world!");
            bot.Wait(1000);
        }
Exemple #20
0
        public InstanceProperty(Instance instance)
        {
            this.instance = instance;
            instance.SetNativeEvent(Events.Object, OnObjectCreate);
            instance.SetNativeEvent(Events.ObjectChange, OnObjectChange);
            instance.SetNativeEvent(Events.ObjectDelete, OnObjectDelete);
            instance.SetNativeEvent(Events.ObjectClick, OnObjectClick);
            instance.SetNativeEvent(Events.QueryCellEnd, OnQueryCellEnd);

            instance.SetNativeCallback(Callbacks.ObjectAdd, OnObjectCreateCallback);
            instance.SetNativeCallback(Callbacks.ObjectChange, OnObjectChangeCallback);
            instance.SetNativeCallback(Callbacks.ObjectDelete, OnObjectDeleteCallback);
        }
Exemple #21
0
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "Services: RKill", "^rkill$", cmdRKill,
                    @"Kills a Services bot by name; restricted to set users",
                    @"!rkill `name`"
                ),
            });

            config = app.Settings.Configs["RKill"] ?? app.Settings.AddConfig("RKill");
        }
Exemple #22
0
 void onObjDelete(Instance sender, int sessionId, int objectId)
 {
     lock (VPServices.App.DataMutex)
         connection.Insert( new sqlBuildHistory
         {
             ID   = objectId,
             X    = 0,
             Y    = 0,
             Z    = 0,
             Type = sqlBuildType.Delete,
             When = TDateTime.UnixTimestamp
         });
 }
        void onWorldChat(Instance sender, Avatar user, string message)
        {
            // No chat if not connected
            if (!irc.IsConnected)
                return;

            var msgRoll = message.TerseSplit("\n");

            foreach (var msg in msgRoll)
                if ( msg.StartsWith("/me ") )
                    irc.SendMessage(SendType.Action, config.Channel, user.Name + " " + msg.Substring(4) );
                else
                    irc.SendMessage(SendType.Message, config.Channel, user.Name + ": " +  msg );
        }
Exemple #24
0
        public override void main()
        {
            Console.WriteLine("Creating new instance, connecting and entering");
            bot = new Instance("VP Bot")
                .Login(VPNetExamples.Username, VPNetExamples.Password)
                .Enter(VPNetExamples.World);

            bot.Property.ObjectClick += Property_ObjectClick;
            bot.GoTo();

            while (true)
                bot.Wait(100);

            bot.Property.ObjectClick -= Property_ObjectClick;
        }
Exemple #25
0
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "History: Go back", "^(ba?ck|prev)$", cmdDeprecated,
                    @"DEPRECATED; please use VP 0.3.34 for teleport history"
                ),

                new Command
                (
                    "History: Go forward", "^(forward|fwd)$", cmdDeprecated,
                    @"DEPRECATED; please use VP 0.3.34 for teleport history"
                ),
            });
        }
        void onWorldLeave(Instance sender, Avatar avatar)
        {
            if (!irc.IsConnected)
                return;

            // No greetings within 10 seconds of bot load, to prevent flooding of entries
            // on initial user list load
            if ( VPServices.App.LastConnect.SecondsToNow() < 10 )
                return;

            // Reject for those who have greetme off
            var greets = app.GetService<Greetings>();
            if ( greets != null && !greets.CanGreet(avatar) )
                return;

            var msg = msgPart.LFormat(avatar.Name, VPServices.App.World);
            irc.SendMessage(SendType.Action, config.Channel, msg);
        }
Exemple #27
0
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "Todo: Add", "^(addtodo|atd|todoadd)$", cmdAddTodo,
                    @"Adds an attributed and timestamped todo entry",
                    @"!todoadd `entry`"
                ),

                new Command
                (
                    "Todo: Finish", "^(tododone|finishtodo)$", cmdFinishTodo,
                    @"Marks a single or multiple todo entries as finished",
                    @"!tododone `id[, id, [...]]`"
                ),

                new Command
                (
                    "Todo: Delete", "^(tododel(ete)?|deltodo|dtd)$", cmdDeleteTodo,
                    @"Deletes a single or multiple todo entries",
                    @"!tododel `id[, id, [...]]`"
                ),

                new Command
                (
                    "Todo: List", "^(listtodos?|ltd|todolist)$", cmdListTodo,
                    @"Prints the URL to the todo list to chat or lists those matching a search term to you",
                    @"!todolist `[search]`"
                ),

                new Command
                (
                    "Todo: Get random", "^todo$", cmdGetTodo,
                    @"Spins the todo wheel and gives you a random unfinished todo",
                    "!todo"
                ),
            });

            app.Routes.Add(new WebRoute("Todo", "^(list)?todos?$", webListTodos,
                @"Provides a list of todo entries"));

            this.connection = app.Connection;
        }
        void onWorldConsole(Instance sender, ConsoleMessage console)
        {
            // No chat if not connected
            if (!irc.IsConnected)
                return;

            // Ignore nameless consoles
            if ( string.IsNullOrWhiteSpace(console.Name) )
                return;

            // Ignore Services bot messages
            if (console.Name == sender.Name)
                return;

            var msgRoll = console.Message.TerseSplit("\n");

            foreach (var msg in msgRoll)
                irc.SendMessage(SendType.Message, config.Channel, "C* " + console.Name + " " +  msg );
        }
Exemple #29
0
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "Greetings: Show/hide", "^greet(ing)?s?$", (o,e,a) => { return cmdToggle(o,e,a, settingShowGreets); },
                    @"Toggles or sets whether or not the bot sends you user entry/exit messages",
                    @"!greets `[true|false]`"
                ),

                new Command
                (
                    "Greetings: Greet me", "^greetme$", (o,e,a) => { return cmdToggle(o,e,a, settingGreetMe); },
                    @"Toggles or sets whether or not the bot should announce your entry and exit to other users",
                    @"!greetme `[true|false]`"
                ),
            });

            bot.Avatars.Enter += (b,a) => { doGreet(b, a, true);  };
            bot.Avatars.Leave += (b,a) => { doGreet(b, a, false); };
        }
        public void Init(VPServices app, Instance bot)
        {
            app.Commands.AddRange(new[] {
                new Command
                (
                    "IRC: Connect", "^irc(start|connect)$", cmdIRCConnect,
                    @"Starts the IRC-VP bridge", "!ircstart"
                ),

                new Command
                (
                    "IRC: Disconnect", "^irc(end|disconnect)$", cmdIRCDisconnect,
                    @"Stops the IRC-VP bridge", "!ircend"
                ),

                new Command
                (
                    "IRC: Mute", "^ircmute$",
                    (s, w, d) => { return cmdMute(s, w, d, true); },
                    @"Mutes specific user or all of IRC for you", "!ircmute `[target]`"
                ),

                new Command
                (
                    "IRC: Unmute", "^ircunmute$",
                    (s, w, d) => { return cmdMute(s, w, d, false); },
                    @"Unmutes specific user or all of IRC for you", "!ircunmute `[target]`"
                ),
            });

            setupEvents(app);
            loadSettings(app);
            this.app = app;

            // Auto-connect IRC asynchronously if set
            if ( config.AutoConnect )
                Task.Factory.StartNew(() => { connect(app); });
        }