Exemple #1
0
        public static Tuple <IrcNetwork, TestTcpWrapper> GetAuthenticatedNetwork(string nick = "nick", string real = "real")
        {
            var wrapper = new TestTcpWrapper();
            var network = new IrcNetwork(wrapper);

            network.ConnectAsync(nick, real, IrcUserLoginModes.None).Wait();
            wrapper.EndAuthenticate();
            wrapper.LinesSent.Clear();
            return(Tuple.Create(network, wrapper));
        }
Exemple #2
0
        public async Task <bool> ConnectAsync(string hostName, int port)
        {
            // Create an IrcNetwork, injecting a SocketWrapper
            _network = new IrcNetwork(new SocketWrapper(hostName, port));

            // The only options here are to connect as an user or as a service.
            // We'll keep things simple and be a normal user.
            if (await _network.ConnectAsync(_nickname, "Greeting Bot", IrcUserLoginModes.None))
            {
                // We connected successfully, so join the channel and monitor it.
                // However, we have to wait for a while before joining the channel - some networks are a bit slow
                var channel = _network.GetChannel(_channelName);
                channel.UserJoined += Channel_UserJoined;

                // Wait one second
                await Task.Delay(1000);

                channel.Join();
                return(true);
            }

            // An error occured.
            return(false);
        }