Exemple #1
0
        public bool Disconnect()
        {
            if (state != IRCLinkState.Connected)
            {
                return(false);
            }

            ConnectServer    = "";
            ConnectedChannel = "";
            client.Quit();
            state = IRCLinkState.Ready;

            return(true);
        }
Exemple #2
0
        public bool Connect(string ip, string channel)
        {
            Logger.Verbose(nickname);

            if (state != IRCLinkState.Ready)
            {
                return(false);
            }

            client = new IrcClient(ip, new IrcUser(nickname, "HacknetLink"));

            client.ConnectionComplete += (s, e) => client.JoinChannel(channel);

            client.UserJoinedChannel += (s, e) =>
            {
                os.write("User " + e.User.Nick + " has joined the channel.");
            };

            client.UserPartedChannel += (s, e) =>
            {
                os.write("User " + e.User.Nick + " has left the channel.");
            };

            client.NetworkError += (s, e) =>
            {
                if (state != IRCLinkState.Ready)
                {
                    os.write("Connection error. Check your internet connection and the server details.");
                }
            };

            client.ChannelMessageRecieved += (s, e) =>
            {
                string SenderNick = Regex.Split(e.PrivateMessage.User.Nick, "!")[0];
                string message    = e.PrivateMessage.Message;
                os.write(SenderNick + ": " + message);
            };

            state            = IRCLinkState.Connected;
            ConnectServer    = ip;
            ConnectedChannel = channel;
            client.ConnectAsync();

            return(true);
        }