示例#1
0
 public override void onServerBurstEnd()
 {
     services = getChannelFromName(channel);
     if (services == null)
     {
         services = new Channel(channel, getTimeStamp());
     }
     foreach (KeyValuePair<string, Client> c in Program.Clients)
     {
         c.Value.joinChannelMode(services, c.Value, "+o");
         if (c.Value.nickname.ToLower() == "nickserv")
         {
             ns = c.Value;
         }
     }
 }
示例#2
0
 public override void joinChannelMode(Client client, Channel channel, string modes)
 {
     Send(":" + SID + " SJOIN " + channel.TS + " " + channel.name + " " + modes + " :" + client.UID);
 }
示例#3
0
 public override void chanMode(Client sender, Channel channel, User dest, string modes)
 {
     Send(":" + sender.UID + " TMODE " + getTimeStamp() + " " + channel.name + " " + modes + " " + dest.UID);
 }
示例#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;
                        }

                }
            }
        }
示例#5
0
 public override void noticeChannel(Client sender, Channel channel, string message)
 {
     Send(":" + sender.UID + " NOTICE " + channel.name + " :" + message);
 }
示例#6
0
 public virtual void joinChannelMode(Client client, Channel channel, User dest, string modes)
 {
 }
示例#7
0
文件: Client.cs 项目: ttwj/dreamskape
 public void modeChannel(Channel channel, User dest, string mode)
 {
     Protocol.protocolPlugin.chanMode(this, channel, dest, mode);
 }
示例#8
0
文件: Client.cs 项目: ttwj/dreamskape
 public void kickUser(User kickee, Channel chan, string reason = "Kicked by dreamskape")
 {
     Protocol.protocolPlugin.kickUser(this, kickee, chan, reason);
 }
示例#9
0
 public override void joinChannelMode(Client client, Channel channel, User dest, string modes)
 {
     if (modes.StartsWith("+"))
     {
         if (modes.Contains('o'))
         {
             Send("SJOIN " + channel.TS + " " + channel.name + " + :@" + client.UID);
         }
         else if (modes.Contains('v'))
         {
             Send("SJOIN " + channel.TS + " " + channel.name + " + :+" + client.UID);
         }
     }
     else
     {
         Send(":" + client.UID + " TMODE " + getTimeStamp() + " " + channel.name + " " + modes + " " + dest.UID);
     }
 }
示例#10
0
 public ChannelManager(Channel channel, ModulePlugin plugin)
 {
     this.channel = channel;
     this.plugin = plugin;
 }
示例#11
0
 public ChannelMessageEvent(User user, string message, Channel channel)
 {
     this.message = message;
     this.channel = channel;
 }
示例#12
0
 public virtual void chanMode(Client sender, Channel channel, string modes)
 {
 }
示例#13
0
 public virtual void noticeChannel(Client sender, Channel channel, string message)
 {
 }
示例#14
0
 public virtual void kickUser(Client kicker, User kickee, Channel channel, string reason = null)
 {
 }
示例#15
0
 public virtual void joinUser(User joinee, Channel channel)
 {
 }
示例#16
0
文件: Client.cs 项目: ttwj/dreamskape
 public void joinChannel(Channel chan)
 {
     Protocol.protocolPlugin.joinUser(this, chan);
 }
示例#17
0
文件: Client.cs 项目: ttwj/dreamskape
 public void joinChannelMode(Channel channel, User dest, string mode)
 {
     Protocol.protocolPlugin.joinChannelMode(this, channel, dest, mode);
 }
示例#18
0
 public override void joinUser(User joinee, Channel channel)
 {
     Send(":" + SID + " SJOIN " + getTimeStamp() + " " + channel.name + " + :" + joinee.UID);
 }
示例#19
0
文件: Client.cs 项目: ttwj/dreamskape
 public void messageChannel(Channel channel, string message = "hi")
 {
     Protocol.protocolPlugin.msgChannel(this, channel, message);
 }
示例#20
0
 public override void kickUser(Client kicker, User kickee, Channel channel, string reason = null)
 {
     Send(":" + kicker.UID + " KICK " + channel.name + " " + kickee.UID + " :" + reason);
 }
示例#21
0
 public virtual void onServerBurstEnd()
 {
     Services = getChannelFromName("#services");
     if (Services == null)
     {
         Services = new Channel("#services", getTimeStamp());
     }
 }
示例#22
0
 public override void msgChannel(Client sender, Channel channel, string message)
 {
     Console.WriteLine(":" + sender.UID + " PRIVMSG " + channel.name + " :" + message);
     Send(":" + sender.UID + " PRIVMSG " + channel.name + " :" + message);
 }