Beispiel #1
0
        public IrcView( Settings settings )
        {
            Settings = settings;
            Settings.Inject(this);

            Views = new Dictionary<IrcChannelID,Channel>();

            irc = new Irc(settings);
            irc.Listeners.Add(this);

            cursorblink = new Timer() { Interval = 500 };
            cursorblink.Tick += (o,args) => { cursor = !cursor; if ( CurrentView != null ) Invalidate( CurrentView.Input.Bounds ); };
            cursorblink.Start();

            InitializeComponent();
            InitializeShortcutsAndCommands();
            InitializeStyle();

            foreach ( var server in settings.Servers ) {
                var connection = irc.Connect(server.Uri);

                foreach ( var channel in server.Channels ) {
                    connection.Join( channel.Name );
                    if ( channel.Shortcut == Keys.None ) continue;
                    string cname = channel.Name;
                    Shortcuts.Add( channel.Shortcut, () => CurrentView = ViewOf(connection,null,cname) );
                }
            }
        }
Beispiel #2
0
        public void OnChannelModeChange(IrcConnection connection, Irc.Actor op, string channel, string mode, string param)
        {
            Begin(()=>{
                var view = ViewOf(connection,op,channel);
                if ( view==null ) return;

                AddHistory( view, "", Timestamp, op.Nickname + " has set mode " + mode + " " + param, system );
                if ( view == CurrentView ) Invalidate();
            });
        }
        public TextStyle GetStyleFor( Channel view, IrcConnection connection, Irc.Actor who, string target, string message )
        {
            var style
                = connection.ActualNickname == who.Nickname     ? self
                : message.Contains( connection.ActualNickname ) ? alerted
                : normal
                ;

            var nuh = who.ToString();

            lock ( view.NuhFilters ) foreach ( var filter in view.NuhFilters ) if ( filter.Regex.IsMatch(nuh) ) style = filter.Style;

            return style;
        }
 public void OnChannelModeChange( IrcConnection connection, Irc.Actor op, string channel, string mode, string param )
 {
 }
 void CheckForTor( Irc.Actor actor )
 {
     lock( DnsCache ) {
         if( DnsCache.ContainsKey(actor.Hostname) && TorCsv.Lines.Contains(DnsCache[actor.Hostname]) ) {
             // ...tor detected...
         }
     }
 }
Beispiel #6
0
        public void OnPrivMsg(IrcConnection connection, Irc.Actor who, string target, string message)
        {
            Begin(()=>{
                var view = ViewOf(connection,who,target);
                if ( view==null ) return;

                var style = GetStyleFor( view, connection, who, target, message );

                if ( style == null ) return;

                if ( style == alerted || target == connection.ActualNickname )
                if ( !view.IsHiddenPermanently )
                {
                    Sounds.Beep.Play(this);
                    view.IsHighlighted = true;
                }
                view.IsUnread = true;
                view.IsHidden = view.IsHiddenPermanently;

                Match m;
                if ( (m=new Regex("\u0001ACTION (?'action'.*)\u0001").Match(message)).Success ) {
                    AddPrettyHistory( view, who.Nickname, Timestamp, m.Groups["action"].Value, style );
                } else {
                    AddPrettyHistory( view, "<"+who.Nickname+">", Timestamp, message, style );
                }

                Invalidate();
            });
        }
Beispiel #7
0
        public void OnKick(IrcConnection connection, Irc.Actor op, string channel, string target, string message)
        {
            Begin(()=>{
                var view = ViewOf(connection,op,channel);
                if ( view==null ) return;

                AddHistory( view, "", Timestamp, op.Nickname + " has kicked " + target + " from the channel" + (message=="" ? "" : (" ("+message+")")), system );
                if ( view == CurrentView ) Invalidate();
            });
        }
Beispiel #8
0
        public void OnTopic( IrcConnection connection, Irc.Actor who, string channel, string topic )
        {
            Begin(()=>{
                var view = ViewOf(connection,who,channel);
                if ( view==null ) return;

                if ( who == null ) {
                    AddHistory( view, "TOPIC", Timestamp, topic, system );
                } else {
                    AddHistory( view, "", Timestamp, who.Nickname + " has changed the topic to " + topic, system );
                }
                Invalidate();
            });
        }
Beispiel #9
0
        public void OnPrivMsg(IrcConnection connection, Irc.Actor who, string target, string message)
        {
            Begin(()=>{
                var view = ViewOf(connection,who,target);
                if ( view==null ) return;

                var style
                    = connection.ActualNickname == who.Nickname     ? self
                    : message.Contains( connection.ActualNickname ) ? alerted
                    : normal
                    ;

                if ( style == alerted ) MessageBeep(MB_OK);

                Match m;
                if ( (m=new Regex("\u0001ACTION (?'action'.+)\u0001").Match(message)).Success ) {
                    AddPrettyHistory( view, who.Nickname, Timestamp, m.Groups["action"].Value, style );
                } else {
                    AddPrettyHistory( view, "<"+who.Nickname+">", Timestamp, message, style );
                }
                if ( view == CurrentView ) Invalidate();
            });
        }
 public void OnNotice( IrcConnection connection, Irc.Actor who, string target, string message )
 {
 }
 public void OnNick( IrcConnection connection, Irc.Actor who, string channel, string newnick )
 {
 }
 public void OnModeChange( IrcConnection connection, Irc.Actor op, string channel, string mode, string target )
 {
 }
 public void OnKick( IrcConnection connection, Irc.Actor op, string channel, string target, string message )
 {
 }
 public void OnJoin( IrcConnection connection, Irc.Actor who, string channel )
 {
     lock( DnsCache )
     {
         if( DnsCache.ContainsKey(who.Hostname) )
             Dns.BeginResolve( who.Hostname, OnHostnameResolve, who );
         // ...
     }
 }
Beispiel #15
0
        public void OnRplInvited(IrcConnection connection, Irc.Actor who, string channel )
        {
            Begin(()=>{
                var view = ViewOf(connection,who,channel);
                if ( view==null ) return;

                AddHistory( view, "", Timestamp, "You have invited " + who.Nickname + " to " + channel, system );
                Invalidate();
            });
        }
Beispiel #16
0
        public void OnNick(IrcConnection connection, Irc.Actor who, string channel, string new_)
        {
            Begin(()=>{
                var view = ViewOf(connection,who,channel);
                if ( view==null ) return;

                AddHistory( view, "", Timestamp, who.Nickname + " is now known as " + new_, system );
                Invalidate();
            });
        }
 public void OnPart( IrcConnection connection, Irc.Actor who, string channel )
 {
 }
Beispiel #18
0
        public void OnQuit(IrcConnection connection, Irc.Actor who, string channel, string message)
        {
            Begin(()=>{
                var view = ViewOf(connection,who,channel);
                if ( view==null ) return;

                AddHistory( view, "", Timestamp, who + " has quit " + connection.ConnectionID.Hostname + (message=="" ? "" : (" ("+message+")")), system );
                Invalidate();
            });
        }
 public void OnPrivMsg( IrcConnection connection, Irc.Actor who, string target, string message )
 {
 }
Beispiel #20
0
 Channel ViewOf( IrcConnection connection, Irc.Actor who, string channel )
 {
     bool pm = channel == connection.ActualNickname;
     var id = new IrcChannelID() { Connection = connection, Channel = pm?who.Nickname:channel };
     if (!Views.ContainsKey(id)) CreateChannel(id,pm);
     return Views[id];
 }
 public void OnQuit( IrcConnection connection, Irc.Actor who, string channel, string message )
 {
 }
Beispiel #22
0
        public void OnJoin(IrcConnection connection, Irc.Actor who, string channel)
        {
            Begin(()=>{
                var view = ViewOf(connection,who,channel);
                if ( view==null ) return;

                AddHistory( view, "", Timestamp, who + " has joined the channel", system );
                if ( view == CurrentView ) Invalidate();
            });
        }
 public void OnRplInvited( IrcConnection connection, Irc.Actor who, string channel )
 {
 }
Beispiel #24
0
 public void ChangeModes( string channel, Irc.ModeChangeSet modes )
 {
     foreach ( var mode in modes.AllModes ) {
         var _value = (mode.Value==null)?"":(" "+mode.Value);
         Send( "MODE "+channel+" "+mode.Key+_value );
     }
 }
 public void OnTopic( IrcConnection connection, Irc.Actor op, string channel, string topic )
 {
 }