Esempio n. 1
0
        static void Login(object sender, IRCCommandEventArgs e)
        {
            if (e.Length != 2)
            {
                TShockIRC.SendMessage(e.Target, "\u00035Invalid syntax! Proper syntax: " + TShockIRC.Config.BotPrefix + e[-1] + " <user> <password>");
                return;
            }

            User user = TShock.Users.GetUserByName(e[0]);

            if (user == null || e[0] == "")
            {
                TShockIRC.SendMessage(e.Target, "\u00035Invalid user.");
            }
            else
            {
                if (String.Equals(user.Password, TShock.Utils.HashPassword(e[1]), StringComparison.OrdinalIgnoreCase))
                {
                    TShockIRC.SendMessage(e.Target, "\u00033You have logged in as " + e[0] + ".");
                    TShockIRC.IrcUsers[(IrcUser)e.Sender] = TShock.Utils.GetGroup(user.Group);
                }
                else
                {
                    TShockIRC.SendMessage(e.Target, "\u00035Incorrect password!");
                }
            }
        }
Esempio n. 2
0
        static void Players(object sender, IRCCommandEventArgs e)
        {
            int    numPlayers = TShock.Players.Where(p => p != null && p.Active).Count();
            string players    = String.Join(", ", TShock.Players.Where(p => p != null && p.Active).Select(p => p.Name));

            if (numPlayers == 0)
            {
                TShockIRC.SendMessage(e.Target, "0 players currently on.");
            }
            else
            {
                TShockIRC.SendMessage(e.Target, numPlayers + " player(s) currently on:");
                TShockIRC.SendMessage(e.Target, players + ".");
            }
        }
Esempio n. 3
0
        public static void Execute(string str, IrcUser sender, IIrcMessageTarget target)
        {
            var args = new IRCCommandEventArgs(str, sender, target);

            string commandName = args[-1].ToLowerInvariant();
            if (TShockIRC.Config.IgnoredCommands.Contains(commandName))
                return;

            var ircCommand = Commands.FirstOrDefault(c => c.Names.Contains(commandName));
            var senderGroup = TShockIRC.IrcUsers[sender];
            if (ircCommand != null)
            {
                if (String.IsNullOrEmpty(ircCommand.Permission) || senderGroup.HasPermission(ircCommand.Permission))
                {
                    if (ircCommand.DoLog)
                        Log.Info("{0} executed: /{1}.", sender.NickName, str);
                    ircCommand.Execute(args);
                }
                else
                {
                    Log.Warn("{0} tried to execute /{1}.", sender.NickName, str);
                    TShockIRC.SendMessage(target, "\u00035You do not have access to this command.");
                }
            }
            else if (senderGroup.HasPermission("tshockirc.command"))
            {
                var tsIrcPlayer = new TSIrcPlayer(sender.NickName, senderGroup, target);
                var commands = TShockAPI.Commands.ChatCommands.Where(c => c.HasAlias(commandName));

                if (commands.Count() != 0)
                {
                    Main.rand = new Random();
                    WorldGen.genRand = new Random();
                    foreach (Command command in commands)
                    {
                        if (!command.CanRun(tsIrcPlayer))
                        {
                            Log.Warn("{0} tried to execute /{1}.", sender.NickName, str);
                            TShockIRC.SendMessage(target, "\u00035You do not have access to this command.");
                        }
                        else if (!command.AllowServer)
                            TShockIRC.SendMessage(target, "\u00035You must use this command in-game.");
                        else
                        {
                            var parms = args.ParameterRange(0, args.Length);
                            if (TShockAPI.Hooks.PlayerHooks.OnPlayerCommand(tsIrcPlayer, command.Name, str, parms, ref commands))
                                return;
                            if (command.DoLog)
                                Log.Info("{0} executed: /{1}.", sender.NickName, str);
                            command.Run(str, tsIrcPlayer, parms);
                        }
                    }
                }
                else
                    TShockIRC.SendMessage(target, "\u00035Invalid command.");
            }
            else
            {
                Log.Warn("{0} tried to execute /{1}.", sender.NickName, str);
                TShockIRC.SendMessage(target, "\u00035You do not have access to this command.");
            }
        }
Esempio n. 4
0
 static void Players(object sender, IRCCommandEventArgs e)
 {
     int numPlayers = TShock.Players.Where(p => p != null && p.Active).Count();
     string players = String.Join(", ", TShock.Players.Where(p => p != null && p.Active).Select(p => p.Name));
     if (numPlayers == 0)
         TShockIRC.SendMessage(e.Target, "0 players currently on.");
     else
     {
         TShockIRC.SendMessage(e.Target, numPlayers + " player(s) currently on:");
         TShockIRC.SendMessage(e.Target, players + ".");
     }
 }
Esempio n. 5
0
 static void Logout(object sender, IRCCommandEventArgs e)
 {
     TShockIRC.IrcUsers[(IrcUser)e.Sender] = TShock.Groups.GetGroupByName(TShock.Config.DefaultGuestGroupName);
     TShockIRC.SendMessage(e.Target, "\u00033You have logged out.");
 }
Esempio n. 6
0
        static void Login(object sender, IRCCommandEventArgs e)
        {
            if (e.Length != 2)
            {
                TShockIRC.SendMessage(e.Target, "\u00035Invalid syntax! Proper syntax: " + TShockIRC.Config.BotPrefix + e[-1] + " <user> <password>");
                return;
            }

            User user = TShock.Users.GetUserByName(e[0]);
            if (user == null || e[0] == "")
                TShockIRC.SendMessage(e.Target, "\u00035Invalid user.");
            else
            {
                if (String.Equals(user.Password, TShock.Utils.HashPassword(e[1]), StringComparison.OrdinalIgnoreCase))
                {
                    TShockIRC.SendMessage(e.Target, "\u00033You have logged in as " + e[0] + ".");
                    TShockIRC.IrcUsers[(IrcUser)e.Sender] = TShock.Utils.GetGroup(user.Group);
                }
                else
                    TShockIRC.SendMessage(e.Target, "\u00035Incorrect password!");
            }
        }
Esempio n. 7
0
 public void Execute(IRCCommandEventArgs e)
 {
     callback(this, e);
 }
Esempio n. 8
0
 static void Logout(object sender, IRCCommandEventArgs e)
 {
     TShockIRC.IrcUsers[(IrcUser)e.Sender] = TShock.Groups.GetGroupByName(TShock.Config.DefaultGuestGroupName);
     TShockIRC.SendMessage(e.Target, "\u00033You have logged out.");
 }
Esempio n. 9
0
        public static void Execute(string str, IrcUser sender, IIrcMessageTarget target)
        {
            var args = new IRCCommandEventArgs(str, sender, target);

            string commandName = args[-1].ToLowerInvariant();

            if (TShockIRC.Config.IgnoredCommands.Contains(commandName))
            {
                return;
            }

            var ircCommand  = Commands.FirstOrDefault(c => c.Names.Contains(commandName));
            var senderGroup = TShockIRC.IrcUsers[sender];

            if (ircCommand != null)
            {
                if (String.IsNullOrEmpty(ircCommand.Permission) || senderGroup.HasPermission(ircCommand.Permission))
                {
                    if (ircCommand.DoLog)
                    {
                        Log.Info("{0} executed: /{1}.", sender.NickName, str);
                    }
                    ircCommand.Execute(args);
                }
                else
                {
                    Log.Warn("{0} tried to execute /{1}.", sender.NickName, str);
                    TShockIRC.SendMessage(target, "\u00035You do not have access to this command.");
                }
            }
            else if (senderGroup.HasPermission("tshockirc.command"))
            {
                var tsIrcPlayer = new TSIrcPlayer(sender.NickName, senderGroup, target);
                var commands    = TShockAPI.Commands.ChatCommands.Where(c => c.HasAlias(commandName));

                if (commands.Count() != 0)
                {
                    Main.rand        = new Random();
                    WorldGen.genRand = new Random();
                    foreach (Command command in commands)
                    {
                        if (!command.CanRun(tsIrcPlayer))
                        {
                            Log.Warn("{0} tried to execute /{1}.", sender.NickName, str);
                            TShockIRC.SendMessage(target, "\u00035You do not have access to this command.");
                        }
                        else if (!command.AllowServer)
                        {
                            TShockIRC.SendMessage(target, "\u00035You must use this command in-game.");
                        }
                        else
                        {
                            var parms = args.ParameterRange(0, args.Length);
                            if (TShockAPI.Hooks.PlayerHooks.OnPlayerCommand(tsIrcPlayer, command.Name, str, parms, ref commands))
                            {
                                return;
                            }
                            if (command.DoLog)
                            {
                                Log.Info("{0} executed: /{1}.", sender.NickName, str);
                            }
                            command.Run(str, tsIrcPlayer, parms);
                        }
                    }
                }
                else
                {
                    TShockIRC.SendMessage(target, "\u00035Invalid command.");
                }
            }
            else
            {
                Log.Warn("{0} tried to execute /{1}.", sender.NickName, str);
                TShockIRC.SendMessage(target, "\u00035You do not have access to this command.");
            }
        }
Esempio n. 10
0
 public void Execute(IRCCommandEventArgs e)
 {
     callback(this, e);
 }