Example #1
0
        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);
        }
Example #2
0
        /// <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.");
        }
Example #3
0
        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));
 }
Example #6
0
 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));
     }
 }
Example #7
0
        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);
        }
Example #8
0
        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);
        }
Example #9
0
        /// <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);
                }
            }
        }
Example #10
0
        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);
        }
Example #11
0
 /// <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);
 }
Example #12
0
 /// <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);
 }
Example #13
0
 protected virtual void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e)
 {
 }
Example #14
0
 protected virtual void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e)
 {
 }
Example #15
0
 protected virtual void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e)
 {
 }
Example #16
0
 private Network NetworkFromIrcClient(IrcLocalUser user)
 {
     return(NetworkFromIrcClient((StandardIrcClient)user.Client));
 }
Example #17
0
 protected abstract void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e);
Example #18
0
 protected abstract void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e);
Example #19
0
 /// <summary>
 /// </summary>
 /// <param name="localUser">
 /// </param>
 /// <param name="e">
 /// </param>
 protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e)
 {
     this.SendGreeting(localUser, e.Channel);
 }
Example #20
0
 public static void SendMessage(this IrcLocalUser user, IIrcMessageTarget target, string format, params object[] args)
 {
     user.SendMessage(target, String.Format(format, args));
 }
Example #21
0
 public static void SendNotice(this IrcLocalUser user, IEnumerable <IIrcMessageTarget> targets, string format, params object[] args)
 {
     user.SendNotice(targets, String.Format(format, args));
 }
Example #22
0
        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);
        }
Example #23
0
 protected abstract void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e);
Example #24
0
 protected virtual void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e)
 {
 }
Example #25
0
 /// <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)
 {
     //
 }
Example #27
0
 protected abstract void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e);
Example #28
0
 /// <summary>
 /// </summary>
 /// <param name="localUser">
 /// </param>
 /// <param name="e">
 /// </param>
 protected override void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e)
 {
 }