Ejemplo n.º 1
0
        public static async void Handle(object sender, CallbackQueryEventArgs e)
        {
            var callback = e.CallbackQuery;
            var message  = e.CallbackQuery.Message;

            var query = Regex.Match(callback.Data, @"^cmd=([\w\-]+)&data=(\S+)$");

            if (!query.Success)
            {
                _log.Error("Unknown: {0}", callback.Data);
                await BotClient.AnswerCallbackQueryAsync(callback.Id, "Perintah tidak diketahui", true);

                return;
            }

            var cmd  = query.Groups[1].Value;
            var data = query.Groups[2].Value;

            switch (cmd)
            {
            case "greeting":
                new Welcome(message, callback).Manage(data);
                break;

            case "call":
                if (await IsCallbackBlocked(callback, "Hashtag"))
                {
                    return;
                }
                await new Bookmark(message, callback).ForwardHashtag(data);
                break;

            case "generate":
                new Bookmark(message, callback).GenerateList(true, true);
                break;

            case "manage":
                new Bookmark(message, callback).ManageList();
                break;

            case "remove":
                new Bookmark(message, callback).DeleteWithButton(data);
                break;

            case "remove-final":
                new Bookmark(message, callback).DeleteWithButton(data, true);
                break;

            case "info":
                new Bookmark(message, callback).ShowInfo(data);
                break;

            case "mobilism":
                if (await IsCallbackBlocked(callback, "Mobilism"))
                {
                    return;
                }
                new Mobilism(message, callback).OpenThread(data);
                break;

            default:
                _log.Ignore("Unknown: {0}", callback.Data);
                await BotClient.AnswerCallbackQueryAsync(callback.Id, "Perintah tidak diketahui", true);

                break;
            }
        }