Bots like on Telegram — migration, inline, payments

MRIYU's Telegram-compatible Bot API: how to move a bot from Telegram, inline mode, buttons, Mini Apps and payments in coupons.

Besides its own Bot API (see Bot API), MRIYU has a Telegram-compatible layer: requests like https://<service address>/bot<TOKEN>/<method> with the same methods and updates as Telegram. A bot written for Telegram usually moves over by changing the API address and the token.

How to move a bot

  1. Create a bot with @mriyu_father — how to — and take its token.
  2. In your library, replace the base API address with the address of the MRIYU Bot API service (shown in the developer cabinet, the bot's "Connection" tab):
    • python-telegram-bot, aiogram — base_url / TelegramAPIServer;
    • node-telegram-bot-api — baseApiUrl; telegraf and grammY — apiRoot;
    • plain HTTP requests — just a different host.
  3. Updates work as on Telegram: getUpdates with offset and timeout, or setWebhook (the X-Telegram-Bot-Api-Secret-Token header if secret_token is set).
  4. The person must tap "Start" — until then the bot can't write to them.

What works

Feature Methods and updates
Messages sendMessage (HTML, Markdown, MarkdownV2), editMessageText, editMessageCaption, editMessageReplyMarkup, deleteMessage, sendPhoto, sendDocument, sendVideo, sendAudio, sendVoice, sendLocation, sendContact, getFile
Buttons inline_keyboard (callback_data, url, web_app), answerCallbackQuery (text, show_alert window, link), keyboard under the input field, ReplyKeyboardRemove, ForceReply, sendChatAction ("typing…")
Groups and channels getChat, getChatAdministrators, getChatMemberCount, banChatMember, leaveChat, pinChatMessage, exportChatInviteLink, promoteChatMember
Mini Apps web_app button, setChatMenuButton, Telegram.WebApp (initData, MainButton, BackButton, haptics, popups), web_app_data
Inline mode inline_query, answerInlineQuery, chosen_inline_result
Payments sendInvoice, pre_checkout_query, answerPreCheckoutQuery, successful_payment, refundStarPayment
Profile setMyName, setMyDescription, setMyShortDescription, setMyCommands, getMyCommands

Inline mode

A person types @weather_bot kyiv in any chat, the bot receives inline_query, answers with answerInlineQuery, and the person picks a result from the list.

  • Turn it on in the developer cabinet or with /setinline in @mriyu_father (the input hint is set there too).
  • Supported results are article (title and input_message_content.message_text) and photo (an https photo_url), up to 50, with cache_time and next_offset.
  • The chosen result is sent as an ordinary message from the person with a "via @bot" line; the bot gets chosen_inline_result.
  • There are no buttons on inline results and no gif/video results yet.
  • The person agrees once that their query goes to the bot.

Payments in coupons

A bot can send an invoice in a private chat. The currency is MRIYU coupons (the site's internal currency, not money); on Telegram that corresponds to Stars.

  1. The bot calls sendInvoice: title (up to 32 characters), description, payload, currency — XTR or KUNY, prices (the amount total is in coupons). provider_token isn't needed.
  2. An invoice card with a "Pay" button appears in the chat.
  3. The bot receives pre_checkout_query and must answer with answerPreCheckoutQuery within 15 seconds; with no answer the payment is cancelled.
  4. After ok, coupons are taken from the person and go to the bot's owner (minus the site's fee), and the bot gets successful_payment with telegram_payment_charge_id.
  5. A payment can be refunded with refundStarPayment — the person gets the full amount back, and the bot's owner must have enough coupons.

Payments work when monetization is turned on for the site. Administrators can switch bot payments off entirely: then sendInvoice returns a 403 error and unpaid invoices can't be paid. Coupons can't be topped up with money in apps from Google Play — there they can only be spent.

How it differs from Telegram

  • Payments are coupons only and only in private chats.
  • Mini Apps are available only to bots owned by site administrators; the window opens over https from a foreign domain (not mriyu.com).
  • Groups have only the owner, admin and member roles: no persistent bans, per-admin rights, join requests or chat_member updates; restrictChatMember and setChatPermissions aren't supported.
  • No sendPoll, sendSticker, sendMediaGroup, forwardMessage, copyMessage, editMessageMedia, or command scopes and languages.
  • Group and channel IDs in this API are negative, as on Telegram; file_ids are valid only on MRIYU.
  • Limits: 30 messages per second per bot and 20 per minute to one person; updates are kept for 24 hours.

See also: Bot API, MRIYU Father, Bots.