Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using PlayerIOClient;
- using System.Text.RegularExpressions;
- namespace ConsoleApplication1
- {
- class Program
- {
- static Connection con;
- static void Main(string[] args)
- {
- while (true)
- {
- var rline = Console.ReadLine();
- if (rline.Substring(0, 2) == "-c")
- {
- Console1ParamCheck(rline);
- }
- else if (rline == "-h")
- {
- Console.WriteLine("\t\t ### HELP ### \n");
- Console.WriteLine("\t-c Email Password RoomID - Use this to login and join a room.");
- Console.WriteLine("\t-rs - Respawn the bot.");
- }
- else if (rline == "-rs")
- {
- try
- {
- if (con.Connected)
- {
- con.Send("say", "/reset");
- }
- }
- catch
- {
- Console.WriteLine("Error: You have to be connected to use this command");
- }
- }
- }
- }
- static void connect(string u, string p, string r)
- {
- PlayerIO.QuickConnect.SimpleConnect("blocking-blocks-u4zmkxjugu0ap8xqbymw", u, p,
- delegate(Client c)
- {
- Console.WriteLine("Logged on successfully");
- try
- {
- con = c.Multiplayer.JoinRoom(r, null);
- Console.WriteLine("Connected to room");
- con.Send("init");
- con.Send("init2");
- con.OnMessage += new MessageReceivedEventHandler(con_OnMessage);
- }
- catch (PlayerIOError error)
- {
- Console.WriteLine("Error: " + error);
- }
- },
- delegate(PlayerIOError error)
- {
- Console.WriteLine("Error: " + error);
- });
- }
- static void Console1ParamCheck(string rline)
- {
- if (Regex.Matches(rline, @"[ ]+").Count == 3)
- {
- string[] words = rline.Split(' ');
- if (words[1].Contains("@"))
- {
- if (words[2].Length >= 4)
- {
- if (Regex.IsMatch(words[3], "(PW|BW)+[A-f0-9_-]{3,13}", RegexOptions.IgnoreCase))
- {
- Console.Clear();
- connect(words[1], words[2], words[3]);
- }
- else
- {
- Console.Clear();
- Console.WriteLine("The roomID is incorrect.");
- }
- }
- else
- {
- Console.Clear();
- Console.WriteLine("The password is too short.");
- }
- }
- else
- {
- Console.Clear();
- Console.WriteLine("The E-mail is incorrect.");
- }
- }
- else
- {
- Console.Clear();
- Console.WriteLine("Unknown parameters.\nUsage: -c email password roomid");
- }
- }
- static void con_OnMessage(object sender, PlayerIOClient.Message m)
- {
- switch (m.Type)
- {
- case "init":
- Console.WriteLine("Connected to: " + m.GetString(1));
- break;
- case "say":
- if (m.GetString(1).ToLower().StartsWith("hi"))
- {
- con.Send("say", "Hello!");
- }
- else if (m.GetString(1).ToLower().StartsWith("hello"))
- {
- con.Send("say", "Hello!");
- }
- else if (m.GetString(1).ToLower().EndsWith("?"))
- {
- Random rnd = new Random();
- var rand = rnd.Next(1,4);
- switch (rand)
- {
- case 1:
- con.Send("say", "Chuck Norris");
- break;
- case 2:
- con.Send("say", "Depends. What flavor napkin do you like?");
- break;
- case 3:
- con.Send("say", "You don't want to know...");
- break;
- }
- }
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement