Exemplo n.º 1
0
    public async Task <bool> ExecuteAsync()
    {
        Log.Information("Receiving Verify Callback");

        var callbackData = _callbackQuery.Data;
        var chatId       = _callbackQuery.Message.Chat.Id;
        var fromId       = _callbackQuery.From.Id;

        Log.Information(
            "CallbackData: {CallbackData} from {FromId}",
            callbackData,
            fromId
            );

        var partCallbackData = callbackData.Split(" ");
        var action           = partCallbackData.ValueOfIndex(1);
        var target           = partCallbackData.ValueOfIndex(2).ToInt();
        var isAdmin          = await _privilegeService.IsAdminAsync(chatId, fromId);

        if (!isAdmin)
        {
            Log.Information("UserId: {FromId} is not Admin in this chat!", fromId);
            return(false);
        }

        switch (action)
        {
        case "remove-warn":
            Log.Information("Removing warn for {Target}", target);
            // await _telegramService.RemoveWarnMemberStatAsync(target);
            await _telegramService.EditMessageCallback($"Peringatan untuk UserID: {target} sudah di hapus");

            break;

        default:
            Log.Information("Action {Action} is undefined", action);
            break;
        }

        await _telegramService.AnswerCallbackQueryAsync("Succed!");

        return(true);
    }