示例#1
0
        static void ConnectToTwitch()
        {
            ConWin.UpdateTwitchLog("Twitch Client: Connecting...");
            TwitchClient = new TcpClient("irc.chat.twitch.tv", 6667);
            SReader      = new StreamReader(TwitchClient.GetStream());
            SWriter      = new StreamWriter(TwitchClient.GetStream());
            SWriter.WriteLine("PASS " + AuthKey);
            SWriter.WriteLine("NICK " + UserName);
            SWriter.WriteLine("USER " + UserName + " 8 * :" + UserName);
            SWriter.WriteLine("JOIN #" + DisplayName);
            SWriter.Flush();
            string Response = SReader.ReadLine();

            if (Response.Contains("Welcome, GLHF"))
            {
                ConWin.UpdateTwitchLog("Twitch Client: Connected");
            }
            else
            {
                ConWin.UpdateTwitchLog("Twitch Client: Failed to Connect");
                Debug.Log("Twitch - ConnectToTwitch() -> Failed to Connect", 3);
                return;
            }
            ConWin.UpdateTwitchLog(Response);
            string Response2 = SReader.ReadLine();

            ConWin.UpdateTwitchLog(Response2);
        }
示例#2
0
 static void GetTwitchDetails()
 {
     ConWin.UpdateTwitchLog("Twitch Client: Getting Details...");
     DisplayName = File.ReadAllText("Channel Details\\Display Name.txt").ToLower();
     UserName    = File.ReadAllText("Channel Details\\User Name.txt").ToLower();
     AuthKey     = File.ReadAllText("Channel Details\\Auth Key.txt").ToLower();
 }
示例#3
0
 static void UpdateAllVarBoxes()
 {
     for (int x = 0; x < Variables.Count; x++)
     {
         ConWin.UpdateVarBoxes(x + 1, Variables[x].Item1 + ": " + Variables[x].Item2);
     }
     for (int x = 15 - (15 - Variables.Count); x < 15; x++)
     {
         ConWin.UpdateVarBoxes(x + 1, "Var " + (x + 1));
     }
     IO.UpdateMainVariableFile(Variables);
 }
示例#4
0
 static void ReadChat()
 {
     Count++;
     if (!TwitchClient.Connected)
     {
         ConnectToTwitch();
         return;
     }
     if (TwitchClient.Available > 0)
     {
         var Msg = SReader.ReadLine();
         if (Msg.Contains("PING"))
         {
             SWriter.WriteLine("PONG :tmi.twitch.tv");
             Msg += " -> PONG :tmi.twitch.tv";
         }
         else if (Msg.Contains("PRIVMSG"))
         {
             var splitPoint = Msg.IndexOf("!", 1);
             var ChatName   = Msg.Substring(0, splitPoint);
             ChatName   = ChatName.Substring(1);
             splitPoint = Msg.IndexOf(":", 1);
             Msg        = Msg.Substring(splitPoint + 1);
             if (Msg.Substring(0, 1) == "!")
             {
                 Msg = Master.ProcessInput(Msg.ToLower(), ChatName);
                 Msg = ChatName + ": " + Msg;
             }
             else
             {
                 Msg = "";
             }
             //if (Msg.Substring(0, 1) == "!" && ChatName == DisplayName.ToLower())
             //    StreamerChatCommands(Msg);
         }
         if (Msg != "")
         {
             ConWin.UpdateTwitchLog(Msg);
         }
     }
     ChatWriterTimer -= 1;
     if (ChatWriterTimer <= 0)
     {
         WriteToChat("Test");
         //WriteToChat("Type '!' and the number of the option you wish to vote for!");
         ChatWriterTimer = ChatWriterReset;
     }
 }
示例#5
0
        static string RenameVariable(string Msg)
        {
            string Command     = Msg.Substring(8, Msg.Length - 8);
            int    Index       = Command.IndexOf("-", 0, Command.Length);
            string CurrentName = Command.Substring(0, Command.Length - Index);
            string NewName     = Command.Substring(Index + 1, Command.Length - (Index + 1));

            for (int x = 0; x < Variables.Count; x++)
            {
                if (Variables[x].Item1 == CurrentName)
                {
                    Variables[x] = new Tuple <string, int>(NewName, Variables[x].Item2);
                    ConWin.UpdateVarBoxes(x + 1, Variables[x].Item1 + ": " + Variables[x].Item2);
                    return(Msg);
                }
            }
            Twitch.WriteToChat("Engine: The variable '" + CurrentName + "' Doesn't exist!");
            return(" -> Engine: The variable '" + CurrentName + "' Doesn't exist!");
        }
示例#6
0
        static string NewVariable(string Msg)
        {
            if (Variables.Count == 15)
            {
                Twitch.WriteToChat("Engine: Variables list is full, delete a variable before adding another!");
                return(Msg + " -> Engine: Variables list is full!");
            }
            Tuple <string, int> NewTuple = new Tuple <string, int>(Msg.Substring(8, Msg.Length - 8), 0);

            if (!CheckForExistingVariable(NewTuple.Item1))
            {
                Variables.Add(NewTuple);
            }
            else
            {
                Twitch.WriteToChat("Engine: That variable already exists!");
                return(Msg + " -> Engine: That variable already exists!");
            }
            ConWin.UpdateVarBoxes(Variables.Count, NewTuple.Item1 + ": 0");
            IO.UpdateMainVariableFile(Variables);
            return(Msg);
        }
示例#7
0
 static string AddOrRemoveToVariableCount(string Msg, byte VarPos)
 {
     try
     {
         if (Msg.Contains("+"))
         {
             int Index  = Msg.IndexOf("+", 0, Msg.Length);
             int Number = Convert.ToInt32(Msg.Substring(Index + 1, Msg.Length - (Index + 1)));
             Variables[VarPos] = new Tuple <string, int>(Variables[VarPos].Item1, Variables[VarPos].Item2 + Number);
         }
         else if (Msg.Contains("-"))
         {
             int Index  = Msg.IndexOf("-", 0, Msg.Length);
             int Number = Convert.ToInt32(Msg.Substring(Index + 1, Msg.Length - (Index + 1)));
             Variables[VarPos] = new Tuple <string, int>(Variables[VarPos].Item1, Variables[VarPos].Item2 - Number);
         }
         else if (Msg.Contains("="))
         {
             int Index  = Msg.IndexOf("=", 0, Msg.Length);
             int Number = Convert.ToInt32(Msg.Substring(Index + 1, Msg.Length - (Index + 1)));
             Variables[VarPos] = new Tuple <string, int>(Variables[VarPos].Item1, Number);
         }
         else
         {
             Variables[VarPos] = new Tuple <string, int>(Variables[VarPos].Item1, Variables[VarPos].Item2 + 1);
         }
         ConWin.UpdateVarBoxes(VarPos + 1, Variables[VarPos].Item1 + ": " + Variables[VarPos].Item2);
         IO.UpdateMainVariableFile(Variables);
     }
     catch
     {
         Debug.Log("Master - AddOrRemoveToVariableCount() -> Error Processing Command: " + VarPos + " (" + Msg + ")", 1);
         Twitch.WriteToChat("Engine: Variable Error!");
         return(" -> Engine: Variable Error!");
     }
     return(Msg);
 }
示例#8
0
 static void Main(string[] args)
 {
     ConWin.ConWinStart();
     Twitch.LaunchConnection();
     Console.ReadLine();
 }