Exemplo n.º 1
0
        public override async Task HandleAsync(IUpdateContext context, UpdateDelegate next, string[] args,
                                               CancellationToken cancellationToken)
        {
            _requestProvider = new RequestProvider(context);

            var isSudoer = _requestProvider.IsSudoer();
            var isAdmin  = await _requestProvider.IsAdminGroup();

            if (isSudoer)
            {
                await _requestProvider.DeleteAsync(_requestProvider.Message.MessageId);

                await _requestProvider.AppendTextAsync("Sedang mengsinkronkan Word Filter");

                await DataHelper.SyncWordToLocalAsync();

                await _requestProvider.AppendTextAsync("Selesai mengsinkronkan.");

                await _requestProvider.DeleteAsync(delay : 3000);
            }
        }
        public override async Task HandleAsync(IUpdateContext context, UpdateDelegate next, string[] args,
                                               CancellationToken cancellationToken)
        {
            _requestProvider = new RequestProvider(context);
            var msg = context.Update.Message;

            var isSudoer = _requestProvider.IsSudoer();

            if (isSudoer)
            {
                var partedMsg = msg.Text.Split(" ");
                var param1    = partedMsg.ValueOfIndex(1);
                Log.Debug($"RssCtl Param1: {param1}");

                await _requestProvider.AppendTextAsync("Access Granted");

                switch (param1)
                {
                case "start":
                    await _requestProvider.AppendTextAsync("Starting RSS Service");

                    RssScheduler.InitScheduler();
                    await _requestProvider.AppendTextAsync("Start successfully.");

                    break;

                case "stop":
                    await _requestProvider.AppendTextAsync("Stopping RSS Service");

                    HangfireHelper.DeleteAllJobs();
                    await _requestProvider.AppendTextAsync("Stop successfully.");

                    break;
                }
            }
        }