public static async void top(Message mess) { try { BotMain.users = BotMain.users.OrderBy(m => m.balance).ToList(); string text = "Топ богатых игроков в этой группе:\n"; int i = 1; foreach (var item in BotMain.users) { Chat chat = await BotMain.bot.GetChatAsync(item.id); string name = $"{chat.FirstName} {chat.LastName}"; text += $"<b>{i}</b>. <i>{name}</i> -=<code>{item.balance}</code>=-\n"; i += 1; } await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html); } catch (Exception e) { Other.OnReceivedError(e, mess); } }
public static async void scores(Message mess) { try { osuApi osuapi = new osuApi(BotMain.osuToken); string beatmap_id = ""; for (int i = mess.Text.Length - 1; i >= 0; i--) { if (mess.Text[i] != '/') { beatmap_id = beatmap_id.Insert(0, mess.Text[i].ToString()); } else { break; } } string name = string.Join(" ", mess.Text.Split(" ").Skip(1).SkipLast(1)); Score[] scores = await osuapi.GetScoresOnMapByName(name, long.Parse(beatmap_id)); string text = ""; foreach (var item in scores) { Mods mods = (Mods)osuapi.CalculateModsMods(int.Parse(item.enabled_mods)); double accuracy = (50 * double.Parse(item.count50) + 100 * double.Parse(item.count100) + 300 * double.Parse(item.count300)) / (300 * (double.Parse(item.countmiss) + double.Parse(item.count50) + double.Parse(item.count100) + double.Parse(item.count300))) * 100; Beatmap beatmap = await osuapi.GetBeatmapByBeatmapIdAsync(int.Parse(beatmap_id)); double curpp = Other.ppCalc(beatmap, accuracy, mods, int.Parse(item.countmiss), int.Parse(item.maxcombo)); double IfFCpp = Other.ppCalc(beatmap, accuracy, mods, 0, int.Parse(beatmap.max_combo)); text += $"<b>({item.rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{item.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>({beatmap.GetApproved()})</b>\n" + $"{item.count300}-{item.count100}-{item.count50}-{item.countmiss}❌ - <b><i>{accuracy:N2}</i></b>%\n" + $"<b>{mods}</b> <i>{item.maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>~{IfFCpp:N0}pp</u></b> if FC)\n({DateTimeOffset.Parse(item.date).AddHours(5):dd.MM.yyyy HH:mm})\n\n"; } await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html); } catch (Exception e) { Other.OnReceivedError(e, mess, "Нет скоров"); } }
public static async void rs(Message mess) { try { string text = ""; osuApi osuApi = new osuApi(BotMain.osuToken); string name = string.Join(' ', mess.Text.Split(' ').Skip(1)); if (name == "") { await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, "а ты кто?\n!rs [name]"); return; } Score recentScore = (await osuApi.GetRecentScoresByNameAsync(name))[0]; if (recentScore == default) { throw new FormatException(); } Beatmap beatmap = await osuApi.GetBeatmapByBeatmapIdAsync(long.Parse(recentScore.beatmap_id)); Mods mods = (Mods)osuApi.CalculateModsMods(int.Parse(recentScore.enabled_mods)); double accuracy = (50 * double.Parse(recentScore.count50) + 100 * double.Parse(recentScore.count100) + 300 * double.Parse(recentScore.count300)) / (300 * (double.Parse(recentScore.countmiss) + double.Parse(recentScore.count50) + double.Parse(recentScore.count100) + double.Parse(recentScore.count300))) * 100; double curpp = Other.ppCalc(beatmap, accuracy, mods, int.Parse(recentScore.countmiss), int.Parse(recentScore.maxcombo)); double ppIFfc = Other.ppCalc(beatmap, accuracy, mods, 0, int.Parse(beatmap.max_combo)); text += $"<b>({recentScore.rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{beatmap.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>({beatmap.GetApproved()})</b>\n" + $"{recentScore.count300}-{recentScore.count100}-{recentScore.count50}-{recentScore.countmiss}❌ - <b><i>{accuracy:N2}</i></b>%\n" + $"<b>{mods}</b> <i>{recentScore.maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>~{ppIFfc:N0}pp</u></b> if FC)\n({DateTimeOffset.Parse(recentScore.date).AddHours(5):dd.MM.yyyy HH:mm})\n\n"; await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text, ParseMode.Html); } catch (FormatException e) { Other.OnReceivedError(e, mess, "Он ничего не играл последние 24 часа."); } catch (Exception e) { Other.OnReceivedError(e, mess, "Чет не получилось :("); } }
public static async void bandit(Message mess) { try { long bet = Other.getbet(mess); if (bet == -1) { await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, "Кажется, что у вас не хватает монет, либо ставка слишком велика / неправильный формат ставки"); return; } string name = $"{mess.From.FirstName} {mess.From.LastName}"; string text = $"{name}:Ставка {bet}\n[🎁][🎁][🎁]"; string[] emoji = new string[18] { "👻", "🎱", "💥", "🍄", "🦆", "🐴", "🌑", "🤡", "🌕", "🌒", "🌖", "🌓", "🐞", "🐭", "🎢", "⚡️", "💊", "💣" }; double coff = 1; Message bandit = await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text); for (int i = 0; i <= 2; i++) { int rnd = RandomNumberGenerator.GetInt32(0, 18); if (emoji[rnd] == "🌑") { coff = (coff * 0.5); } else if (emoji[rnd] == "🍄") { coff = (coff * 0.7); } else if (emoji[rnd] == "🌕") { coff = (coff * 2); } else if (emoji[rnd] == "🌖") { coff = (coff * 1.25); } else if (emoji[rnd] == "🌒") { coff = (coff * 0.75); } else if (emoji[rnd] == "🌓") { coff = (coff * 1); } else if (emoji[rnd] == "💥") { coff = (coff * 1.75); } else if (emoji[rnd] == "🐞") { coff = coff * 1.3; } else if (emoji[rnd] == "🤡") { coff = coff / 1.5; } else if (emoji[rnd] == "🎢") { coff = (coff * 0.7); } else if (emoji[rnd] == "⚡️") { int lightning = RandomNumberGenerator.GetInt32(1, 31); coff = (coff * ((double)((double)lightning / (double)10))); } else if (emoji[rnd] == "🎱") { coff = coff * 2.5; } else if (emoji[rnd] == "💣") { coff = coff * 0.2; } else if (emoji[rnd] == "🐴") { coff = (coff * 0.8); } else if (emoji[rnd] == "🦆") { coff = (coff * 1.15); } else if (emoji[rnd] == "🐭") { coff = coff * 0.85; } else if (emoji[rnd] == "👻") { coff = Math.Pow(coff, 1.5); } else if (emoji[rnd] == "💊") { int capsule = RandomNumberGenerator.GetInt32(1, 3); if (capsule == 1) { coff = coff * 0; } else if (capsule == 2) { coff = coff * 2; } } var index = text.IndexOf("🎁"); text = text.Remove(index, 2).Insert(index, emoji[rnd]); if (i == 2) { text += $"\nВы выиграли: {(long)(bet * coff) - bet}"; Other.changeBalance(mess.From, (long)(bet * coff) - bet); } await Task.Delay(2000); await BotMain.bot.EditMessageTextAsync(bandit.Chat.Id, bandit.MessageId, text); } } catch (Exception e) { Other.OnReceivedError(e, mess, $"Произошла ошибка. Напишите \"/report текст проблемы\" в чат, чтобы дать разработчику узнать о проблеме."); } }
public static async void notifyFunc() { while (true) { await Task.Run(() => { try { for (int i = 0; i <= BotMain.osuUserTGs.Count - 1; i++) { osuApi osuApi = new osuApi(BotMain.osuToken); Score[] recentScores = osuApi.GetRecentScoresByNameAsync(BotMain.osuUserTGs[i].name, 100).Result; if (recentScores == null) { continue; } int start = recentScores.Length - 1; bool startgot = false; for (int q = recentScores.Length - 1; q >= 0; q--) { if (DateTimeOffset.Parse(recentScores[q].date) > BotMain.osuUserTGs[i].lastCheckedScore) { start = q; startgot = true; break; } } if (!startgot) { continue; } for (int j = start; j >= 0; j--) { double accuracy = (50 * double.Parse(recentScores[j].count50) + 100 * double.Parse(recentScores[j].count100) + 300 * double.Parse(recentScores[j].count300)) / (300 * (double.Parse(recentScores[j].countmiss) + double.Parse(recentScores[j].count50) + double.Parse(recentScores[j].count100) + double.Parse(recentScores[j].count300))) * 100; Beatmap beatmap = osuApi.GetBeatmapByBeatmapIdAsync(int.Parse(recentScores[j].beatmap_id)).Result; if (beatmap == null) { continue; } double curpp = Other.ppCalc(beatmap, accuracy, (Mods)osuApi.CalculateModsMods(int.Parse(recentScores[j].enabled_mods)), int.Parse(recentScores[j].countmiss), int.Parse(recentScores[j].maxcombo)); double ifFCpp = Other.ppCalc(beatmap, accuracy, (Mods)osuApi.CalculateModsMods(int.Parse(recentScores[j].enabled_mods)), 0, int.Parse(beatmap.max_combo)); Mods mods = (Mods)osuApi.CalculateModsMods(int.Parse(recentScores[j].enabled_mods)); if (curpp > 200 && recentScores[j].rank != "F") { foreach (var item in BotMain.groups) { if (item.notifyOsu) { BotMain.bot.SendTextMessageAsync(item.id, $"<b><u>{BotMain.osuUserTGs[i].name}</u></b> недавно прошел данную карту, набрав <i>{curpp:N0}pp</i>!\n" + $"<b>({recentScores[j].rank})</b> <a href=\"https://osu.ppy.sh/beatmaps/{beatmap.beatmap_id}\">{beatmap.title} [{beatmap.version}]</a> <b>{osuApi.GetBeatmapByBeatmapIdAsync(int.Parse(beatmap.beatmap_id)).Result.GetApproved()}</b>\n" + $"{recentScores[j].count300}-{recentScores[j].count100}-{recentScores[j].count50}-{recentScores[j].countmiss}x❌ - <b><i>{accuracy:N2}%</i></b>\n" + $"<b>{mods}</b> <i>{recentScores[j].maxcombo}/{beatmap.max_combo}</i> <b><u>{curpp:N0}pp</u></b> (<b><u>{ifFCpp:N0}pp</u></b> if FC)\n" + $"{DateTimeOffset.Parse(recentScores[j].date).AddHours(5):dd.MM.yyyy HH:mm}", ParseMode.Html, disableNotification: true).Wait(); } } } BotMain.osuUserTGs[i].lastCheckedScore = DateTimeOffset.Parse(recentScores[j].date); } } } catch (Exception ex) { Other.OnReceivedError(ex, null, ""); } }); } }
public static async void AllGroups(Message mess) { try { string[] ab = mess.Text.Split(" "); string text = ""; if (ab[1] == "all") { int count = 0; for (int i = 0; i <= BotMain.groups.Count - 1; i++) { try { count += 1; var t = await BotMain.bot.GetChatAsync(BotMain.groups[i].id); text += $"{count}. {t.Title} [{i}]\n"; } catch (Exception) { BotMain.groups.RemoveAt(i); i--; } } await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, text); } else if (ab[1] == "toall") { for (int i = 0; i <= BotMain.groups.Count - 1; i++) { if (BotMain.groups[i].id.ToString().StartsWith("-100")) { try { await BotMain.bot.SendTextMessageAsync(BotMain.groups[i].id, string.Join(" ", ab.Skip(2))); } catch (Exception) { BotMain.groups.RemoveAt(i); i--; } } } } else if (ab[1] == "to") { try { await BotMain.bot.SendTextMessageAsync(BotMain.groups[int.Parse(ab[2])].id, string.Join(" ", ab.Skip(3))); } catch (Exception) { } } else if (ab[1] == "replyto") { try { Message messreply = mess.ReplyToMessage; string caption = ""; if (mess.ReplyToMessage.Photo != null) { if (mess.ReplyToMessage.Caption != null) { caption = mess.ReplyToMessage.Caption; } await BotMain.bot.SendPhotoAsync(BotMain.groups[int.Parse(ab[2])].id, new InputOnlineFile(mess.ReplyToMessage.Photo[0].FileId), caption : caption); } else if (mess.ReplyToMessage.Sticker != null) { await BotMain.bot.SendStickerAsync(BotMain.groups[int.Parse(ab[2])].id, new InputOnlineFile(mess.ReplyToMessage.Sticker.FileId)); } else if (mess.ReplyToMessage.Video != null) { if (mess.ReplyToMessage.Caption != null) { caption = mess.ReplyToMessage.Caption; } await BotMain.bot.SendVideoAsync(BotMain.groups[int.Parse(ab[2])].id, new InputOnlineFile(mess.ReplyToMessage.Video.FileId), caption : caption); } } catch (Exception) { } } else if (ab[1] == "fromall") { for (int i = 0; i <= BotMain.groups.Count - 1; i++) { if (BotMain.groups[i].id.ToString().StartsWith("-100")) { try { await BotMain.bot.SendTextMessageAsync(BotMain.groups[i].id, string.Join(" ", ab.Skip(2))); await BotMain.bot.LeaveChatAsync(BotMain.groups[i].id); BotMain.groups.RemoveAt(i); } catch (Exception) { BotMain.groups.RemoveAt(i); i--; } } } } else if (ab[1] == "from") { try { int ind = int.Parse(ab[2]); if (ab.Length >= 4) { await BotMain.bot.SendTextMessageAsync(BotMain.groups[ind].id, string.Join(" ", ab.Skip(3))); } await BotMain.bot.LeaveChatAsync(BotMain.groups[ind].id); BotMain.groups.RemoveAt(ind); } catch (Exception) { } } else if (ab[1] == "remove") { BotMain.groups.RemoveAt(int.Parse(ab[2])); } } catch (Exception e) { Other.OnReceivedError(e, mess, ""); await BotMain.bot.SendTextMessageAsync(mess.Chat.Id, "/groups\nremove [index] - del from bd\nfrom [ind] [mes] - leave + send mes\nfromall [mes] - leave from all + send mes\nto [ind] [mes] - send mes to group\ntoall [mes] - send mes to all groups\nall - get groups index"); } }