Ejemplo n.º 1
0
 void Awake()
 {
     #if !NOT_TWITCH
     _twitchChatClient = TwitchChatClient.Instance;
     _twitchChatClient.AddOnCommandReceived(OnCommand);
     #endif
 }
Ejemplo n.º 2
0
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 // トーク
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// トークのメッセージを受信した
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="nickName"></param>
 /// <param name="host"></param>
 /// <param name="message"></param>
 private void TwitchChatClient_OnQueryMessage(TwitchChatClient sender, string nickName, string host, string message)
 {
     /*
      * TalkForm talkForm = talkForm_Show(nickName, host);
      * talkForm.UpdateMessage(message);
      */
 }
Ejemplo n.º 3
0
 private void chatMessageTrigger(TwitchChatClient sender, ChatMessage m)
 {
     if (m.Message.StartsWith("!" + GlobalVars.Settings["commandprefix"]))
     {
         this.OnMessageReceive(this, m);
     }
 }
Ejemplo n.º 4
0
    private void Awake()
    {
        Debug.Assert(_singleton == null, "Attempting to create multiple instances of TwitchChatter.TwitchChatClient! Only one instance can exist at any time.");

        _singleton = this;

        _internalClient = TwitchChatClientInternal.singleton;
        _internalClient.Awake();

        if (_autoJoinChannels != null &&
            _autoJoinChannels.Length > 0)
        {
            foreach (string channelName in _autoJoinChannels)
            {
                JoinChannel(channelName);
            }
        }

        if (_autoEnableWhispers &&
            !string.IsNullOrEmpty(_userName) &&
            !string.IsNullOrEmpty(_oAuthPassword))
        {
            EnableWhispers();
        }

        //_internalClient.printVerboseDebugInfo = true;
    }
Ejemplo n.º 5
0
 void Start()
 {
     #if NOT_TWITCH
     debugInput.AddListener((command) => ProcessCommand(command));
     #else
     _twitchChatClient = TwitchChatClient.Instance;
     _twitchChatClient.AddOnCommandReceived(OnCommand);
     #endif
 }
Ejemplo n.º 6
0
        public static BotMain NewBot(TwitchClientSettings twitchSettings, string connectionString)
        {
            var twitchApi        = new TwitchAPI(twitchSettings.TwitchClientId);
            var twitchChatClient = new TwitchChatClient(twitchSettings, twitchApi);
            var chatClients      = new List <IChatClient>
            {
                new ConsoleChatClient(),
                twitchChatClient,
            };
            var twitchFollowerService = new TwitchFollowerService(twitchApi, twitchSettings);

            IRepository repository = SetUpDatabase.SetUpRepository(connectionString);

            var chatUserCollection = new ChatUserCollection(repository);
            var currencyGenerator  = new CurrencyGenerator(chatClients, chatUserCollection);
            var currencyUpdate     = new CurrencyUpdate(1, currencyGenerator);

            var automatedActionSystem = new AutomatedActionSystem(new List <IIntervalAction> {
                currencyUpdate
            });
            var rockPaperScissorsGame = new RockPaperScissorsGame(currencyGenerator, automatedActionSystem);
            var wordList = new List <string> {
                "apple", "banana", "orange", "mango", "watermellon", "grapes", "pizza", "pasta", "pepperoni", "cheese", "mushroom", "csharp", "javascript", "cplusplus", "nullreferenceexception", "parameter", "argument"
            };
            var hangmanGame = new HangmanGame(currencyGenerator, automatedActionSystem, wordList);

            var simpleCommands = repository.List <SimpleCommand>();

            List <IBotCommand> allCommands = new List <IBotCommand>();

            allCommands.AddRange(simpleCommands);
            allCommands.Add(new GiveCommand(chatUserCollection));
            allCommands.Add(new HelpCommand(allCommands));
            allCommands.Add(new CommandsCommand(allCommands));
            allCommands.Add(new CoinsCommand(repository));
            allCommands.Add(new BonusCommand(currencyGenerator));
            allCommands.Add(new StreamsCommand(repository));
            allCommands.Add(new ShoutOutCommand(twitchFollowerService));
            allCommands.Add(new QuoteCommand(repository));
            allCommands.Add(new AddQuoteCommand(repository));
            allCommands.Add(new AddCommandCommand(repository, allCommands));
            allCommands.Add(new RemoveCommandCommand(repository, allCommands));
            allCommands.Add(new HangmanCommand(hangmanGame));
            allCommands.Add(new RockPaperScissorsCommand(rockPaperScissorsGame));

            var commandHandler    = new CommandHandler(chatClients, allCommands);
            var subscriberHandler = new SubscriberHandler(chatClients);

            var twitchSystem = new FollowableSystem(new[] { twitchChatClient }, twitchFollowerService);


            var botMain = new BotMain(chatClients, repository, commandHandler, subscriberHandler, twitchSystem, automatedActionSystem);

            return(botMain);
        }
Ejemplo n.º 7
0
    private void OnDestroy()
    {
        if (_internalClient != null)
        {
            _internalClient.OnDestroy();

            _internalClient = null;
        }

        _singleton = null;
    }
Ejemplo n.º 8
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// トピックイベントハンドラ
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="channelName">チャンネル名</param>
 /// <param name="who">トピック変更ユーザーニックネーム</param>
 /// <param name="topic">トピック</param>
 private void TwitchChatClient_OnTopic(TwitchChatClient sender, string channelName, string who, string topic)
 {
     ChannelInfoEx[] channelInfoExs = TwitchChatClient.GetChannelInfoExsByJoined(true);
     if (channelInfoExs != null && channelInfoExs.Length > 0)
     {
         if (channelName == channelInfoExs[0].RealName)  // アリーナのみ対象
         {
             // トピックの更新
             SetTopic(channelName, topic);
         }
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Called when the scene starts
        /// <para>Opens the connection and starts the Coroutine and Thread to monitor the IRC client</para>
        /// </summary>
        protected void Awake()
        {
            m_Client = new TwitchChatClient();

            OpenConnection();

            StartChatMonitor();

            StartCoroutine(m_Monitor.Runner());

            EnableChatMessenger();

            Capabilities(TwitchProtocol.CAP_REQ.All);
            Connect();
        }
Ejemplo n.º 11
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var auth    = new AuthenticationModal();
            var success = auth.ShowDialog();

            if (success.HasValue && success.Value)
            {
                var token    = auth.Token;
                var username = Users.Get(token);
                Console.WriteLine("sucessfully got login info for " + username);
                this.chat            = new TwitchChatClient();
                this.chat.OnConnect += Chat_OnConnect;
                this.chat.OnPrivMsg += Chat_OnMessageReceived;
                this.chat.Connect(username, token, true);
            }
        }
Ejemplo n.º 12
0
        public async Task Start()
        {
            _client = new TwitchChatClient(new TwitchChatConfig()
            {
                LogLevel = LogLevel.Debug
            });

            _client.Log += OnLogAsync;

            await _client.LoginAsync("z05gs6s3y58vxv9gbxv7n8vazk0n98");

            await _client.ConnectAsync();

            await _client.JoinChannelAsync("summit1g");

            await Task.Delay(-1);
        }
        public void Setup()
        {
            mockTwitchClient = new Mock <ITwitchClient>();

            mockTwitchClient.Setup(s => s.Initialize(It.IsAny <ConnectionCredentials>(), It.IsAny <string>(), It.IsAny <char>(), It.IsAny <char>(), It.IsAny <bool>())).Verifiable();
            mockTwitchClient.Setup(s => s.Connect()).Verifiable();
            mockTwitchCredentialFileReader = new Mock <TwitchCredentials>();
            TwitchCredentials twitchCredentials = new TwitchCredentials
            {
                twitchUsername = "******",
                twitchOAuth    = "raw/erwakjrhak;ew"
            };

            //mockTwitchCredentialFileReader.Setup(s => s.readTwitchCredentials(It.IsAny<string>())).Returns(twitchCredentials);

            twitchChatClient = new TwitchChatClient(mockTwitchClient.Object);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// チャンネルメッセージ受信イベントハンドラ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="channelName">チャンネル名</param>
        /// <param name="nickName">ニックネーム</param>
        /// <param name="host">ホスト</param>
        /// <param name="message">チャンネルメッセージ</param>
        private void TwitchChatClient_OnChannelMessage(
            TwitchChatClient sender, string channelName, string nickName, string host, string message)
        {
            string date = DateTime.Now.ToString("HH:mm"); // 現在時刻

            /*
             * ChannelUser channelUser;
             *
             * channelUser = TwitchChatClient.GetChannelUser(channelName, nickName);
             * if (channelUser == null)
             * {
             *  return;
             * }
             */


            // 配信者判定
            bool isBc = TwitchChatClient.IsBc(channelName, nickName);

            // コメントの追加
            UiCommentData uiCommentData = new UiCommentData();

            uiCommentData.UserThumbUrl = "";
            uiCommentData.UserName     = nickName;
            uiCommentData.CommentStr   = message;

            System.Diagnostics.Debug.WriteLine("UserThumbUrl " + uiCommentData.UserThumbUrl);
            System.Diagnostics.Debug.WriteLine("UserName " + uiCommentData.UserName);
            System.Diagnostics.Debug.WriteLine("CommentStr " + uiCommentData.CommentStr);

            ViewModel viewModel = this.DataContext as ViewModel;
            ObservableCollection <UiCommentData> uiCommentDatas = viewModel.UiCommentDataCollection;

            uiCommentDatas.Add(uiCommentData);

            // データグリッドを自動スクロール
            DataGridScrollToEnd();

            // コメントログを記録
            WriteLog(uiCommentData.UserName, uiCommentData.CommentStr);

            // 棒読みちゃんへ送信
            BouyomiChan.Talk(uiCommentData.CommentStr);
        }
Ejemplo n.º 15
0
        private void button2_Click(object sender, EventArgs e)
        {
            ConnectionCredentials credentials = new ConnectionCredentials(ConnectionCredentials.ClientType.Chat, new TwitchIpAndPort(textBox8.Text, true), 
                textBox4.Text, textBox5.Text);
            TwitchChatClient newClient = new TwitchChatClient(textBox8.Text, credentials, '!');
            newClient.OnMessageReceived += new EventHandler<TwitchChatClient.OnMessageReceivedArgs>(globalChatMessageReceived);
            newClient.OnCommandReceived += new EventHandler<TwitchChatClient.OnCommandReceivedArgs>(chatCommandReceived);
            newClient.OnIncorrectLogin += new EventHandler<TwitchChatClient.OnIncorrectLoginArgs>(incorrectChatLogin);
            newClient.OnConnected += new EventHandler<TwitchChatClient.OnConnectedArgs>(onChatConnected);
            newClient.Connect();
            chatClients.Add(newClient);
            ListViewItem lvi = new ListViewItem();
            lvi.Text = textBox4.Text;
            lvi.SubItems.Add("CHAT");
            lvi.SubItems.Add(textBox8.Text);
            listView1.Items.Add(lvi);

            if(!comboBox2.Items.Contains(textBox4.Text))
                comboBox2.Items.Add(textBox4.Text);

            
        }
Ejemplo n.º 16
0
        ///////////////////////////////////////////////////////////////
        // Twitchチャットクライアント起動/停止
        ///////////////////////////////////////////////////////////////
        /// <summary>
        /// Twitchチャットを開始する
        /// </summary>
        private void TwitchChatClientStart(string nickName, string password, string channelName)
        {
            ChannelName = channelName;

            string chatChannelName = ChatChannelNamePrefix + channelName;

            TwitchChatClient                    = new TwitchChatClient(this, nickName, password);
            TwitchChatClient.OnStop            += TwitchChatClient_OnStop;
            TwitchChatClient.OnBusyChange      += TwitchChatClient_OnBusyChange;
            TwitchChatClient.OnChannelMessage  += TwitchChatClient_OnChannelMessage;
            TwitchChatClient.OnTopic           += TwitchChatClient_OnTopic;
            TwitchChatClient.OnUserCountChange += TwitchChatClient_OnUserCountChange;
            TwitchChatClient.OnModeChange      += TwitchChatClient_OnModeChange;
            TwitchChatClient.OnQueryMessage    += TwitchChatClient_OnQueryMessage;

            if (!TwitchChatListen.TwitchChatClient.IsValidChannelFormat(chatChannelName))
            {
                MessageBox.Show("チャンネル名の書式が間違っています。");
                return;
            }
            // チャットに接続
            TwitchChatClient.Start(new string[] { chatChannelName });
        }
Ejemplo n.º 17
0
        public static void Main(string[] args)
        {
            var user          = new UserConsole();
            var authUser      = args.Length > 0 ? new UserFile(args[0]) : (UserAbstract)user;
            var clientId      = authUser.ReadInput("Client-Id");
            var redirectURI   = authUser.ReadInput("Redirect-URI");
            var nickName      = authUser.ReadInput("Nickname").ToLowerInvariant();
            var authorization = Auth(clientId, redirectURI);

            using (var client = new TwitchChatClient())
            {
                client.Type     = ProtocolType.WebSocket;
                client.Security = ProtocolSecurity.Default;
                client.OAuth    = authorization.AccessToken;
                client.Nick     = nickName;
                client.Capabilities.Add(KnownCapabilities.Commands);
                client.Capabilities.Add(KnownCapabilities.Membership);
                client.Capabilities.Add(KnownCapabilities.Tags);
                client.Connect();

                new Thread(() =>
                {
                    while (true)
                    {
                        var input   = user.ReadInput();
                        var message = new IRCMessage();
                        message.Parse(input);

                        client.Send(message);
                    }
                }).Start();

                var program = new Program(user, client);
                program.Run();
            }
        }
Ejemplo n.º 18
0
        private void button2_Click(object sender, EventArgs e)
        {
            ConnectionCredentials credentials = new ConnectionCredentials(ConnectionCredentials.ClientType.Chat, new TwitchIpAndPort(textBox8.Text, true),
                                                                          textBox4.Text, textBox5.Text);
            TwitchChatClient newClient = new TwitchChatClient(textBox8.Text, credentials, '!');

            newClient.OnMessageReceived += new EventHandler <TwitchChatClient.OnMessageReceivedArgs>(globalChatMessageReceived);
            newClient.OnCommandReceived += new EventHandler <TwitchChatClient.OnCommandReceivedArgs>(chatCommandReceived);
            newClient.OnIncorrectLogin  += new EventHandler <TwitchChatClient.OnIncorrectLoginArgs>(incorrectChatLogin);
            newClient.OnConnected       += new EventHandler <TwitchChatClient.OnConnectedArgs>(onChatConnected);
            newClient.Connect();
            chatClients.Add(newClient);
            ListViewItem lvi = new ListViewItem();

            lvi.Text = textBox4.Text;
            lvi.SubItems.Add("CHAT");
            lvi.SubItems.Add(textBox8.Text);
            listView1.Items.Add(lvi);

            if (!comboBox2.Items.Contains(textBox4.Text))
            {
                comboBox2.Items.Add(textBox4.Text);
            }
        }
Ejemplo n.º 19
0
 public void incorrectChatLogin(object sender, TwitchChatClient.OnIncorrectLoginArgs e)
 {
     MessageBox.Show("Failed login as chat client!!!\nException: " + e.Exception + "\nUsername: " + e.Exception.Username);
 }
Ejemplo n.º 20
0
 public void onChatConnected(object sender, TwitchChatClient.OnConnectedArgs e)
 {
     MessageBox.Show("Connected to channel: " + e.Channel + "\nUnder username: " + e.Username);
 }
Ejemplo n.º 21
0
        private void globalChatMessageReceived(object sender, TwitchChatClient.OnMessageReceivedArgs e)
        {
            //Don't do this in production
            CheckForIllegalCrossThreadCalls = false;

            richTextBox1.Text = String.Format("#{0} {1}[isSub: {2}]: {3}", e.ChatMessage.Channel, e.ChatMessage.DisplayName, e.ChatMessage.Subscriber, e.ChatMessage.Message) + 
                "\n" + richTextBox1.Text;
        }
Ejemplo n.º 22
0
 private void chatCommandReceived(object sender, TwitchChatClient.OnCommandReceivedArgs e)
 {
     listBox1.Items.Add(e.ChatMessage.Username + ": " + e.Command + "; args: " + e.ArgumentsAsString + ";");
     foreach(string arg in e.ArgumentsAsList)
     {
         Console.WriteLine("[chat] arg: " + arg);
     }
     Console.WriteLine("[chat] args as string: " + e.ArgumentsAsString);
 }
Ejemplo n.º 23
0
        ///////////////////////////////////////////////////////////////
        // Twitchチャットクライアントイベント
        ///////////////////////////////////////////////////////////////
        /// <summary>
        /// 終了通知コールバック
        /// </summary>
        /// <param name="sender"></param>
        private void TwitchChatClient_OnStop(TwitchChatClient sender)
        {
            System.Diagnostics.Debug.WriteLine("TwitchChatClient_OnStop...");

            System.Diagnostics.Debug.WriteLine("TwitchChatClient_OnStop...done.");
        }
Ejemplo n.º 24
0
 /// <summary>
 /// ユーザー数変更イベントハンドラ
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="channelName">チャンネル名</param>
 private void TwitchChatClient_OnUserCountChange(TwitchChatClient sender, string channelName)
 {
     UpdateUserCntText();
 }
Ejemplo n.º 25
0
 /// <summary>
 /// モード変更イベントイベントハンドラ
 /// </summary>
 /// <param name="sender"></param>
 private void TwitchChatClient_OnModeChange(TwitchChatClient sender)
 {
     UpdateModeText();
 }
Ejemplo n.º 26
0
 public Program(UserAbstract user, TwitchChatClient client)
 {
     this.User   = user;
     this.Client = client;
 }
Ejemplo n.º 27
0
 /// <summary>
 /// 処理中フラグ変更通知コールバック
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="isBusy"></param>
 private void TwitchChatClient_OnBusyChange(TwitchChatClient sender, bool isBusy)
 {
     UpdateBtn.IsEnabled = !isBusy;
 }
 public TwitchSubscriberHandler(TwitchChatClient chatClient)
 {
     chatClient.OnNewSubscriber += ChatClientOnOnNewSubscriber;
 }
Ejemplo n.º 29
0
 public TwitchService(HttpClient client, Proxy proxy, TwitchChatClient chatClient)
 {
     this.client     = client;
     this.proxy      = proxy;
     this.chatClient = chatClient;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="client">Client to use for this monitor</param>
 public TwitchCoMonitor(TwitchChatClient client)
     : base(client)
 {
 }