Esempio n. 1
0
        public void SendIRCMessage(String writeMessage)
        {
            IRCMessage message = new IRCMessage();

            message.userName = Twitch.TwitchAPI._channel.Replace("#", "");
            message.channel  = Twitch.TwitchAPI._channel;

            IRCClient.SendIRCMessage(writeMessage);
            message.message = writeMessage;
            HandleUserCommands(message);

            //System Only Commands
            IRCClient.HandleMessages(message);
        }
        public void Start(QuestionUser pMethod, WriteToUser pWriteMethod, WriteLineToUser pWriteLineMethod)
        {
            Write     = pWriteMethod;
            WriteLine = pWriteLineMethod;

            string userName = string.Empty;

            if (!File.Exists("Username.USER"))
            {
                userName = pMethod("UserName?");
                File.WriteAllText("Username.USER", userName);
            }
            else
            {
                userName = File.ReadAllText("Username.USER");
            }

            if (!File.Exists("SecretTokenDontLOOK.TOKEN"))
            {
                var password = pMethod("Token?");
                File.WriteAllText("SecretTokenDontLOOK.TOKEN", password);
            }

            if (!File.Exists("Channel.JOIN"))
            {
                var channel = pMethod("Channel?(Leave blank for your own channel)");

                if (String.IsNullOrEmpty(channel))
                {
                    channel = "#" + userName;
                }

                if (!channel.StartsWith("#"))
                {
                    channel = "#" + channel;
                }

                File.WriteAllText("Channel.JOIN", channel);
                Twitch.TwitchAPI._channel = channel;
            }
            else
            {
                Twitch.TwitchAPI._channel = File.ReadAllText("Channel.JOIN");
            }

            IRCClient.Start(HandleUserCommands, Twitch.TwitchAPI._channel);

            TwitchAPI.Init();
            VoteSystem.Init();
            UserManager.Init();
            IRCClient.Init(ConsoleWrite);
            MemorySystem._instance.Init();
            Microphone.Init();

            IRCMessage message = new IRCMessage();

            message.userName = userName;
            message.channel  = Twitch.TwitchAPI._channel;
            while (true)
            {
                try
                {
                    var writeMessage = Console.ReadLine();
                    if (writeMessage?.Trim() == "q")
                    {
                        break;
                    }
                    if (writeMessage?.Trim() != string.Empty)
                    {
                        IRCClient.SendIRCMessage(writeMessage);
                        message.message = writeMessage;
                        HandleUserCommands(message);

                        //System Only Commands
                        IRCClient.HandleMessages(message);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.ToString());
                }
            }
        }