static void Main(string[] args)
        {
            Authenticator = new WebAuthenticator();
            if (!File.Exists($"{AppDirectory}setupcomplete.txt"))
            {
                FirstTimeSetup();
            }

            // TODO: create json/xml settings file instead of this
            var FileContents = File.ReadAllText($"{AppDirectory}setupcomplete.txt");

            AppState = Guid.Parse(FileContents);

            ConsoleHelper.WriteLine("Grabbing credentials from database...");
            ChatBot = new TwitchChatBot(Authenticator, AppState);
            ConsoleHelper.WriteLine("Connecting to Twitch...");
            ChatBot.Start();

            // TODO: make playlists great again
            ConsoleHelper.WriteLine("Attempting to load the playlist...");
            GlobalVariables.GlobalPlaylist.LoadFromFolder("C:/Users/rocki/OneDrive/Music/STREM III");
            GlobalVariables.GlobalPlaylist.Shuffle();
            GlobalVariables.GlobalPlaylist.Play();

            object      locker     = new object();
            List <char> charBuffer = new List <char>();

            while (ChatBot.IsConnected)
            {
                var key = ConsoleHelper.ReadKey();
            }

            ConsoleHelper.WriteLine("Press any key to exit...");
            System.Console.ReadKey(true);
        }
Beispiel #2
0
        private void SettingsButton_Click(object sender, EventArgs e)
        {
            if (twitchBot != null)
            {
                twitchBot.KillThreads();

                if (twitchBot.twitchChat.Connected)
                {
                    StatusIndicator.BackColor = Color.Green;
                    StartBotButton.Text       = "Stop Bot";
                }
                else
                {
                    StatusIndicator.BackColor = Color.Red;
                    StartBotButton.Text       = "Start Bot";
                }

                twitchBot = null;
            }

            OptionsForm ow = new OptionsForm(options);

            if (ow.ShowDialog() == DialogResult.OK)
            {
                options.botName     = ow.input_botName.Text;
                options.channelName = ow.input_channelName.Text;
                options.password    = ow.input_oAuth.Text;
                options.host        = ow.input_host.Text;
                options.port        = (int)ow.input_port.Value;
                SaveSettings();
                LoadSettings();
            }

            GC.Collect();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            new WakeUpAssembly();
            TwitchChatBot chatBot = new TwitchChatBot(new SqlTwitchFactory());

            new Thread(chatBot.Run).Start();
            //Application.Run(new Hardly.Games.Holdem.Gui.Holdem());
        }
Beispiel #4
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;


            twitchbot  = twitchbot ?? new TwitchChatBot();
            viewhelp   = viewhelp ?? new ViewersHelper();
            logservice = logservice ?? new LogService();
        }
Beispiel #5
0
        private void ConnectToTwitch()
        {
            m_bot = new TwitchChatBot(Configuration.Instance.BotUsername, Configuration.Instance.ChannelName);

            m_bot.ConnectedToChannel += OnBotConnected;
            m_bot.NewMessage         += OnBotMessage;
            m_bot.Error += OnBotError;

            m_bot.Connect(Configuration.Instance.TwitchIrcUrl, Configuration.Instance.TwitchIrcPort, Configuration.Instance.TwitchOAuthToken);
        }
Beispiel #6
0
 public static TwitchChatBot GetBot()
 {
     if (twitchbot == null)
     {
         twitchbot = new TwitchChatBot();
         return(twitchbot);
     }
     else
     {
         return(twitchbot);
     }
 }
Beispiel #7
0
        static void Main()
        {
            TwitchChatBot bot = new TwitchChatBot();

            bot.Connect();

            //bot.Disconnect();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new LorAI());
        }
Beispiel #8
0
        private void DisconnectFromTwitch()
        {
            if (m_bot?.Connected ?? false)
            {
                m_bot.ConnectedToChannel -= OnBotConnected;
                m_bot.NewMessage         -= OnBotMessage;
                m_bot.Error -= OnBotError;

                m_bot.Dispose();

                m_bot = null;
            }
        }
Beispiel #9
0
 public ChatTimer(TwitchChatBot chatBot, int interval)
 {
     bot      = chatBot;
     messages = new List <string>();
     foreach (var item in Directory.GetFiles(directory).Where(x => x.Split('.').Last() == "txt"))
     {
         messages.Add(File.ReadAllText(item));
     }
     if (messages.Count() > 1)
     {
         timer = new Timer(new TimerCallback(OnElapsed), null, 0, interval);
     }
 }
    void Awake()
    {
        playerController = GameObject.FindGameObjectWithTag(Tags.Player).GetComponent<PlayerController>();

        GameObject twitchChatBotObj = GameObject.FindGameObjectWithTag(Tags.TwitchChatBot);
        if (twitchChatBotObj != null)
        {
            twitchChatBot = twitchChatBotObj.GetComponent<TwitchChatBot>();
        }

        playerStateValues = Enum.GetValues(typeof(PlayerState)).OfType<PlayerState>().ToArray();

        ResetVotes();
    }
Beispiel #11
0
        /// <summary>
        /// Creates the TCB object and adds events
        /// </summary>
        private void CreateTwitchChatBot()
        {
            this.Tcb = new TwitchChatBot();
            this.Tcb.LoginCompleted += (s, e) =>
            {
                Tcb.ReceiveWhispers();
                Tcb.JoinChannel(ConfigFile.Channel);
            };

            this.Tcb.MessageReceived += Tcb_MessageReceived;
            this.Tcb.CommandExecute  += Tcb_CommandExecute;

            this.Tcb.Verbose = IsInDebugMode;
        }
Beispiel #12
0
        private void StartBotButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(options.botName) || string.IsNullOrEmpty(options.password) || string.IsNullOrEmpty(options.channelName) || string.IsNullOrEmpty(options.host) && options.port >= 1 && options.port <= 65535)
            {
                if (MessageBox.Show("It appears that the setup have blank fields. That is not allowed.", "Setup Required!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    SettingsButton_Click(null, EventArgs.Empty);
                    return;
                }
            }

            if (twitchBot == null)
            {
                twitchBot = new TwitchChatBot(this, options.host, options.port, options.botName, options.password, options.channelName, true);
                autoManager.StartThreads();
                if (twitchBot.twitchChat.Connected)
                {
                    StatusIndicator.BackColor = Color.Green;
                    StartBotButton.Text       = "Stop Bot";
                }
                else
                {
                    StatusIndicator.BackColor = Color.Red;
                    StartBotButton.Text       = "Start Bot";
                }
            }
            else
            {
                twitchBot.KillThreads();
                autoManager.KillThreads();

                if (twitchBot.twitchChat.Connected)
                {
                    StatusIndicator.BackColor = Color.Green;
                    StartBotButton.Text       = "Stop Bot";
                }
                else
                {
                    StatusIndicator.BackColor = Color.Red;
                    StartBotButton.Text       = "Start Bot";
                }

                twitchBot = null;
            }

            autoList_SelectedIndexChanged(null, EventArgs.Empty);

            GC.Collect();
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            DisableConsoleQuickEdit.Go();

            Authenticator = new WebAuthenticator();
            Settings      = new ApplicationSettings();
            if (!Settings.Exists())
            {
                FirstTimeSetup();
            }
            Settings = Settings.Load();
            GlobalVariables.AppSettings = Settings;

            ConsoleHelper.WriteLine("Grabbing credentials from database...");
            ChatBot = new TwitchChatBot(Authenticator, Settings.AppState, Settings);
            ConsoleHelper.WriteLine("Connecting to Twitch...");
            ChatBot.Start();

            ConsoleHelper.WriteLine("Loading chat timers...");
            MsgTimer = new ChatTimer(ChatBot, 900000);
            if (MsgTimer.Count() > 1)
            {
                ConsoleHelper.WriteLine($"{MsgTimer.Count()} timers loaded.");
            }

            GlobalVariables.GlobalPlaylist.OnSongChanged += OnPlaylistSongChanged;
            if (Settings.PlaylistLocation != null && Directory.Exists(Settings.PlaylistLocation))
            {
                ConsoleHelper.WriteLine("Loading the playlist...");
                GlobalVariables.GlobalPlaylist.LoadFromFolder(Settings.PlaylistLocation);
                GlobalVariables.GlobalPlaylist.Shuffle();
                GlobalVariables.GlobalPlaylist.Play();
            }

            object      locker     = new object();
            List <char> charBuffer = new List <char>();

            while (ChatBot.IsConnected)
            {
                var key = ConsoleHelper.ReadKey();
            }

            ConsoleHelper.WriteLine("Press any key to exit...");
            System.Console.ReadKey(true);
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            if (Configs.CheckSetup() == false)
            {
                Configs.FirstTimeSetup();
            }

            TwitchChatBot bot    = new TwitchChatBot();
            PubSub        pubSub = new PubSub(ref bot);

            bot.Connect();
            pubSub.Connect();

            do
            {
                var input = Console.ReadLine();
                if (input.ToLowerInvariant() == "exit")
                {
                    bot.Disconnect();
                    pubSub.Disconnect();
                    Environment.Exit(0);
                }
                else
                {
                    if (input.StartsWith("/w"))
                    {
                        string[] substrings = input.Split();
                        string   receiver   = substrings[1];
                        string   message    = "";
                        int      target     = substrings.Length;

                        for (int i = 2; i < target; i++)
                        {
                            message += $"{substrings[i]} ";
                        }
                        bot.ManualWhisper(receiver, message);
                    }
                    else
                    {
                        bot.ManualMessage(input);   // Dev testing to send messages to chat, remove when unnecessary
                    }
                }
            } while (GlobalOptions.IsConnected == true);
        }
Beispiel #15
0
        private async Task StartBot(string oauthToken)
        {
            var botChatAuthenticated = Twitch.AuthenticateBot()
                                       .FromOAuthToken(oauthToken)
                                       .Build();

            _chatBot = new TwitchChatBot(botChatAuthenticated, _appClient, ServiceProvider, ServiceProvider.GetRequiredService <ILogger <TwitchChatBot> >());

            var orleansTaskScheduler = TaskScheduler.Current;

            _botCancellationSource = new CancellationTokenSource();
            var cancellationToken = _botCancellationSource.Token;

            _botTask = Task.Run(() => _chatBot.StartAsync(cancellationToken));

            _chatBot.SetChannel(_channelId);

            foreach ((var key, var processorInfo) in _channelBotState.State.Commands)
            {
                var registration = _registeredCommands[processorInfo.Type];
                await _chatBot.RegisterMessageProcessor(registration.ProcessorType, processorInfo);
            }
        }
 public SendTwitchPublicMessageHandler(TwitchChatBot twitchChatBot)
 {
     _twitchChatBot = twitchChatBot;
 }
Beispiel #17
0
 public PubSub(ref TwitchChatBot bot)
 {
     chatbot = bot;
 }