Ejemplo n.º 1
0
        public void Connect(IrcCredentials ircCredentials)
        {
            IrcClient.Connect(ircCredentials, "irc.twitch.tv", 6667);

            IrcClient.SendRawMessage($"PASS {ircCredentials.Password}");
            IrcClient.SendRawMessage($"NICK {ircCredentials.NickName}");
            IrcClient.SendRawMessage($"USER {ircCredentials.NickName}");
            //Fork of an async method that will continuously read text lines from the server
            var serverMessageHandler = ReadLinesFromServer();
        }
Ejemplo n.º 2
0
        private TwitchClient(IrcCredentials twitchCredentials)
        {
            s_IsInitialized = false;
            if (twitchCredentials == null || !twitchCredentials.Valid)
            {
                return;
            }

            Credentials       = twitchCredentials;
            m_websocketClient = new WebSocket($"ws://{Credentials.TwitchHost}:{Credentials.TwitchPort}");
            Initialize();
        }
Ejemplo n.º 3
0
        public static TwitchClient GetInstance(IrcCredentials twitchCredentials = null)
        {
            if (s_TwitchClient == null)
            {
                s_TwitchClient = new TwitchClient(twitchCredentials);

                if (!s_IsInitialized)
                {
                    s_TwitchClient = null;
                }
            }
            return(s_TwitchClient);
        }
Ejemplo n.º 4
0
        public bool LogIn(string user, string nick, string token, ILogger logger, TwitchBot bot)
        {
            try
            {
                //bot = new TwitchBot(new SQLiteConnection(new SQLitePlatformWin32(), "DotDotBot.db"), logger);

                IrcCredentials credentials;
                credentials = new IrcCredentials(token, user);
                bot.Connect(credentials);
            }
            catch
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 5
0
        public void Connect(IrcCredentials ircCredentials, string server, int port)
        {
            var serverAddress = Dns.GetHostEntry(server);
            Credentials = ircCredentials;
            try
            {
                _logger.Write($"Attemting to connect to {server} ({serverAddress.AddressList.First()}) on port {port}");
                _tcpClient.Connect(serverAddress.AddressList, port);

                _writer = new MessageThrottleService(new StreamWriter(_tcpClient.GetStream()) { AutoFlush = true }, _logger);
                Reader = new StreamReader(_tcpClient.GetStream());
            }
            catch (Exception e)
            {
                _logger.Write($"Exception: {e.Message}");
                _logger.WriteIndented($"Stacktrace: { e.StackTrace}");
                throw;
            }
        }
Ejemplo n.º 6
0
 public static bool IsMessageFromMe(ServerMessage message, IrcCredentials ircCredentials)
 {
     return message.Prefix.Equals(
         $"{ircCredentials.NickName}!{ircCredentials.NickName}@{ircCredentials.NickName}.tmi.twitch.tv");
 }