Exemplo n.º 1
0
 public static async Task <byte[]> GetBytes(this PalBot bot, string url)
 {
     using (var client = new WebClient())
     {
         return(await client.DownloadDataTaskAsync(url));
     }
 }
Exemplo n.º 2
0
        public static PalBot UseConsoleLogging(this PalBot bot, bool logUnhandled = false)
        {
            if (logUnhandled)
            {
                bot.On.UnhandledPacket += (p) =>
                                          Extensions.ColouredConsole($"^w[^g{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}^w] ^rUNHANDLED ^w{p.Command}");
            }

            //bot.On.PacketReceived += (p) =>
            ((BroadcastUtility)bot.On).PacketParsed += (c, p) =>
                                                       Extensions.ColouredConsole($"^w[^g{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}^w] ^c<< ^w{p.Command} - ^b{p.ContentLength}");

            ((BroadcastUtility)bot.On).PacketParsed += (c, p) => HandlePacketWrite(p);

            bot.On.PacketSent += (p) =>
                                 Extensions.ColouredConsole($"^w[^g{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}^w] ^e>> ^w{p.Command} - ^b{p.ContentLength}");

            bot.On.Disconnected += () =>
                                   Extensions.ColouredConsole($"^w[^g{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}^w] ^yDisconnected..");

            bot.On.Exception += (e, n) =>
                                Extensions.ColouredConsole($"^w[^g{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}^w] ^rERROR {n} - {e.ToString()}");

            bot.On.LoginFailed += (b, r) =>
                                  Extensions.ColouredConsole($"^w[^g{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}^w] ^rLogin Failed: {r.Reason}");

            return(bot);
        }
Exemplo n.º 3
0
 public static PalBot RemoveIgnoredUser(this PalBot bot, params string[] ids)
 {
     foreach (var id in ids)
     {
         Restrictions.IgnoreRestriction.IgnoreUsers.Remove(id);
     }
     return(bot);
 }
Exemplo n.º 4
0
 public static PalBot RemoveAuth(this PalBot bot, params string[] ids)
 {
     foreach (var id in ids)
     {
         Restrictions.AuthRestriction.AuthorizedUsers.Remove(id);
     }
     return(bot);
 }
Exemplo n.º 5
0
        public static async Task <Bitmap> GetImage(this PalBot bot, string url)
        {
            using (var client = new WebClient())
            {
                var data = await client.DownloadDataTaskAsync(url);

                return(data.ToBitmap());
            }
        }
Exemplo n.º 6
0
        public static PalBot ReloginOnThrottle(this PalBot bot)
        {
            bot.On.Throttle += async(b, c) => await b.Login(b.Email, b.Password, b.Prefix, b.Status, b.Device, b.SpamFilter);

            return(bot);
        }
Exemplo n.º 7
0
        public static PalBot AutoReconnect(this PalBot bot)
        {
            bot.On.Disconnected += async() => await bot.Login(bot.Email, bot.Password, bot.Prefix, bot.Status, bot.Device, bot.SpamFilter);

            return(bot);
        }
Exemplo n.º 8
0
 public static PalBot AddIgnoredUser(this PalBot bot, params string[] ids)
 {
     Restrictions.IgnoreRestriction.IgnoreUsers.AddRange(ids);
     return(bot);
 }
Exemplo n.º 9
0
 public static PalBot AddAuth(this PalBot bot, params string[] ids)
 {
     Restrictions.AuthRestriction.AuthorizedUsers.AddRange(ids);
     return(bot);
 }
Exemplo n.º 10
0
 public static async Task <bool> Avatar(this PalBot bot, byte[] image)
 {
     return(await((PalBot)bot).UpdateAvatar(image));
 }
Exemplo n.º 11
0
 public static async Task <bool> Avatar(this PalBot bot, Bitmap image)
 {
     return(await((PalBot)bot).UpdateAvatar(image.ToByteArray()));
 }