public void OnLevelWasLoaded(int level)
        {
            string menuName = SceneManager.GetSceneByBuildIndex(level).name;

            if (menuName == "Menu")
            {
                if (!_chatHandler)
                {
                    _chatHandler = new GameObject("EnhancedTwitchChat").AddComponent <ChatHandler>();
                }

                if (!TwitchIRCClient.Initialized)
                {
                    new Thread(() => TwitchIRCClient.Initialize(_chatHandler)).Start();
                    TwitchIRCClient.Initialized = true;
                }

                //Plugin.Log("Taking out the trash... ;)");
                System.GC.Collect();

                IsAtMainMenu = true;
            }
            else if (menuName.Contains("Environment"))
            {
                IsAtMainMenu = false;
            }
        }
    private void Awake()
    {
        twitchIRCClient = GetComponent <TwitchIRCClient>();
        twitchIRCClient.MessageReceived.AddListener(MessageReceived);


        commentVFX = GetComponent <CommentVFX>();
    }
Exemple #3
0
        private void PluginOnConfigChangedEvent(Config config)
        {
            TwitchIRCClient.OnConnectionComplete();
            UpdateChatUI();

            _canvasRectTransform.localScale = new Vector3(0.012f * Plugin.Instance.Config.ChatScale, 0.012f * Plugin.Instance.Config.ChatScale, 0.012f * Plugin.Instance.Config.ChatScale);
            _lockButtonSphere.localScale    = new Vector3(0.15f * Plugin.Instance.Config.ChatScale, 0.15f * Plugin.Instance.Config.ChatScale, 0.001f * Plugin.Instance.Config.ChatScale);
            _background.color = Plugin.Instance.Config.BackgroundColor;

            foreach (CustomText currentMessage in _chatMessages)
            {
                currentMessage.color = Plugin.Instance.Config.TextColor;
            }
        }
Exemple #4
0
 public int Disconnect()
 {
     return(TwitchIRCClient.Disconnect(Connection));
 }
Exemple #5
0
 public int Restart()
 {
     return(TwitchIRCClient.Restart(Connection, ExtendedInformation));
 }
Exemple #6
0
 public int SendChannelMessage(string channelName, string message)
 {
     return(TwitchIRCClient.SendChannelMessage(channelName, message, Connection));
 }
Exemple #7
0
 public int SendWisperMessage(string username, string message)
 {
     return(TwitchIRCClient.SendWisperMessage(username, message, Connection));
 }
Exemple #8
0
 public int SendServerMessage(string message)
 {
     return(TwitchIRCClient.SendServerMessage(message, Connection));
 }
Exemple #9
0
 public string ReadMessage()
 {
     return(TwitchIRCClient.ReadMessage(Connection));
 }
Exemple #10
0
 public int LeaveChannel(string channelName)
 {
     return(TwitchIRCClient.DepartChannel(channelName, Connection));
 }
Exemple #11
0
 public int JoinChannel(string channelName)
 {
     return(TwitchIRCClient.JoinChannel(channelName, Connection));
 }
Exemple #12
0
        static void Main(string[] args)
        {
            string           username;
            string           oAuth;
            string           host;
            ITwitchIRCClient client;

            username = "";
            oAuth    = "";
            host     = "irc.chat.twitch.tv";

            client = new TwitchIRCClient(host, 6667, oAuth, username);

            //client.OnRawMessage += (object sender, RawMessageEventArgs e)=>{ Console.WriteLine(e.Content); };

            client.OnConnect += (object sender, ConnectEventArgs e) =>
            {
                if (e.Connected)
                {
                    Console.WriteLine("-----Connected-----");
                }
                else
                {
                    Console.WriteLine("-----Disconnected-----");
                }
            };

            client.OnMessage += (object sender, MessageEventArgs e) =>
            {
                var m = e.Message;
                if (m.Type == MessageType.ChatMessage)
                {
                    string displayName = "";
                    if (m.Tags.ContainsKey("display-name"))
                    {
                        displayName = m.Tags["display-name"];
                    }
                    else
                    {
                        Regex usernameparse = new Regex(@"[:](\S+)[!]");
                        var   usernamematch = usernameparse.Match(m.Prefix);
                        if (usernamematch.Success)
                        {
                            displayName = usernamematch.Groups[1].Value;
                        }
                    }

                    string chatLine = "";
                    chatLine += displayName;
                    chatLine += ": ";
                    chatLine += m.Payload;

                    Console.WriteLine(chatLine);
                }
            };

            Console.WriteLine("Press CTRL+C To Close Connection.");
            client.Start().Wait();
            var channel = client.JoinChannel(username.ToLowerInvariant()).Result;
            CancellationTokenSource cts = new CancellationTokenSource();

            Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) => { cts.Cancel(); };
            channel.SendToChat("Omni bot was turned on").Wait();
            while (!cts.Token.IsCancellationRequested)
            {
                Task.Delay(500).Wait();
            }
            client.Stop().Wait();
            Console.WriteLine("Any key to exit...");
            Console.ReadKey();
        }