コード例 #1
0
ファイル: Join.cs プロジェクト: FreeApophis/ircddotnet
        protected override void PrivateHandle(UserInfo info, List<string> args)
        {
            if (args[0] == "0")
            {
                PartAll(info);
                return;
            }

            foreach (var channel in from temp in GetSubArgument(args[0])
                                    where info.UserPerChannelInfos.All(upci => upci.ChannelInfo.Name != temp)
                                    select temp)
            {
                ChannelInfo chan;

                if (IrcDaemon.Channels.ContainsKey(channel))
                {
                    chan = IrcDaemon.Channels[channel];

                    if (!chan.Modes.HandleEvent(this, chan, info, args))
                    {
                        continue;
                    }
                }
                else
                {
                    if (IrcDaemon.ValidChannel(channel))
                    {
                        chan = new ChannelInfo(channel, IrcDaemon);
                        IrcDaemon.Channels.Add(chan.Name, chan);
                    }
                    else
                    {
                        IrcDaemon.Replies.SendBadChannelMask(info, channel);
                        return;
                    }
                }

                var chanuser = new UserPerChannelInfo(info, chan);

                // ToDo: this probably should get delegated to the Channel Type specific "NormalChannel" class, because it depends on the channel type.
                if (!chan.Users.Any())
                {
                    chanuser.Modes.Add(IrcDaemon.ModeFactory.GetChannelRank('o'));
                }

                chan.UserPerChannelInfos.Add(info.Nick, chanuser);
                info.UserPerChannelInfos.Add(chanuser);
                Send(new JoinArgument(info, chan, chan));
                SendTopic(info, chan);
                IrcDaemon.Replies.SendNamesReply(chanuser.UserInfo, chan);
                IrcDaemon.Replies.SendEndOfNamesReply(info, chan);
            }
        }
コード例 #2
0
ファイル: ServerReplies.cs プロジェクト: autocar/ircddotnet
        /// <summary>
        /// Reply Code 352
        /// </summary>
        /// <param name="info"></param>
        /// <param name="who"></param>
        public void SendWhoReply(UserInfo info, UserPerChannelInfo who)
        {
            BuildMessageHeader(info, ReplyCode.WhoReply);

            response.Append(" ");
            response.Append(who.ChannelInfo.Name);
            response.Append(" ");
            response.Append(who.UserInfo.User);
            response.Append(" ");
            response.Append(who.UserInfo.Host);
            response.Append(" ");

            // TODO Server to Server
            response.Append(ircDaemon.Options.ServerName);
            response.Append(" ");
            response.Append(who.UserInfo.Nick);
            response.Append(" ");
            response.Append(who.UserInfo.Modes.Exist<ModeAway>() ? "G" : "H");
            response.Append(who.UserInfo.Modes.Exist<ModeOperator>() || who.UserInfo.Modes.Exist<ModeLocalOperator>() ? "*" : string.Empty);
            response.Append(who.Modes.NickPrefix);
            response.Append(" :");

            // TODO: Server to Server
            //response.Append(who.Server.Hops);
            response.Append(0);
            response.Append(" ");
            response.Append(who.UserInfo.RealName);

            //TODO: append d if deaf - add Deaf (such as Mode X / W on undernet)

            info.WriteLine(response);
        }