Exemple #1
0
        public IrcConnection Connect( IrcConnectionID id )
        {
            var server = this.settings.Servers.FirstOrDefault( (s) => UriToConnectionId(s.Uri) == id ) ?? this.settings.DefaultServerSettings;

            var p = new IrcConnectParams()
                { To   = id
                , User =
                    { Host     = server.Userhost
                    , RealName = server.Realname
                    , ID       = server.Username
                    , Nick     = server.Nickname
                    }
                , Encoding = Encoding.UTF8
                , Password = server.Password
                , Channels = server.Channels.Select( (s) => s.Name ).ToArray()
                };

            IrcConnection connection;
            if ( !Connections.ContainsKey(id) ) {
                connection = new IrcConnection(p,Listeners);
                Connections.Add(id,connection);
            } else {
                connection = Connections[id];
            }
            return connection;
        }
Exemple #2
0
 public void OnConnectionError( IrcConnection connection, Exception e )
 {
     Begin(()=>{
         var view = ViewOf(connection,null,"Error Log");
         AddHistory( view, "Exception"    , Timestamp, e.GetType().Name + " thrown handling of connection", alerted );
         AddHistory( view, "Message"      , Timestamp, e.Message   , normal );
         AddHistory( view, "Backtrace"    , Timestamp, e.StackTrace, normal );
     });
 }
Exemple #3
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 OnErrNickInUse( IrcConnection connection, string nick )
 {
 }
 public void OnChannelModeChange( IrcConnection connection, Irc.Actor op, string channel, string mode, string param )
 {
 }
 public void OnConnectionError( IrcConnection connection, Exception e )
 {
 }
Exemple #8
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();
            });
        }
 public void OnJoin( IrcConnection connection, Irc.Actor who, string channel )
 {
     lock( DnsCache )
     {
         if( DnsCache.ContainsKey(who.Hostname) )
             Dns.BeginResolve( who.Hostname, OnHostnameResolve, who );
         // ...
     }
 }
Exemple #10
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();
            });
        }
Exemple #11
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();
            });
        }
 public void OnPrivMsg( IrcConnection connection, Irc.Actor who, string target, string message )
 {
 }
 public void OnQuit( IrcConnection connection, Irc.Actor who, string channel, string message )
 {
 }
 public void OnNotice( IrcConnection connection, Irc.Actor who, string target, string message )
 {
 }
 public void OnPart( IrcConnection connection, Irc.Actor who, string channel )
 {
 }
 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 )
 {
 }
Exemple #19
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();
            });
        }
 // IEventListener
 public void OnRawRecv( IrcConnection connection, string rawline )
 {
 }
Exemple #21
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();
            });
        }
Exemple #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();
            });
        }
Exemple #23
0
 public void OnRecvParseError( IrcConnection connection, string rawline, Exception e )
 {
     Begin(()=>{
         var view = ViewOf(connection,null,"Error Log");
         AddHistory( view, "Exception"    , Timestamp, e.GetType().Name + " thrown during parsing of recieved data", alerted );
         AddHistory( view, "Recieved Data", Timestamp, rawline, normal );
         AddHistory( view, "Message"      , Timestamp, e.Message, normal );
         Invalidate();
     });
 }
Exemple #24
0
        public void OnRawRecv( IrcConnection connection, string rawline )
        {
            Begin(()=>{
                var view = ViewOf( connection, null, "Raw" );
                if ( view==null ) return;

                AddHistory( view, "", Timestamp, rawline, system );
                if ( view == CurrentView ) Invalidate();
            });
        }
Exemple #25
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 OnTopic( IrcConnection connection, Irc.Actor op, string channel, string topic )
 {
 }
 public void OnRecvParseError( IrcConnection connection, string rawrecv, Exception e )
 {
 }
 public void OnErrNotChannelOp( IrcConnection connection, string channel, string message )
 {
 }
Exemple #29
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();
            });
        }
 public void OnRplInvited( IrcConnection connection, Irc.Actor who, string channel )
 {
 }