Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Speech.Synthesis;
- using System.Windows.Forms;
- using TwitchLib;
- using TwitchLib.Models.API;
- using TwitchLib.Models.Client;
- using TwitchLib.Events.Client;
- using TwitchLib.Exceptions.API;
- using TwitchLib.Events.PubSub;
- using TwitchLib.Events.Services.FollowerService;
- using TwitchLib.Events.Services.MessageThrottler;
- using TwitchLib.Enums;
- using TwitchLib.Extensions.Client;
- namespace ChatroomTool
- {
- public partial class Form1 : Form
- {
- public TwitchClient client = new TwitchClient(new TwitchLib.Models.Client.ConnectionCredentials(Properties.Settings.Default.username, Properties.Settings.Default.oauth));
- System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();
- SpeechSynthesizer synth = new SpeechSynthesizer();
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (client.IsConnected)
- {
- richChat.Text = richChat.Text + "\n" + txtChatBox.Text;
- client.SendMessage(txtChatBox.Text);
- txtChatBox.Text = "";
- }
- else
- {
- richChat.Text = richChat.Text + "\n" + "<< Disconnected From Chat >>";
- }
- }
- private void btnConnect_Click(object sender, EventArgs e)
- {
- client.OnMessageReceived += new EventHandler<OnMessageReceivedArgs>(globalChatMessageReceived);
- client.OnConnected += new EventHandler<OnConnectedArgs>(onConnected);
- client.OnDisconnected += new EventHandler<OnDisconnectedArgs>(onDisconnected);
- if (client.IsConnected == false)
- {
- client.Connect();
- }
- }
- public void onConnected(object sender, OnConnectedArgs e)
- {
- CheckForIllegalCrossThreadCalls = false;
- client.JoinChannel(txtChatroom.Text);
- richChat.Text = richChat.Text + "\n" + "<< Connected to chat server >>";
- }
- public void onDisconnected(object sender, OnDisconnectedArgs e)
- {
- //Don't do this in production
- CheckForIllegalCrossThreadCalls = false;
- //MessageBox.Show("disconnected");
- richChat.Text = richChat.Text + "\n" + "<< Disconnected From Channel >>";
- }
- private void globalChatMessageReceived(object sender, OnMessageReceivedArgs e)
- {
- CheckForIllegalCrossThreadCalls = false;
- if (e.ChatMessage.Username == "bacon_donut" & e.ChatMessage.Message.StartsWith("!hello "))
- {
- //MessageBox.Show("bacon says hello");
- //soundPlayer.Load();
- //soundPlayer.Play();
- synth.Speak(e.ChatMessage.Message);
- richChat.Text = richChat.Text + "\n" + e.ChatMessage.Message;
- }
- else if (e.ChatMessage.UserType== UserType.Moderator & e.ChatMessage.Message == "!modcommand")
- {
- MessageBox.Show("this is a mod command");
- richChat.Text = richChat.Text + "\n" + e.ChatMessage.Message;
- }
- else
- {
- richChat.Text = richChat.Text + "\n" + e.ChatMessage.Message;
- }
- }
- private void btnDisconnect_Click(object sender, EventArgs e)
- {
- client.LeaveChannel(txtChatroom.Text);
- client.Disconnect();
- richChat.Text = richChat.Text + "\n" + "<< Disconnecting.... >>";
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- soundPlayer.SoundLocation = "c:\\sizzle.wav";
- synth.SetOutputToDefaultAudioDevice();
- }
- private void btnSizzle_Click(object sender, EventArgs e)
- {
- soundPlayer.SoundLocation = "c:\\sizzle.wav";
- soundPlayer.Load();
- soundPlayer.Play();
- }
- private void btnBomb_Click(object sender, EventArgs e)
- {
- soundPlayer.SoundLocation = "c:\\bomb.wav";
- soundPlayer.Load();
- soundPlayer.Play();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement