mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Do not parse sticker pack when removing from ban
Also added try-catch strategy when printing banned packs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using BotFramework.Attributes;
|
||||
using BotFramework.Enums;
|
||||
@@ -43,9 +44,9 @@ public partial class BanStickerSet
|
||||
}
|
||||
|
||||
[ParametrizedCommand(InChat.Public, "stick_unban", CommandParseMode.Both)]
|
||||
public async Task HandleUnBanSticker(StickerSet.Param stickerSet)
|
||||
public async Task HandleUnBanSticker(string stickerSet)
|
||||
{
|
||||
if (!await PreCommand(stickerSet))
|
||||
if (!await PreCommand())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -57,13 +58,16 @@ public partial class BanStickerSet
|
||||
return;
|
||||
}
|
||||
|
||||
var setName = stickerSet.Set.Name;
|
||||
if (!list.Exists(e => e == stickerSet))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
list.Remove(setName);
|
||||
list.Remove(stickerSet);
|
||||
option.SetValue(list);
|
||||
Db.AddOrUpdate(option);
|
||||
|
||||
await Reply(FormatStickerSetAction(stickerSet.Set, "разблокирован"));
|
||||
await Reply(FormatStickerSetAction(stickerSet, "разблокирован"));
|
||||
}
|
||||
|
||||
[Command(InChat.Public, "stick_banlist", CommandParseMode.Both)]
|
||||
@@ -82,10 +86,18 @@ public partial class BanStickerSet
|
||||
var htmlString = new HtmlString().Bold("Заблокированные наборы стикеров:").Br();
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
var stickerSet = await Bot.GetStickerSetAsync(list[i]);
|
||||
htmlString.Text($"{i + 1}. ")
|
||||
.Url("https://t.me/addstickers/" + stickerSet.Name, stickerSet.Title)
|
||||
.Br();
|
||||
try
|
||||
{
|
||||
var stickerSet = await Bot.GetStickerSetAsync(list[i]);
|
||||
htmlString.Text($"{i + 1}. ")
|
||||
.Url("https://t.me/addstickers/" + stickerSet.Name, stickerSet.Title)
|
||||
.Br();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Suppress error.
|
||||
// Maybe remove pack from ban, but this exception can be just a timeout or Internal Server Error.
|
||||
}
|
||||
}
|
||||
|
||||
msg = htmlString.ToString();
|
||||
|
||||
Reference in New Issue
Block a user