예제 #1
0
 public virtual void onUserIdentifyFail(UserEvent ev)
 {
 }
예제 #2
0
 public virtual void onUserConnect(UserEvent ev)
 {
 }
예제 #3
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;
                        }

                }
            }
        }
예제 #4
0
파일: OperServ.cs 프로젝트: ttwj/dreamskape
 public override void onUserIdentifyFail(UserEvent ev)
 {
     User user = ev.user;
     Console.WriteLine("blah blah blah");
     ns.messageChannel(services, Convert.ToChar(2) + user.loginAttempts + Convert.ToChar(2) + " failed login attempts by " + Convert.ToChar(2) + user.nickname + Convert.ToChar(2));
 }
예제 #5
0
파일: OperServ.cs 프로젝트: ttwj/dreamskape
 public override void onUserIdentify(UserEvent ev)
 {
     User user = ev.user;
     ns.messageChannel(services, "Sucessful login by " + Convert.ToChar(2) + user.nickname + Convert.ToChar(2));
 }
예제 #6
0
파일: OperServ.cs 프로젝트: ttwj/dreamskape
 public override void onUserConnect(UserEvent ev)
 {
     User user = ev.user;
     os.messageChannel(services, Convert.ToChar(2) + user.nickname + "(" + user.UID + ")" + Convert.ToChar(2) + " has connected");
 }