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.Windows.Forms;
- using IrcDotNet;
- namespace icc_twitch_bot
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- public IrcRegistrationInfo irc_iri
- {
- get
- {
- return new IrcUserRegistrationInfo()
- {
- NickName = "jsBot",
- UserName = "jsBot",
- RealName = "jsBot",
- Password = "oauth:94xo4jf562po2aafb94wklg0nhpm75f"
- };
- }
- }
- public IrcClient gIrcClient = new IrcClient();
- private void button1_Click(object sender, EventArgs e)
- {
- button1.Enabled = false;
- if (!gIrcClient.IsConnected)
- {
- button1.Text = "Connecting...";
- gIrcClient.Connect("irc.twitch.tv", 6667, false, irc_iri);
- }
- else
- {
- button1.Text = "Disconnecting...";
- gIrcClient.Quit(5000, "bye");
- }
- }
- void ircClient_Connected(object sender, EventArgs e)
- {
- try
- {
- if (button1.InvokeRequired)
- {
- MethodInvoker del = delegate {
- button1.Text = "Disconnect";
- button1.Enabled = true; };
- button1.Invoke(del);
- }
- else
- {
- button1.Text = "Disconnect";
- button1.Enabled = true;
- }
- gIrcClient.Channels.Join("#lgt_justice");
- }
- catch (Exception ex) { MessageBox.Show(ex.Message); }
- }
- void gIrcClient_Disconnected(object sender, EventArgs e)
- {
- if (!gIrcClient.IsConnected)
- {
- try
- {
- if (button1.InvokeRequired)
- {
- MethodInvoker del = delegate
- {
- button1.Text = "Connect";
- button1.Enabled = true;
- };
- button1.Invoke(del);
- }
- else
- {
- button1.Text = "Connect";
- button1.Enabled = true;
- }
- }
- catch (Exception ex) { MessageBox.Show(ex.Message); }
- }
- else gIrcClient.Disconnect();
- }
- void LocalUser_JoinedChannel(object sender, IrcChannelEventArgs e)
- {
- try
- {
- gIrcClient.Channels[0].MessageReceived += Form1_MessageReceived;
- gIrcClient.LocalUser.SendMessage(e.Channel, "yolo!");
- MessageBox.Show(gIrcClient.Channels[0].Users[0].User.NickName);
- MessageBox.Show("lol");
- }
- catch (Exception ex) { MessageBox.Show(ex.Message); }
- }
- void Form1_MessageReceived(object sender, IrcMessageEventArgs e)
- {
- try
- {
- if (e.Text.Equals("asd"))
- gIrcClient.LocalUser.SendMessage(e.Targets, "received");
- }
- catch (Exception ex) { MessageBox.Show(ex.Message); }
- }
- private void Form1_FormClosed(object sender, FormClosedEventArgs e)
- {
- if (gIrcClient.IsConnected)
- gIrcClient.Disconnect();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- gIrcClient.Connected += ircClient_Connected;
- gIrcClient.Disconnected += gIrcClient_Disconnected;
- gIrcClient.LocalUser.JoinedChannel += LocalUser_JoinedChannel;
- gIrcClient.FloodPreventer = new IrcStandardFloodPreventer(1, 10000);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment