void _bot_OnConnect(TBot sender, bool success) { if (success) { MessageBox.Show("Connected"); } else { MessageBox.Show("Failed to connect"); Environment.Exit(0); return; } }
public MainWindow() { using (BotStartForm bsf = new BotStartForm()) { if (bsf.ShowDialog() != System.Windows.Forms.DialogResult.OK) { Environment.Exit(0); return; } _bot = bsf.Bot; } InitializeComponent(); _bot.OnMessageRead += _bot_OnMessageRead; _bot.OnDisconnect += _bot_OnDisconnect; _bot.OnConnect += _bot_OnConnect; _bot.Start(); }
private void BotStartForm_Load(object sender, EventArgs e) { _bot = new TBot("BahNahNahBot", "oauth:68g2aewlvaon4i99ze354odf99keti", "BahNahNah"); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
private void button1_Click(object sender, EventArgs e) { _bot = new TBot(textBox1.Text, textBox2.Text, textBox3.Text); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
void _bot_OnMessageRead(TBot sender, TBotMessage message, string raw) { Chatlog.AppendText(string.Format("<{0}> {1}\n", message.Username, message.Text)); TBotCommand command = null; foreach (ListViewItem i in commandList.Items) { TBotCommand _tCom = (TBotCommand)i.Tag; string msgCompare = message.Text; string msgCompareSplit = message.Text; if (msgCompare.Contains(" ")) { msgCompareSplit = msgCompare.Split(' ')[0]; } if (!_tCom.FlagCaseSensitive) { msgCompare = msgCompare.ToLower(); } if (_tCom.FlagIsRegex) { if (Regex.Match(msgCompare, _tCom.Flag).Success) { command = _tCom; } } else { switch (_tCom.Paramiters) { case ParamiterType.HasParamiters: if (i.Text.ToLower() == msgCompare) { command = _tCom; } break; case ParamiterType.NoParamiters: if (i.Text.ToLower() == msgCompareSplit) { command = _tCom; } break; default: if (i.Text.ToLower() == msgCompareSplit || i.Text.ToLower() == msgCompare) { command = _tCom; } break; } } if (command != null) { break; } } if (command != null) { ExecuteCommand(command, message); } CheckBlacklist(message); }
void _bot_OnDisconnect(TBot sender, Exception ex) { MessageBox.Show("Lost connection! \n " + ex.ToString()); Environment.Exit(0); return; }