public static void SendSafeNotice(this IrcLocalUser user, IEnumerable <IIrcMessageTarget> targets, string format, params object[] args) { var message = String.Format(format, args).Replace("\r\n", " ").Replace('\r', ' ').Replace('\n', ' '); user.SendNotice(targets, message); }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="target"> /// </param> private void SendGreeting(IrcLocalUser localUser, IIrcMessageTarget target) { localUser.SendNotice(target, "This is the {0}, welcome.", ProgramInfo.AssemblyTitle); localUser.SendNotice(target, "Message me with '.help' for instructions on how to use me."); localUser.SendNotice(target, "Remember to log in via a private message and not via the channel."); }
private static void HandleEventLoop(IrcClient client) { _ircLocaluser = client.LocalUser; _hostNameToWebSockets.Add("", new WebSocketListenerClient(PrivateConstants.TestAccountWebsocketAuth)); _hostNameToWebSockets[""].Run(sendToIrcProcessor); bool isExit = false; while (!isExit) { Console.Write("> "); var command = Console.ReadLine(); switch (command) { case "exit": isExit = true; break; default: if (!string.IsNullOrEmpty(command)) { if (command.StartsWith("/") && command.Length > 1) { client.SendRawMessage(command.Substring(1)); } else { Console.WriteLine($"Unknown command '{command}'"); } } break; } } client.Disconnect(); }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="target"> /// </param> /// <param name="format"> /// </param> /// <param name="args"> /// </param> public static void SendNotice( this IrcLocalUser localUser, IIrcMessageTarget target, string format, params object[] args) { SendNotice(localUser, new[] { target }, format, args); }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="targets"> /// </param> /// <param name="format"> /// </param> /// <param name="args"> /// </param> public static void SendMessage( this IrcLocalUser localUser, IList <IIrcMessageTarget> targets, string format, params object[] args) { localUser.SendMessage(targets, string.Format(format, args)); }
public void HandleLeaveChannel(object sender, IrcChannelEventArgs e) { if (e.Channel == channel) { IrcLocalUser client = (IrcLocalUser)sender; client.LeftChannel -= HandleLeaveChannel; Form1.eventQueue.QueueEventAction(new Utility.EventQueue.VoidEventAction(DeleteThisTab)); } }
private void ClientOnRegistered(object sender, EventArgs eventArgs) { OnRegistered(); _user = _client.LocalUser; _user.MessageReceived += UserOnMessageReceived; _user.JoinedChannel += UserOnJoinedChannel; _user.LeftChannel += UserOnLeftChannel; _client.Channels.Join(_settings.Channel, _settings.ModChannel); }
private bool ReadChatCommand(IrcLocalUser user, IrcMessageEventArgs eventArgs) { var line = eventArgs.Text; if (line.Length > 1) { var userMessage = new UserMessage(eventArgs.Source.Name, line); NewMessageRecieved?.Invoke(this, new NewMessageEventArgs(userMessage, user) { }); return(true); } return(false); }
/// <summary> /// Called when our irc client receives a notice. /// </summary> /// <param name="localUser">The local user.</param> /// <param name="e"> /// The <see cref="IrcMessageEventArgs"/> instance containing the event data. /// </param> protected override void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { Log.Write(string.Format("We received notice from {0}: {1}", e.Source.Name, e.Text), _logClassType, _logPrefix); // Services (Quakenet) auto authentication if (_ircSettings.hideHostnameOnQuakeNet) { if (e.Text.StartsWith("You are now logged in", StringComparison.InvariantCultureIgnoreCase)) { localUser.SetModes("+x"); Log.Write("Setting mode +x to hide our hostname", _logClassType, _logPrefix); } } }
private void ChannelOnMessageReceived(object sender, IrcMessageEventArgs e, IrcDotNet.IrcChannel channel) { IrcLocalUser localUser = sender as IrcLocalUser; if (localUser == null) { return; } MessageEventArgs args = new MessageEventArgs(new IrcMessage(e.Text), new IrcServer(_clients.Keys.First(x => x.LocalUser.Equals(localUser)), _uploader), new IrcChannel(channel, _uploader), new IrcUser(channel.Users.FirstOrDefault(x => x.User.NickName == e.Source.Name)?.User, _uploader)); // Since we can't really listen to outgoing accurately, we can abuse this to get our message sent event. if (e.Source.Name == localUser.NickName) { MessageSent?.Invoke(this, args); return; } MessageReceived?.Invoke(this, args); }
/// <summary> /// Called when our irc client receives a message. /// </summary> /// <param name="localUser">The local user.</param> /// <param name="e"> /// The <see cref="IrcMessageEventArgs"/> instance containing the event data. /// </param> protected override void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { Log.Write(string.Format("We received message from {0}: {1}", e.Source.Name, e.Text), _logClassType, _logPrefix); }
/// <summary> /// Called when our irc client leaves a channel. /// </summary> /// <param name="localUser">The local user.</param> /// <param name="e"> /// The <see cref="IrcChannelEventArgs"/> instance containing the event data. /// </param> protected override void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { Log.Write(string.Format("We left channel: {0}", e.Channel.Name), _logClassType, _logPrefix); }
protected virtual void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { }
protected virtual void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { }
protected virtual void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { }
private Network NetworkFromIrcClient(IrcLocalUser user) { return(NetworkFromIrcClient((StandardIrcClient)user.Client)); }
protected abstract void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e);
protected abstract void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e);
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="e"> /// </param> protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { this.SendGreeting(localUser, e.Channel); }
public static void SendMessage(this IrcLocalUser user, IIrcMessageTarget target, string format, params object[] args) { user.SendMessage(target, String.Format(format, args)); }
public static void SendNotice(this IrcLocalUser user, IEnumerable <IIrcMessageTarget> targets, string format, params object[] args) { user.SendNotice(targets, String.Format(format, args)); }
public static void SendSafeMessage(this IrcLocalUser user, IIrcMessageTarget target, string format, params object[] args) { var message = String.Format(format, args).Replace("\r\n", " ").Replace('\r', ' ').Replace('\n', ' '); user.SendMessage(target, message); }
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="e"> /// </param> protected override void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { }
protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e) { // }
protected abstract void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e);
/// <summary> /// </summary> /// <param name="localUser"> /// </param> /// <param name="e"> /// </param> protected override void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e) { }