예제 #1
0
파일: IrcView.cs 프로젝트: Finity/uberirc
        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) );
                }
            }
        }
예제 #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();
            });
        }
예제 #3
0
        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;
        }
예제 #4
0
 public void OnChannelModeChange( IrcConnection connection, Irc.Actor op, string channel, string mode, string param )
 {
 }
예제 #5
0
 void CheckForTor( Irc.Actor actor )
 {
     lock( DnsCache ) {
         if( DnsCache.ContainsKey(actor.Hostname) && TorCsv.Lines.Contains(DnsCache[actor.Hostname]) ) {
             // ...tor detected...
         }
     }
 }
예제 #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();
            });
        }
예제 #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();
            });
        }
예제 #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();
            });
        }
예제 #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();
            });
        }
예제 #10
0
 public void OnNotice( IrcConnection connection, Irc.Actor who, string target, string message )
 {
 }
예제 #11
0
 public void OnNick( IrcConnection connection, Irc.Actor who, string channel, string newnick )
 {
 }
예제 #12
0
 public void OnModeChange( IrcConnection connection, Irc.Actor op, string channel, string mode, string target )
 {
 }
예제 #13
0
 public void OnKick( IrcConnection connection, Irc.Actor op, string channel, string target, string message )
 {
 }
예제 #14
0
 public void OnJoin( IrcConnection connection, Irc.Actor who, string channel )
 {
     lock( DnsCache )
     {
         if( DnsCache.ContainsKey(who.Hostname) )
             Dns.BeginResolve( who.Hostname, OnHostnameResolve, who );
         // ...
     }
 }
예제 #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();
            });
        }
예제 #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();
            });
        }
예제 #17
0
 public void OnPart( IrcConnection connection, Irc.Actor who, string channel )
 {
 }
예제 #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();
            });
        }
예제 #19
0
 public void OnPrivMsg( IrcConnection connection, Irc.Actor who, string target, string message )
 {
 }
예제 #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];
 }
예제 #21
0
 public void OnQuit( IrcConnection connection, Irc.Actor who, string channel, string message )
 {
 }
예제 #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();
            });
        }
예제 #23
0
 public void OnRplInvited( IrcConnection connection, Irc.Actor who, string channel )
 {
 }
예제 #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 );
     }
 }
예제 #25
0
 public void OnTopic( IrcConnection connection, Irc.Actor op, string channel, string topic )
 {
 }