private void _OnRegistered(object sender, EventArgs e) { OnConnected(EventArgs.Empty); // preliminary person _MyPerson = CreatePerson(_IrcClient.Nickname); // WHO ourself so OnWho() can retrieve our ident, host and realname _IrcClient.RfcWho(_IrcClient.Nickname); }
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)) { _MyPerson = CreatePerson(e.NewNickname, MyPerson.RealName, MyPerson.Ident, MyPerson.Host); var builder = CreateMessageBuilder(); builder.AppendEventPrefix(); // TRANSLATOR: do NOT change the position of {0}! builder.AppendText(_("You're now known as {0}"), String.Empty); builder.AppendIdendityName(CreatePerson(e.NewNickname)); Session.AddMessageToChat(_NetworkChat, builder.ToMessage()); } 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; } var newuser = CreateGroupPerson(e.NewNickname); 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); var builder = CreateMessageBuilder(); builder.AppendEventPrefix(); if (e.Data.Irc.IsMe(e.NewNickname)) { // TRANSLATOR: do NOT change the position of {0}! builder.AppendText(_("You're now known as {0}"), String.Empty); } else { builder.AppendIdendityName(olduser); // TRANSLATOR: do NOT change the position of {0} or {1}! builder.AppendText(_("{0} is now known as {1}"), String.Empty, String.Empty); } builder.AppendIdendityName(newuser); Session.AddMessageToChat(cchat, builder.ToMessage()); } } }
private IrcPersonModel CreatePerson(string nick, string realname, string ident, string host) { var person = new IrcPersonModel(nick, realname,ident, host, NetworkID, this); if (_IrcClient.IsMe(nick)) { person.IdentityNameColored.ForegroundColor = IrcTextColor.Blue; person.IdentityNameColored.BackgroundColor = TextColor.None; person.IdentityNameColored.Bold = true; } return person; }
public void CommandMessageQuery(CommandModel cd) { ChatModel chat = null; if (cd.DataArray.Length >= 2) { string nickname = cd.DataArray[1]; chat = GetChat(nickname, ChatType.Person); if (chat == null) { IrcPersonModel person = new IrcPersonModel(nickname, NetworkID, this); chat = new PersonChatModel(person, nickname, nickname, this); Session.AddChat(chat); Session.SyncChat(chat); } } if (cd.DataArray.Length >= 3) { string message = String.Join(" ", cd.DataArray, 2, cd.DataArray.Length-2); _Say(chat, message); } }
private void _OnQueryNotice(object sender, IrcEventArgs e) { ChatModel chat = null; if (e.Data.Nick != null) { chat = GetChat(e.Data.Nick, ChatType.Person); } if (chat == null) { // use server chat as fallback if (e.Data.Nick == null) { // this seems to be a notice from the server chat = _NetworkChat; } else { // create new chat IrcPersonModel person = new IrcPersonModel(e.Data.Nick, null, e.Data.Ident, e.Data.Host, NetworkID, this); chat = new PersonChatModel(person, e.Data.Nick, e.Data.Nick, this); Session.AddChat(chat); Session.SyncChat(chat); } } MessageModel fmsg = new MessageModel(); TextMessagePartModel fmsgti; fmsgti = new TextMessagePartModel(); fmsgti.Text = String.Format("-{0} ({1}@{2})- ", e.Data.Nick, e.Data.Ident, e.Data.Host); // notice shouldn't be a highlight //fmsgti.IsHighlight = true; fmsg.MessageParts.Add(fmsgti); _IrcMessageToMessageModel(ref fmsg, e.Data.Message); Session.AddMessageToChat(chat, fmsg); }
private void _OnQueryMessage(object sender, IrcEventArgs e) { ChatModel chat = GetChat(e.Data.Nick, ChatType.Person); if (chat == null) { IrcPersonModel person = new IrcPersonModel(e.Data.Nick, null, e.Data.Ident, e.Data.Host, NetworkID, this); chat = new PersonChatModel(person, e.Data.Nick, e.Data.Nick, this); Session.AddChat(chat); Session.SyncChat(chat); } MessageModel fmsg = new MessageModel(); TextMessagePartModel fmsgti; fmsgti = new TextMessagePartModel(); fmsgti.Text = String.Format("<{0}> ", e.Data.Nick); fmsgti.IsHighlight = true; fmsg.MessageParts.Add(fmsgti); _IrcMessageToMessageModel(ref fmsg, e.Data.Message); Session.AddMessageToChat(chat, fmsg); }