Example #1
0
 private IrcGroupPersonModel CreateGroupPerson(string nick)
 {
     var person = new IrcGroupPersonModel(nick, NetworkID, this);
     if (_IrcClient.IsMe(nick)) {
         person.IdentityNameColored.ForegroundColor = IrcTextColor.Blue;
         person.IdentityNameColored.BackgroundColor = TextColor.None;
         person.IdentityNameColored.Bold = true;
     }
     return person;
 }
Example #2
0
        private void _OnNames(object sender, NamesEventArgs e)
        {
            #if LOG4NET
            _Logger.Debug("_OnNames() e.Channel: " + e.Channel);
            #endif
            GroupChatModel groupChat = (GroupChatModel) GetChat(e.Data.Channel, ChatType.Group);
            if (groupChat.IsSynced) {
                // nothing todo for us
                return;
            }

            // would be nice if SmartIrc4net would take care of removing prefixes
            foreach (string user in e.UserList) {
                // skip empty users (some IRC servers send an extra space)
                if (user.TrimEnd(' ').Length == 0) {
                    continue;
                }
                string username = user;

                switch (user[0]) {
                    case '@':
                    case '+':
                    // RFC VIOLATION
                    // some IRC network do this and break our nice smuxi...
                    case '&':
                    case '%':
                    case '~':
                        username = user.Substring(1);
                        break;
                }

                IrcGroupPersonModel groupPerson = new IrcGroupPersonModel(username,
                                                                     NetworkID,
                                                                     this);

                groupChat.UnsafePersons.Add(groupPerson.NickName.ToLower(), groupPerson);
            #if LOG4NET
                _Logger.Debug("_OnNames() added user: "******" to: " + groupChat.Name);
            #endif
            }
        }
Example #3
0
        private void _OnNickChange(object sender, NickChangeEventArgs e)
        {
            #if LOG4NET
            _Logger.Debug("_OnNickChange() e.OldNickname: "+e.OldNickname+" e.NewNickname: "+e.NewNickname);
            #endif
            if (e.Data.Irc.IsMe(e.NewNickname)) {
                MessageModel msg = new MessageModel();
                msg.MessageType = MessageType.Event;
                TextMessagePartModel textMsg;

                textMsg = new TextMessagePartModel();
                textMsg.Text = "-!- " + String.Format(
                                            _("You're now known as {0}"),
                                            String.Empty);
                msg.MessageParts.Add(textMsg);

                textMsg = new TextMessagePartModel();
                textMsg.Text = e.NewNickname;
                textMsg.Bold = true;
                textMsg.ForegroundColor = GetNickColor(e.NewNickname);
                msg.MessageParts.Add(textMsg);

                Session.AddMessageToChat(_NetworkChat, msg);
            }

            IrcUser ircuser = e.Data.Irc.GetIrcUser(e.NewNickname);
            if (ircuser != null) {
                foreach (string channel in ircuser.JoinedChannels) {
                    GroupChatModel cchat = (GroupChatModel)GetChat(channel, ChatType.Group);

                    // clone the old user to a new user
                    IrcGroupPersonModel olduser = (IrcGroupPersonModel) cchat.GetPerson(e.OldNickname);
                    if (olduser == null) {
            #if LOG4NET
                        _Logger.Error("cchat.GetPerson(e.OldNickname) returned null! cchat.Name: "+cchat.Name+" e.OldNickname: "+e.OldNickname);
            #endif
                        continue;
                    }
                    IrcGroupPersonModel newuser = new IrcGroupPersonModel(
                                                        e.NewNickname,
                                                        NetworkID,
                                                        this);
                    newuser.RealName = olduser.RealName;
                    newuser.Ident = olduser.Ident;
                    newuser.Host = olduser.Host;
                    newuser.IsOp = olduser.IsOp;
                    newuser.IsVoice = olduser.IsVoice;

                    Session.UpdatePersonInGroupChat(cchat, olduser, newuser);

                    if (e.Data.Irc.IsMe(e.NewNickname)) {
                        MessageModel msg = new MessageModel();
                        msg.MessageType = MessageType.Event;
                        TextMessagePartModel textMsg;

                        textMsg = new TextMessagePartModel();
                        textMsg.Text = "-!- " + String.Format(
                                                    _("You're now known as {0}"),
                                                    String.Empty);
                        msg.MessageParts.Add(textMsg);

                        textMsg = new TextMessagePartModel();
                        textMsg.Text = e.NewNickname;
                        textMsg.Bold = true;
                        textMsg.ForegroundColor = GetNickColor(e.NewNickname);
                        msg.MessageParts.Add(textMsg);

                        Session.AddMessageToChat(cchat, msg);
                    } else {
                        MessageModel msg = new MessageModel();
                        msg.MessageType = MessageType.Event;
                        TextMessagePartModel textMsg;

                        textMsg = new TextMessagePartModel();
                        textMsg.Text = "-!- ";
                        msg.MessageParts.Add(textMsg);

                        textMsg = new TextMessagePartModel();
                        textMsg.Text = e.OldNickname;
                        textMsg.ForegroundColor = GetNickColor(e.OldNickname);
                        msg.MessageParts.Add(textMsg);

                        textMsg = new TextMessagePartModel();
                        textMsg.Text = String.Format(
                                            _("{0} is now known as {1}"),
                                            String.Empty,
                                            String.Empty);
                        msg.MessageParts.Add(textMsg);

                        textMsg = new TextMessagePartModel();
                        textMsg.Text = e.NewNickname;
                        textMsg.ForegroundColor = GetNickColor(e.NewNickname);
                        msg.MessageParts.Add(textMsg);

                        Session.AddMessageToChat(cchat, msg);
                    }
                }
            }
        }
Example #4
0
        private void _OnJoin(object sender, JoinEventArgs e)
        {
            GroupChatModel groupChat = (GroupChatModel) GetChat(e.Channel, ChatType.Group);
            if (e.Data.Irc.IsMe(e.Who)) {
                if (groupChat == null) {
                    groupChat = new GroupChatModel(e.Channel, e.Channel, this);
                    Session.AddChat(groupChat);
                } else {
                    // chat still exists, so we we only need to enable it
                    // (sync is done in _OnChannelActiveSynced)
                    Session.EnableChat(groupChat);
                }
            } else {
                // someone else joined, let's add him to the channel chat
                IrcUser siuser = _IrcClient.GetIrcUser(e.Who);
                IrcGroupPersonModel icuser = new IrcGroupPersonModel(e.Who,
                                                                     NetworkID,
                                                                     this);
                icuser.Ident = siuser.Ident;
                icuser.Host = siuser.Host;
                groupChat.UnsafePersons.Add(icuser.NickName.ToLower(), icuser);
                Session.AddPersonToGroupChat(groupChat, icuser);
            }

            MessageModel msg = new MessageModel();
            msg.MessageType = MessageType.Event;
            TextMessagePartModel textMsgPart;

            textMsgPart = new TextMessagePartModel();
            textMsgPart.Text = "-!- ";
            msg.MessageParts.Add(textMsgPart);

            textMsgPart = new TextMessagePartModel();
            textMsgPart.ForegroundColor = GetNickColor(e.Data.Nick);
            textMsgPart.Text = e.Who;
            msg.MessageParts.Add(textMsgPart);

            textMsgPart = new TextMessagePartModel();
            textMsgPart.Text = String.Format(_("{0} [{1}] has joined {2}"),
                                             String.Empty,
                                             e.Data.Ident + "@" + e.Data.Host,
                                             e.Channel);
            msg.MessageParts.Add(textMsgPart);

            Session.AddMessageToChat(groupChat, msg);
        }