private void eUsersList_DoubleClick(object sender, EventArgs e) { var userItem = eUsersList.SelectedItem; if (userItem == null) { return; } Match m = Regex.Match(userItem.ToString(), "^[@+]?(.*)$"); string targetNick = m.Groups[1].Value; var ctx = ContextCollection.GetByName(targetNick); if (ctx == null) { ContextCollection.Add(new IrcQuery(targetNick)); } else { ContextCollection.Current = ctx; UpdateContext(); } }
static public void PrivmsgAction(Message message) { if (message.ParamsArray[1] == ContextCollection.Server.Client.Nickname) // Private message { var ctx = ContextCollection.GetByName(message.Nick); if (ctx != null) { ctx.WriteMessage(message.Nick, message.Text); } else { IrcQuery query = new IrcQuery(message.Nick); ContextCollection.Add(query, true); query.WriteMessage(message.Nick, message.Text); } } else // Channel { var ctx = ContextCollection.GetByName(message.ParamsArray[1]); if (ctx != null) { ctx.WriteMessage(message.Nick, message.Text); } } }
static public void JoinAction(Message message) { if (message.Nick == ContextCollection.Server.Client.Nickname) { ContextCollection.Add(new IrcChannel(message.ParamsArray[1])); } else { var ctx = ContextCollection.GetByName(message.ParamsArray[1]); if (ctx != null) { ((IrcChannel)ctx).Users.Add(message.Nick); ctx.WriteLine(RTF.ColourString(message.Nick + " (" + message.Ident + "@" + message.Host + ") has joined.", IrcColor.Orange)); Program.MainWindow.UpdateUsersList(); } } }
static public void QueryCommand(string _params) { Match m = Regex.Match(_params.Trim(), @"^([A-Za-z0-9_\-\[\]\\^{}|`]+)$"); if (m.Groups[1] == null || m.Groups[1].Value.Length == 0) { ContextCollection.Current.WriteLine("Usage: /query [<nickname>]"); return; } var ctx = ContextCollection.GetByName(m.Groups[1].Value); if (ctx == null) { IrcQuery query = new IrcQuery(m.Groups[1].Value); ContextCollection.Add(query); } else { ContextCollection.Current = ctx; Program.MainWindow.UpdateContext(); } }