void Awake() { #if !NOT_TWITCH _twitchChatClient = TwitchChatClient.Instance; _twitchChatClient.AddOnCommandReceived(OnCommand); #endif }
///////////////////////////////////////////////////////////////////////////////////////////////////// // トーク ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <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); */ }
private void chatMessageTrigger(TwitchChatClient sender, ChatMessage m) { if (m.Message.StartsWith("!" + GlobalVars.Settings["commandprefix"])) { this.OnMessageReceive(this, m); } }
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; }
void Start() { #if NOT_TWITCH debugInput.AddListener((command) => ProcessCommand(command)); #else _twitchChatClient = TwitchChatClient.Instance; _twitchChatClient.AddOnCommandReceived(OnCommand); #endif }
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); }
private void OnDestroy() { if (_internalClient != null) { _internalClient.OnDestroy(); _internalClient = null; } _singleton = null; }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
/// <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); } } }
/// <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(); }
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); } }
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); }
/// <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); }
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); }
/////////////////////////////////////////////////////////////// // 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 }); }
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(); } }
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); } }
public void incorrectChatLogin(object sender, TwitchChatClient.OnIncorrectLoginArgs e) { MessageBox.Show("Failed login as chat client!!!\nException: " + e.Exception + "\nUsername: " + e.Exception.Username); }
public void onChatConnected(object sender, TwitchChatClient.OnConnectedArgs e) { MessageBox.Show("Connected to channel: " + e.Channel + "\nUnder username: " + e.Username); }
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; }
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); }
/////////////////////////////////////////////////////////////// // 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."); }
/// <summary> /// ユーザー数変更イベントハンドラ /// </summary> /// <param name="sender"></param> /// <param name="channelName">チャンネル名</param> private void TwitchChatClient_OnUserCountChange(TwitchChatClient sender, string channelName) { UpdateUserCntText(); }
/// <summary> /// モード変更イベントイベントハンドラ /// </summary> /// <param name="sender"></param> private void TwitchChatClient_OnModeChange(TwitchChatClient sender) { UpdateModeText(); }
public Program(UserAbstract user, TwitchChatClient client) { this.User = user; this.Client = client; }
/// <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; }
public TwitchService(HttpClient client, Proxy proxy, TwitchChatClient chatClient) { this.client = client; this.proxy = proxy; this.chatClient = chatClient; }
/// <summary> /// Constructor /// </summary> /// <param name="client">Client to use for this monitor</param> public TwitchCoMonitor(TwitchChatClient client) : base(client) { }