#include "mologram/ProtocolMethods.hpp" namespace mologram { static std::vector split(const std::string& params, bool wantOptional) { std::vector out; if (params == "none") return out; size_t i = 0; while (i < params.size()) { size_t j = params.find(',', i); std::string p = params.substr(i, j == std::string::npos ? std::string::npos : j - i); size_t a = p.find_first_not_of(' '); p = a == std::string::npos ? "" : p.substr(a); bool opt = !p.empty() && p.back() == '?'; if (opt) p.pop_back(); if (!p.empty() && (wantOptional || !opt)) out.push_back(p); if (j == std::string::npos) break; i = j + 1; } return out; } std::vector MethodDef::required() const { return split(params, false); } std::vector MethodDef::accepted() const { return split(params, true); } const std::vector& ProtocolMethods::all() { static const std::vector m = { {"hello", "client?", "proto_version, account, premium state"}, {"auth.state", "none", "state"}, {"auth.send_phone", "phone", "sent, type, next_type, timeout"}, {"auth.send_code", "code", "state"}, {"auth.send_password", "password", "state"}, {"auth.qr_start", "none", "url"}, {"auth.logout", "none", "ok"}, {"dialogs.list", "folder?, offset?", "dialogs"}, {"dialogs.folders", "none", "folders"}, {"dialogs.pin", "peer, on", "ok"}, {"dialogs.mute", "peer, until", "ok"}, {"dialogs.mark_read", "peer", "ok"}, {"dialogs.archive", "peer, on", "ok"}, {"dialogs.delete", "peer", "ok"}, {"messages.history", "peer, offset_id?, direction?, count?", "messages"}, {"messages.send", "peer, text, reply_to?, schedule?, format?, entities?, effect?", "message"}, {"messages.edit", "peer, id, text, format?, entities?", "message"}, {"messages.delete", "peer, ids, revoke?", "ok"}, {"messages.forward", "from, to, ids", "messages"}, {"messages.pin", "peer, id, on", "ok"}, {"messages.react", "peer, id, reactions", "ok"}, {"messages.search", "peer?, query, filter?, offset_id?", "messages"}, {"messages.draft", "peer, text", "ok"}, {"messages.send_file", "peer, path, caption?, kind?", "message"}, {"messages.send_album", "peer, paths, caption?", "messages"}, {"messages.send_poll", "peer, question, options, multiple?, quiz?, correct?", "message"}, {"messages.vote", "peer, id, options", "ok"}, {"messages.click_button", "peer, id, data", "answer"}, {"media.download", "media, dest?, thumb?", "path"}, {"peer.info", "peer", "info"}, {"peer.members", "peer, offset?", "members"}, {"contacts.list", "none", "contacts"}, {"contacts.search", "query", "peers"}, {"contacts.add", "user, name", "ok"}, {"contacts.block", "user, on", "ok"}, {"chat.create", "kind, title, members?", "peer"}, {"chat.join", "link_or_name", "peer"}, {"chat.leave", "peer", "ok"}, {"chat.delete", "peer", "ok"}, {"chat.invite_link", "peer", "link"}, {"account.profile", "none", "profile"}, {"account.update_profile", "fields", "profile"}, {"account.sessions", "none", "sessions"}, {"account.terminate_session", "hash", "ok"}, {"account.privacy", "key", "rules"}, {"premium.state", "none", "state"}, {"premium.translate", "peer, id, to", "text"}, {"premium.transcribe", "peer, id", "text"}, {"premium.emoji_status", "document_id, until?", "ok"}, {"premium.profile_color", "color, background?", "ok"}, {"messages.pinned", "peer", "messages"}, {"messages.scheduled", "peer", "messages"}, {"messages.scheduled_delete", "peer, ids", "ok"}, {"messages.scheduled_send_now", "peer, ids", "ok"}, {"messages.send_sticker", "peer, sticker", "message"}, {"bot.commands", "peer", "commands"}, {"bot.inline", "bot, peer, query", "results"}, {"bot.inline_send", "peer, query_id, result_id", "message"}, {"contacts.import", "contacts", "imported"}, {"stickers.search", "query?", "stickers"}, {"emoji.custom", "query?", "emoji"}, {"stickers.sets", "emoji?", "sets"}, {"stickers.set", "short_name", "stickers"}, {"stickers.premium", "none", "stickers"}, {"account.set_privacy", "key, rule", "ok"}, {"account.notifications", "none", "scopes"}, {"account.set_notifications", "scope, muted", "ok"}, {"auth.resend_code", "none", "sent, type, next_type, timeout"}, {"chat.add_members", "peer, users", "ok"}, {"chat.remove_member", "peer, user", "ok"}, {"chat.set_admin", "peer, user, on", "ok"}, {"premium.promo", "none", "promo"}, {"premium.translate_toggle", "peer, disabled", "ok"}, {"premium.transcribe_rate", "peer, id, transcription_id, good", "ok"}, {"premium.emoji_statuses", "none", "statuses"}, {"premium.name_color", "color, background?", "ok"}, {"premium.reaction_tags", "peer?", "tags"}, {"premium.reaction_tag_set", "reaction, title?", "ok"}, {"premium.effects", "none", "effects"}, {"premium.wallpapers", "none", "wallpapers"}, {"premium.wallpaper_set", "peer, slug, for_both?", "ok"}, {"premium.wallpaper_remove", "peer", "ok"}, {"premium.privacy_global", "none", "settings"}, {"premium.privacy_global_set", "settings", "ok"}, {"premium.privacy_voice", "who", "ok"}, {"premium.custom_emoji", "ids", "documents"}, {"business.get", "none", "settings"}, {"business.hours_set", "hours?", "ok"}, {"business.location_set", "location?", "ok"}, {"business.greeting_set", "greeting?", "ok"}, {"business.away_set", "away?", "ok"}, {"business.intro_set", "intro?", "ok"}, {"business.bots", "none", "bots"}, {"business.bot_set", "bot, recipients, rights?, remove?", "ok"}, {"business.quick_replies", "none", "replies"}, {"business.quick_reply_messages", "id", "messages"}, {"business.quick_reply_add", "shortcut, text", "message"}, {"business.quick_reply_rename", "id, shortcut", "ok"}, {"business.quick_reply_delete", "id", "ok"}, {"business.quick_reply_send", "peer, id", "ok"}, {"business.chat_links", "none", "links"}, {"business.chat_link_create", "message, title?", "link"}, {"business.chat_link_delete", "slug", "ok"}, {"stories.list", "hidden?, state?", "stories"}, {"stories.peer", "peer", "stories"}, {"stories.read", "peer, max_id", "ok"}, {"stories.send", "path, caption?, privacy?, period?, pinned?", "story"}, {"stories.delete", "peer, ids", "ok"}, {"stories.views", "peer, ids", "views"}, {"stories.view_list", "peer, id, offset?, limit?", "views"}, {"stories.react", "peer, id, reaction", "ok"}, {"stories.archive", "peer, offset_id?, limit?", "stories"}, {"stories.stealth", "past?, future?", "ok"}, {"stories.pin", "peer, ids, pinned", "ok"}, {"stories.link", "peer, id", "link"}, {"gifts.list", "none", "gifts"}, {"gifts.saved", "peer, offset?, limit?", "gifts"}, {"gifts.stars", "peer?", "status"}, {"gifts.send", "peer, gift, message?, hide_name?, confirm", "result"}, {"payments.form", "peer, id", "form"}, {"payments.receipt", "peer, id", "receipt"}, {"passport.values", "none", "values"}, {"secret.list", "none", "chats"}, {"secret.request", "user", "chat"}, {"secret.accept", "chat", "chat"}, {"secret.discard", "chat, delete_history?", "ok"}, {"secret.send", "chat, text, ttl?", "message"}, {"secret.ttl", "chat, seconds", "ok"}, {"secret.typing", "chat, on", "ok"}, {"secret.fingerprint", "chat", "fingerprint"}, {"secret.history", "chat", "messages"}, {"calls.request", "user, video?", "call"}, {"calls.accept", "call", "call"}, {"calls.discard", "call, reason?, duration?", "ok"}, {"calls.rate", "call, stars, comment?", "ok"}, {"calls.list", "none", "calls"}, {"calls.group_create", "peer, title?", "group_call"}, {"calls.group_get", "call, access_hash", "group_call"}, {"calls.group_discard", "call, access_hash", "ok"}, {"dialogs.folder_set", "folder", "folder"}, }; return m; } const MethodDef* ProtocolMethods::find(const std::string& name) { for (const auto& m : all()) if (m.name == name) return &m; return nullptr; } } // namespace mologram