コード例 #1
0
        public override async Task HandleAsync(IUpdateContext context, UpdateDelegate next, string[] args, CancellationToken cancellationToken)
        {
            _chatProcessor = new ChatProcessor(context);
            var msg      = context.Update.Message;
            var partsMsg = msg.Text.GetTextWithoutCmd().Split("|").ToArray();

            var isSudoer = _chatProcessor.IsSudoer();

            if (isSudoer)
            {
                var sendText = "Maaf, saya harus keluar";

                if (partsMsg[1] != null)
                {
                    sendText += $"\n{partsMsg[1]}";
                }
                var chatId = partsMsg[0].ToInt64();

                ConsoleHelper.WriteLine($"Target out: {chatId}");
                await _chatProcessor.SendAsync(sendText, customChatId : chatId);

                await _chatProcessor.LeaveChat(chatId);
            }
            else
            {
                await _chatProcessor.SendAsync("Kamu tidak punya hak akses.");
            }
        }