예제 #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);
        }
예제 #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.");
        }
예제 #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));
 }
예제 #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));
     }
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
                }
            }
        }
예제 #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);
        }
예제 #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);
 }
예제 #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);
 }
예제 #13
0
 protected virtual void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e)
 {
 }
예제 #14
0
 protected virtual void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e)
 {
 }
예제 #15
0
파일: IrcBot.cs 프로젝트: matthid/ircdotnet
 protected virtual void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e)
 {
 }
예제 #16
0
 private Network NetworkFromIrcClient(IrcLocalUser user)
 {
     return(NetworkFromIrcClient((StandardIrcClient)user.Client));
 }
예제 #17
0
파일: IrcBot.cs 프로젝트: djeebus/MusicHub
 protected abstract void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e);
예제 #18
0
 protected abstract void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e);
예제 #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);
 }
예제 #20
0
 public static void SendMessage(this IrcLocalUser user, IIrcMessageTarget target, string format, params object[] args)
 {
     user.SendMessage(target, String.Format(format, args));
 }
예제 #21
0
 public static void SendNotice(this IrcLocalUser user, IEnumerable <IIrcMessageTarget> targets, string format, params object[] args)
 {
     user.SendNotice(targets, String.Format(format, args));
 }
예제 #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);
        }
예제 #23
0
파일: IrcBot.cs 프로젝트: djeebus/MusicHub
 protected abstract void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e);
예제 #24
0
파일: IrcBot.cs 프로젝트: matthid/ircdotnet
 protected virtual void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e)
 {
 }
예제 #25
0
 /// <summary>
 /// </summary>
 /// <param name="localUser">
 /// </param>
 /// <param name="e">
 /// </param>
 protected override void OnLocalUserLeftChannel(IrcLocalUser localUser, IrcChannelEventArgs e)
 {
 }
예제 #26
0
 protected override void OnLocalUserJoinedChannel(IrcLocalUser localUser, IrcChannelEventArgs e)
 {
     //
 }
예제 #27
0
 protected abstract void OnLocalUserMessageReceived(IrcLocalUser localUser, IrcMessageEventArgs e);
예제 #28
0
 /// <summary>
 /// </summary>
 /// <param name="localUser">
 /// </param>
 /// <param name="e">
 /// </param>
 protected override void OnLocalUserNoticeReceived(IrcLocalUser localUser, IrcMessageEventArgs e)
 {
 }