Ejemplo n.º 1
0
        public override bool onUserCommand(string Command, string[] args, UserMessageEvent ev)
        {
            User user = ev.sender;
            Console.WriteLine ("register command called!");

            if (args.Length < 3)
            {
                Console.WriteLine("wtf register fail?");
                nickserv.noticeUser(user, "Invalid syntax");
                return false;
            }
            else if (NickServ.getNickEntry(user) != null) {
                nickserv.noticeUser(user, Convert.ToChar(2) + "Error: This nickname is already registered.");
                return true;
            }
            registerAccount (user, args [1], args [2]);
            user.loggedIn = true;
            nickserv.noticeUser(user, Chars.bold + "You are now registered.");
            return true;
        }
Ejemplo n.º 2
0
        private void processCommand(UserMessageEvent ev)
        {
            Console.WriteLine ("processing user command");
            Console.WriteLine (UserCommands.Keys);

            string[] messageArray = ev.message.Split(' ');
            string command = messageArray [0].ToUpper();
            if (command == "HELP") {
                Help.showHelp (ev.sender);
            } else {
                if (UserCommands.ContainsKey (command)) {
                    Console.WriteLine ("executing command " + command);
                    bool success = UserCommands [command].onUserCommand (command, messageArray, ev);
                    if (!success) {
                        Console.WriteLine ("command failed!");
                        Help.showCommandHelp (ev.sender, command);
                    }
                }
            }
            Console.WriteLine ("command " + command);
        }
Ejemplo n.º 3
0
 public virtual void onUserMessageClient(UserMessageEvent ev)
 {
     Console.WriteLine ("user message client !");
     processCommand (ev);
 }
Ejemplo n.º 4
0
        public void parseLine(string line)
        {
            string[] lineArray = line.Split(' ');

            string lineStart = lineArray[0];
            if (lineStart == "PING")
            {
                Send("PONG " + lineArray[1]);
                if (burstComplete == false)
                {
                    Console.WriteLine("calling hook burst_Complete ===");
                    ModuleManager.callHook(Hooks.SERVER_BURST_END, null, null);
                    burstComplete = true;
                }
            }
            else if (lineArray[1].Length > 1)
            {
                switch (lineArray[1])
                {
                    case "QUIT":
                        {
                            string user_UID = lineArray[0].Remove(0, 1);
                            //check if user exists.
                            User user = getUserFromUID(user_UID);
                            if (user == null)
                            {
                                Console.WriteLine("Warning : A user that wasn't introduced quit!");
                                return;
                            }
                            //get rid of this user.
                            user = null;
                            Program.Users.Remove(user_UID);
                            //call plugins :o

                            break;
                        }
                    case "PART":
                        {
                            Channel channel = getChannelFromName(lineArray[2]);
                            if (channel == null)
                            {
                                Console.WriteLine("attempted to remove user from non-existant channel " + lineArray[2]);
                                return;
                            }
                            User user = getUserFromUID(lineArray[0].Remove(0, 1));
                            channel.removeFromChannel(user);

                            break;
                        }
                    case "SJOIN":
                        {
                            Channel channel = getChannelFromName(lineArray[3]);
                            if (channel == null)
                            {
                                channel = new Channel(lineArray[3], int.Parse(lineArray[2]));
                            }
                            //get the user..
                            Regex users = new Regex(@":(.*) SJOIN (.*):(.*)");
                            Match match = users.Match(line);
                            string[] userStringArray = match.Groups[3].Value.Split(' ');
                            foreach (string user in userStringArray)
                            {
                                string usr;
                                User u = null;
                                if (user.StartsWith("@") || user.StartsWith("+"))
                                {
                                    usr = user.Remove(0, 1);
                                    u = getUserFromUID(usr);
                                    switch (user.Substring(0, 1))
                                    {
                                        case "@":
                                            {
                                                channel.Ops.Add(usr, u);
                                                break;
                                            }
                                        case "+":
                                            {
                                                channel.Voices.Add(usr, u);
                                                break;
                                            }
                                    }
                                }
                                else
                                {
                                    usr = user;
                                    u = getUserFromUID(usr);
                                }

                                Console.WriteLine("created channel " + channel.name);
                                channel.addToChannel(u);
                            }
                            break;
                        }
                    case "UID":
                        {
                            //create new user
                            foreach (string lol in lineArray)
                            {
                                Console.WriteLine(": " + lol);
                            }
                            string user_nickname = lineArray[2];
                            string user_modes = lineArray[5];
                            string user_username = lineArray[6];
                            string user_host = lineArray[7];
                            string user_UID = lineArray[9];
                            string user_realname = lineArray[10].Remove(0, 1);
                            User newuser = new User(user_nickname, user_username, user_modes, user_host, user_realname, user_UID);
                            Console.WriteLine("Initiated new user " + newuser.nickname);
                            UserEvent ev = new UserEvent(newuser);
                            ModuleManager.callHook(Hooks.USER_CONNECT, null, ev);
                            ModuleManager.callHook(Hooks.USER_BURST_CONNECT, null, ev);
                            break;
                        }
                    case "PRIVMSG":
                        {
                            Console.WriteLine("OMG PRIVMSG!!");
                            User sender = getUserFromUID(lineArray[0].Remove(0, 1));
                            string dest = lineArray[2];
                            Client user = (Client)getUserFromUID(dest);
                            Console.WriteLine(dest);
                            Console.WriteLine(sender.nickname);
                            Channel channel = getChannelFromName(dest);
                            Regex text = new Regex(@":(.*) PRIVMSG (.*) :(.*)");
                            Match match = text.Match(line);
                            if (match.Success)
                            {
                                string message = match.Groups[3].Value;
                                Console.WriteLine(message);
                                if (user != null)
                                {
                                    UserMessageEvent ev = new UserMessageEvent(sender, user, message);
                                    ModuleManager.callHook(Hooks.USER_MESSAGE_CLIENT, user, ev);
                                }
                                else if (channel != null)
                                {

                                }
                                else
                                {
                                    Console.WriteLine("An unexpected shit happened at " + line);
                                }
                            }
                            break;
                        }
                    case "NICK":
                        {
                            string senderuid = lineArray[0].Remove(0, 1);
                            User user = getUserFromUID(senderuid);
                            string oldnick = user.nickname;
                            user.nickname = lineArray[2];
                            Console.WriteLine("changed " + user.nickname);
                            UserNickChangeEvent ev = new UserNickChangeEvent(user, oldnick, lineArray[2]);
                            Console.WriteLine("calling hook!");
                            ModuleManager.callHook(Hooks.USER_NICKCHANGE, null, ev);
                            break;
                        }
                    case "MODE":
                        {
                            string senderuid = lineArray[0].Remove(0, 1);
                            User user = getUserFromUID(senderuid);
                            user.modes = user.modes + lineArray[3].Remove(0, 1);
                            break;
                        }

                }
            }
        }
Ejemplo n.º 5
0
 public virtual bool onUserCommand(String Command, string[] args, UserMessageEvent ev)
 {
     return false;
 }
Ejemplo n.º 6
0
        public override void onUserMessageClient(UserMessageEvent ev)
        {
            User user = ev.sender;
            string message = ev.message;
            string[] messageArray = message.Split(' ');
            try
            {
                switch (messageArray[0].ToUpper())
                {
                    case "HELP":
                        {
                            Help.showHelp(user);
                            break;
                        }
                    case "SHUTDOWN":
                        {
                            if (user.modes.Contains('o'))
                            {
                                Protocol.protocolPlugin.Send("QUIT: bai bai");
                                Program.Shutdown();

                            }
                            else
                            {
                                os.noticeUser(user, "You do not have permission to perform this task.");
                                os.messageChannel(services, "NP " + Convert.ToChar(2) + user.nickname + "SHUTDOWN");
                            }
                            break;
                        }
                    case "RAW":
                        {
                            if (user.modes.Contains('o'))
                            {
                                string raw = message.Remove(0, 4).Replace(';', ':');
                                os.messageChannel(services, user.nickname + "RAW: " + raw);
                                Protocol.protocolPlugin.Send(raw);
                                //Protocol.protocolPlugin.Send(message.Remove(0,4));
                            }
                            else
                            {
                                os.noticeUser(user, "You do not have permission to perform this task.");
                                os.messageChannel(services, "NP " + Convert.ToChar(2) + user.nickname + "RAW");
                            }
                            break;
                        }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("FAIL " + e.ToString());
            }
        }
Ejemplo n.º 7
0
 public override void onUserMessageClient(UserMessageEvent ev)
 {
     base.onUserMessageClient (ev);
 }