/// <summary> /// Creates Builds /// </summary> public static void CreateDefualtBuild() { try { var filename = $"{BuildName()}.json"; var buildUrl = $"https://raw.githubusercontent.com/plsfixrito/AramBuddy.Data/master/Default/{filename}"; var result = Weeb.ReadString(buildUrl).Result; if (string.IsNullOrEmpty(result)) { Logger.Send("Wrong Response or was canceled, No Champion Build Created !", Logger.LogLevel.Warn); Logger.Send("No Build is being used !", Logger.LogLevel.Warn); return; } if (result.Contains("data")) { File.WriteAllText(Setup.BuildPath + "\\" + filename, result); Setup.Builds.Add(BuildName(), File.ReadAllText(Setup.BuildPath + "\\" + filename)); Logger.Send(BuildName() + " Build Created for " + Player.Instance.ChampionName + " - " + BuildName()); Setup.UseDefaultBuild(); } else { Logger.Send("Wrong Response, No Champion Build Created", Logger.LogLevel.Warn); Console.WriteLine(result); } } catch (Exception ex) { // if faild to create build terminate the AutoShop Logger.Send("Failed to create default build for " + Player.Instance.ChampionName, ex, Logger.LogLevel.Error); Logger.Send("No build is currently being used!", Logger.LogLevel.Error); } }
private static void Update(object e, EventArgs arg) { if (Source.thread_sleep) { System.Threading.Tasks.Task.Factory.StartNew(() => Weeb.Get_Currency_Update()); } }
public async Task RandomWaifu() { var r = new Random(); while (true) { try { var ran = r.Next(0, 500000); var tmp = await Weeb.GetCharacter(ran); var result = tmp.Data.Attributes; if (result.Name == "") { break; } await ReplyAsync("", false, Embed.GetEmbed($"**{result.Name ?? ""}** ({tmp.Data.Id ?? ""})", $"{Regex.Replace(Regex.Replace(result.Description ?? "", @"<[^>]+>| ", "").Trim(), @"\s{2,}", " ")}", result.Image.Original ?? "")); return; } catch (Exception) { //loop } } }
public async Task MyWaifu() { var List = new List <Functions.Waifu>(); var Id = Context.Message.Author.Id; var IdList = new List <int>(); foreach (var item in Program.Waifus) { if (item.Value.Owner == Id) { if (item.Value.Owner == Context.Message.Author.Id) { IdList.Add(item.Value.Id); } } } foreach (var item in IdList) { var tmp = await Weeb.GetCharacter(item); var result = tmp.Data.Attributes; await ReplyAsync("", false, Embed.GetEmbed($"**{result.Name ?? ""}**", "", result.Image.Original ?? "")); } if (IdList.Count() == 0) { await ReplyAsync("Sorry but you don't have any yet."); } }
public async Task Character([Remainder] int input) { var tmp = await Weeb.GetCharacter(input); var result = tmp.Data.Attributes; await ReplyAsync("", false, Embed.GetEmbed($"**{result.Name ?? ""}**", $"{Regex.Replace(Regex.Replace(result.Description ?? "", @"<[^>]+>| ", "").Trim(), @"\s{2,}", " ")}", result.Image.Original ?? "")); }
static void Main() { var init = new Initialization(); init.Init(); Task.Factory.StartNew(() => Weeb.Get_Currency_Update()); System.Windows.Forms.Application.Run(); }
static private void Timing(object ebj, ElapsedEventArgs e) { if (DateTime.Now.Hour == Hour || Source.last_error) { if (Source.thread_sleep) { Weeb.Get_Currency_Update(); } } }
public override Hero Get_Instance() { if (_instance == null) { _instance = new Weeb(); _instance.Start(); return(_instance); } else { return(_instance); } }
public async Task Character([Remainder] string input) { input = input.Replace(' ', '-'); var results = await Weeb.GetCharacter(input); string msg = "*Please reply with the following int:*\n"; int cnt = 1; foreach (var item in results) { msg = msg + "`" + cnt + ". " + item.Attributes.Name + "`\n"; cnt++; } int num = 0; await ReplyAndDeleteAsync("", false, Embed.GetEmbed($"**Please select a result**", msg), TimeSpan.FromMinutes(1)); try { var response = await NextMessageAsync(true, true, TimeSpan.FromMinutes(1)); num = int.Parse(response.Content) - 1; } catch { await ReplyAndDeleteAsync("", false, Embed.GetEmbed($"**Oops something went wrong**", "You didnt reply before timeout or inputed an invalid number")); return; } var tmp1 = results[num]; var tmp = tmp1.Attributes; int counter = 0; var dump = Embed.GetEmbeds($"**{tmp.Name ?? ""}** ({tmp1.Id ?? ""})", $"{Regex.Replace(Regex.Replace(tmp.Description ?? "", @"<[^>]+>| ", "").Trim(), @"\s{2,}", " ")}", tmp.Image.Original ?? ""); foreach (var item in dump) { if (counter == 0) { await ReplyAsync("", false, item); } else { await ReplyAsync("", false, item); } counter++; } }
public async Task AddWaifu(int input) { if (Context.Message.Author.Id != Program.OwnerID && Program.Users.GetValueOrDefault(Context.Message.Author.Id).lastWaifu == DateTime.Now.ToShortDateString()) { await ReplyAsync("", false, Embed.GetEmbed("**Oops something went wrong**", "You can only do this once per day!")); return; } if (Program.Users.GetValueOrDefault(Context.Message.Author.Id).currency < 100 && Program.Users.GetValueOrDefault(Context.Message.Author.Id).lastWaifu != "") { await ReplyAsync("", false, Embed.GetEmbed("**Oops something went wrong**", "Looks like you don't have enough credits to use this!")); return; } var result = await Weeb.GetCharacter(input); //check to see if taken if (Program.Waifus.ContainsKey(input)) { var Owner = Program.Waifus.GetValueOrDefault(input).Owner; if (Owner != 0) { await ReplyAsync($"Sorry but this waifu has already been taken by {Context.Client.GetUser(Owner).Username}."); } else { Program.Waifus.Remove(input, out Functions.Waifu Temp); Temp.Owner = Context.Message.Author.Id; Program.Waifus.GetOrAdd(input, Temp); await Functions.Waifu.CreateWaifuObject(Temp); } } else { await Functions.Waifu.CreateWaifuObject(new Functions.Waifu(input, result.Data.Attributes.Name, Context.Message.Author.Id)); } if (Context.Message.Author.Id != Program.OwnerID || Program.Users.GetValueOrDefault(Context.Message.Author.Id).lastWaifu != "") { Program.Users.GetValueOrDefault(Context.Message.Author.Id).currency = Program.Users.GetValueOrDefault(Context.Message.Author.Id).currency - 100; } Program.Users.GetValueOrDefault(Context.Message.Author.Id).lastWaifu = DateTime.Now.ToShortDateString(); await Program.SaveUser(Context.Message.Author.Id); await ReplyAsync("Waifu has been successfully added."); }
public async Task MyWaifu([Remainder] string input) { int id = 0; foreach (var item in Program.Waifus) { if (item.Value.Owner == Context.Message.Author.Id) { if (item.Value.Name.ToLower() == input.ToLower()) { id = item.Value.Id; break; } } } if (id == 0) { await ReplyAsync("Error. They are not your Waifu."); return; } var tmp = await Weeb.GetCharacter(id); var result = tmp.Data.Attributes; int counter = 0; foreach (var item in Embed.GetEmbeds($"**{result.Name ?? ""}**", $"{Regex.Replace(Regex.Replace(result.Description ?? "", @"<[^>]+>| ", "").Trim(), @"\s{2,}", " ")}", result.Image.Original ?? "")) { if (counter == 0) { await ReplyAsync("", false, item); } else { await ReplyAsync("", false, item); } counter++; } }
/// <summary> /// Creates Builds /// </summary> public static void GetBuildFromService() { try { var filename = $"{Player.Instance.CleanChampionName()}.json"; var buildUrl = $"https://raw.githubusercontent.com/plsfixrito/AramBuddy.Data/master/{Config.CurrentPatchUsed}/ItemBuilds/{filename}"; var result = Weeb.ReadString(buildUrl).Result; if (string.IsNullOrEmpty(result)) { Logger.Send("Wrong Response or was canceled, No Champion Build Created !", Logger.LogLevel.Warn); Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn); Setup.UseDefaultBuild(); return; } if (result.Contains("data")) { var filepath = $"{Setup.BuildPath}/{filename}"; File.WriteAllText(filepath, result); Setup.Builds.Add(Player.Instance.CleanChampionName(), File.ReadAllText(filepath)); Logger.Send("Created Build for " + Player.Instance.ChampionName); Setup.CustomBuildService(); } else { Logger.Send("Wrong Response, No Champion Build Created !", Logger.LogLevel.Warn); Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn); Setup.UseDefaultBuild(); } } catch (Exception ex) { // if faild to create build terminate the AutoShop Logger.Send($"Failed to create Build from service {Config.CurrentPatchUsed} for {Player.Instance.ChampionName}", Logger.LogLevel.Error); Logger.Send(ex.InnerException?.Message, Logger.LogLevel.Error); Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn); Setup.UseDefaultBuild(); } }
private static void DownLoadLevelSet() { try { var result = Weeb.ReadString(FileURL).Result; if (!string.IsNullOrEmpty(result) && result.Contains("LevelSet")) { File.WriteAllText(LevelSetFile, result); TryParseData(result, out CurrentLevelset); Logger.Send($"Created LevelSet For {Player.Instance.ChampionName}"); } else { Logger.Send("Failed to create Levelset.", Logger.LogLevel.Warn); Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); } } catch (Exception ex) { Logger.Send("ERROR: ", ex, Logger.LogLevel.Error); } }
internal void Init() { Weeb.Init(); Rechecker.Init(); IconBar.Init(); }
public async Task Manga([Remainder] string input) { List <MangaDataModel> results; if (input == null) { results = await Weeb.GetMangaTrending(); string msg = ""; int cnt = 1; foreach (var item in results) { msg = msg + cnt + ". " + item.Attributes.Titles.EnJp + "\n"; cnt++; } await ReplyAsync("", false, Embed.GetEmbed($"**Currently Trending**", msg)); } else { input = input.Replace(' ', '-'); results = await Weeb.GetManga(input); string msg = "*Please reply with the following int:*\n"; int cnt = 1; foreach (var item in results) { msg = msg + "`" + cnt + ". " + item.Attributes.Titles.EnJp + "`\n"; cnt++; } int num = 0; await ReplyAndDeleteAsync("", false, Embed.GetEmbed($"**Please select a result**", msg), TimeSpan.FromMinutes(1)); try { var response = await NextMessageAsync(true, true, TimeSpan.FromMinutes(1)); num = int.Parse(response.Content) - 1; } catch { await ReplyAndDeleteAsync("", false, Embed.GetEmbed($"**Oops something went wrong**", "You didnt reply before timeout or inputed an invalid number")); return; } var tmp1 = results[num]; var tmp = tmp1.Attributes; int counter = 0; foreach (var item in Embed.GetEmbeds($"**{tmp.Titles.EnJp}**", Regex.Replace(Regex.Replace($"Synonyms: {string.Join(", ", tmp.AbbreviatedTitles ?? Enumerable.Empty<string>())}\nScore: {tmp.AverageRating}\nAge: {tmp.AgeRating}\nStatus: {tmp.Status}\nType: {tmp.MangaType}\nChapters: {tmp.ChapterCount.ToString() ?? "Unknown" }\nVolumes: {tmp.VolumeCount.ToString() ?? "Unknown"}\nRuntime: {tmp.StartDate} - {tmp.EndDate}\n{tmp.Synopsis}", @"<[^>]+>| ", "").Trim(), @"\s{2,}", " "), tmp.PosterImage.Original ?? null)) { if (counter == 0) { await ReplyAsync($"https://kitsu.io/manga/{tmp1.Id ?? "error"}", false, item); } else { await ReplyAsync($"", false, item); } } } }
public static void Init() { try { Logger.Send("Checking For Updates.."); var size = Drawing.Width <= 1280 || Drawing.Height <= 720 ? 10F : 40F; text = new Text("ARAMBUDDY OUTDATED! PLEASE UPDATE!", new Font("Euphemia", size, FontStyle.Bold)) { Color = Color.White }; UpdateMsg = Weeb.ReadString(UpdateMsgPath).Result; if (string.IsNullOrEmpty(UpdateMsg)) { UpdateMsg = "Failed to get update msg."; } var onlineVersion = Weeb.ReadString(WebVersionPath).Result; if (string.IsNullOrEmpty(onlineVersion)) { Logger.Send("Failed to check for updates.", Logger.LogLevel.Warn); } else { if (!onlineVersion.Contains(CurrentVersion.ToString())) { Drawing.OnEndScene += delegate { text.Position = new Vector2(Drawing.Width * 0.01f, Drawing.Height * 0.1f); text.Draw(); }; Outdated = true; Logger.Send("Update available for AramBuddy!", Logger.LogLevel.Warn); Logger.Send("Update Log: " + UpdateMsg); Game.OnTick += delegate { if (UpdateMsg != string.Empty && !Sent && Outdated) { Chat.Print("<b>AramBuddy: Update available for AramBuddy!</b>"); Chat.Print("<b>AramBuddy Update Log: " + UpdateMsg + "</b>"); Notifications.Show(new SimpleNotification("ARAMBUDDY OUTDATED", "Update Log: " + UpdateMsg), 25000); Sent = true; } }; } else { Logger.Send("AramBuddy is updated to the latest version!"); } } /*var WebClient = new WebClient(); * WebClient.DownloadStringTaskAsync(UpdateMsgPath); * WebClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args) * { * if (args.Cancelled || args.Error != null) * { * Logger.Send("Failed to get update Message.", Logger.LogLevel.Warn); * Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); * Logger.Send(args.Error?.InnerException?.Message, Logger.LogLevel.Warn); * return; * } * * UpdateMsg = args.Result; * * WebClient.Dispose(); * };*/ /* * var WebClient2 = new WebClient(); * WebClient2.DownloadStringTaskAsync(WebVersionPath); * WebClient2.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args) * { * if (args.Cancelled || args.Error != null) * { * Logger.Send("Failed to check live version.", Logger.LogLevel.Warn); * Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); * Logger.Send(args.Error?.InnerException?.Message, Logger.LogLevel.Warn); * return; * } * if (args.Cancelled) * { * Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); * Logger.Send(args.Error?.InnerException?.Message, Logger.LogLevel.Warn); * Console.WriteLine(args.Result); * } * if (!args.Result.Contains(CurrentVersion.ToString())) * { * Drawing.OnEndScene += delegate * { * text.Position = new Vector2(Drawing.Width * 0.01f, Drawing.Height * 0.1f); * text.Draw(); * }; * Outdated = true; * Logger.Send("Update available for AramBuddy!", Logger.LogLevel.Warn); * Logger.Send("Update Log: " + UpdateMsg); * } * else * { * Logger.Send("AramBuddy is updated to the latest version!"); * } * WebClient2.Dispose(); * }; * * Game.OnTick += delegate * { * if (UpdateMsg != string.Empty && !Sent && Outdated) * { * Chat.Print("<b>AramBuddy: Update available for AramBuddy!</b>"); * Chat.Print("<b>AramBuddy Update Log: " + UpdateMsg + "</b>"); * Notifications.Show(new SimpleNotification("ARAMBUDDY OUTDATED", "Update Log: " + UpdateMsg), 25000); * Sent = true; * } * };*/ } catch (Exception ex) { Logger.Send("Update check failed!", ex, Logger.LogLevel.Error); } }