-
-
Save Yonom/75e5c83937ea8a167d9d to your computer and use it in GitHub Desktop.
Speedrun Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using BotBits; | |
using BotBits.Events; | |
using PlayerIOClient; | |
using Rabbit; | |
using Rabbit.EE; | |
namespace SpeedRun | |
{ | |
public partial class Form1 : Form | |
{ | |
public static BotBitsClient bot = new BotBitsClient(); | |
public Form1() | |
{ | |
InitializeComponent(); | |
EventLoader.Of(bot).Load(this); | |
} | |
[EventListener] | |
void OnJoin(JoinEvent e) | |
{ | |
this.Write("{0}: Press any arrow key to start the timer.", e.Player.ChatName); | |
} | |
[EventListener] | |
void OnMove(MoveEvent e) | |
{ | |
if (e.Player.Get<DateTime>("StartTime") == default(DateTime)) | |
{ | |
e.Player.Set("StartTime", DateTime.UtcNow); | |
this.Write("{0}: Timer started, go go go!", e.Player.ChatName); | |
} | |
} | |
[EventListener] | |
void OnSilverCrown(SilverCrownEvent e) | |
{ | |
var startTime = e.Player.Get<DateTime>("StartTime"); | |
if (startTime != default(DateTime)) | |
{ | |
this.Write("{0}: You won! Time: {1:g}", e.Player.ChatName, DateTime.UtcNow - startTime); | |
} | |
} | |
private async void button1_Click(object sender, EventArgs e) | |
{ | |
button1.Text = "Connecting..."; | |
button1.Enabled = false; | |
try | |
{ | |
var username = textBox1.Text == "guest" ? "guest@lol.dk" : textBox1.Text; | |
Client client = null; | |
await Task.Run(() => | |
client = new RabbitAuth().LogOn(EERabbitAuth.GameId, username, textBox2.Text)); | |
await ConnectionManager | |
.Of(bot) | |
.WithClient(client) | |
.JoinRoomAsync(textBox3.Text); | |
this.Hide(); | |
} | |
catch (PlayerIOError ex) | |
{ | |
MessageBox.Show("Error! " + ex.Message); | |
button1.Text = "Login"; | |
button1.Enabled = true; | |
} | |
} | |
void Write(string message, params object[] args) | |
{ | |
Chat.Of(bot).Say(message, args); | |
Console.WriteLine(message, args); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment