{"id":13571707,"url":"https://github.com/Daeren/telegram-bot-api-c","last_synced_at":"2025-04-04T08:32:02.920Z","repository":{"id":57376628,"uuid":"42376141","full_name":"Daeren/telegram-bot-api-c","owner":"Daeren","description":"[NodeJS] Lightweight, Simple, Fastest module for Telegram Bot without Dependencies","archived":false,"fork":false,"pushed_at":"2017-11-22T00:35:37.000Z","size":597,"stargazers_count":16,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-21T20:58:50.787Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Daeren.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-12T22:57:47.000Z","updated_at":"2023-07-30T17:39:11.000Z","dependencies_parsed_at":"2022-08-29T21:20:46.506Z","dependency_job_id":null,"html_url":"https://github.com/Daeren/telegram-bot-api-c","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daeren%2Ftelegram-bot-api-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daeren%2Ftelegram-bot-api-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daeren%2Ftelegram-bot-api-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Daeren%2Ftelegram-bot-api-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Daeren","download_url":"https://codeload.github.com/Daeren/telegram-bot-api-c/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247147561,"owners_count":20891723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T14:01:05.140Z","updated_at":"2025-04-04T08:31:57.913Z","avatar_url":"https://github.com/Daeren.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![Codacy][cod_b]][cod_l] ![NodeSecurity][node_sec_b]\n\n```\nnpm -g install telegram-bot-api-c\ngit clone https://github.com/Daeren/telegram-bot-api-c.git\n```\n\n\n```js\nrequire(\"telegram-bot-api-c\").call(\"TK\", \"sendMessage\", [0, \"+\"])\n```\n\n```js\nrequire(\"telegram-bot-api-c\")(\"TK\").api.sendMessage({chat_id: 0, text: \"+\"})\n```\n\n```js\nrequire(\"telegram-bot-api-c\")(\"TK\").polling(bot =\u003e bot.answer().html(\"+\").send())\n```\n\n```js\n\u003e tg-bot --token TK --method sendMessage --chat_id 0 --text \"+\"\n```\n\n\n[Telegram Bot API][3], [Bot API 2.x][100], Bot API 3.5\n\n* [Proxy](#refProxy): +\n* Array and [Map][10] as a data source (.call, .callJson, .api[method]): +\n* Analytics: [tgb-pl-botanio][4]\n* Added: tgBot.api[sendMethod] =\u003e error.retryAfter\n* Added: [sendMediaGroup][150] (doesn't support \"attach://\")\n\n\n```\n- All methods in the Bot API are case-insensitive (method: .call, .callJson)\n\n- message:                                             buffer, stream, string\n- location|venue|contact:                              buffer, string\n- photo|audio|voice|video|document|sticker|video_note: buffer, stream, file_id, path, url\n- certificate:                                         buffer, stream, path, url\n```\n\n\n#### Goals:\n1. High stability;\n2. Low memory usage;\n3. Maximum performance;\n4. Flexibility.\n\n\n#### Index\n\n* [Start](#refStart)\n* [Proxy](#refProxy)\n* [Polling](#refPolling)\n* [HTTP](#refHTTP)\n* [Virtual](#refVirtual)\n* [mServer](#refMServer)\n* [Nginx + Node.js](#refExampleNginxNodejs)\n* [Response Builder](#refResponseBuilder)\n* [Tg Upload](#refTgUpload)\n* [Plugin](#refPlugin)\n* [Goto](#refGoto)\n* [JS Generators](#refJSGenerators)\n* [Render](#refRender)\n* [Keyboard](#refKeyboard)\n* [Download](#refDownload)\n* [InlineQuery](#refInlineQuery)\n* [Send file as Buffer](#refSendFileAsBuffer)\n* [CLI](#refCLI)\n* [Test](#refTest)\n\n\n\n![architecture][image-architecture]\n\n\n\n\u003ca name=\"refStart\"\u003e\u003c/a\u003e\n\n```js\nconst rTgBot    = require(\"telegram-bot-api-c\");\n\nconst gBot      = rTgBot(process.env.TELEGRAM_BOT_TOKEN),\n      gApi      = gBot.api;\n\n//----------------------------]\u003e\n\ngBot.promise(require(\"bluebird\"));\n\n//----------------------------]\u003e\n\ngApi\n    .sendMessage([\"0\", \"Hi\"])\n    .then(console.info, console.error);\n    \ngApi.sendMessage([\"0\", \"Hi\"], (e, data) =\u003e console.log(e || data));\n\n// e    - Error: request/JSON.parse/response.ok\n// data - JSON: response.result or null\n\n//-------]\u003e\n\ngBot.callJson(\"sendMessage\", [\"0\", \"Hi\"], (e, data, res) =\u003e console.log(e || data));\n\n// e    - Error: request/JSON.parse\n// data - JSON: response or null\n// res  - Class: http.IncomingMessage or null\n\n//-------]\u003e\n\ngBot.call(\"sendMessage\", [\"0\", \"Hi\"], (e, data, res) =\u003e console.log(e || data));\n\n// e    - Error: request\n// data - Buffer: response or null\n// res  - Class: http.IncomingMessage or null\n\n//------------]\u003e\n\n/*\n  e.code           - gApi.sendMessage( ...\n  data.error_code  - callJson(\"sendMessage\" ...\n\n  rTgBot or gBot\n\n  gBot.ERR_INTERNAL_SERVER\n  gBot.ERR_NOT_FOUND\n  gBot.ERR_FORBIDDEN\n  gBot.ERR_MESSAGE_LIMITS\n  gBot.ERR_USED_WEBHOOK\n  gBot.ERR_INVALID_TOKEN\n\n  gBot.ERR_BAD_REQUEST\n  gBot.ERR_BAD_PROXY\n  gBot.ERR_FAILED_PARSE_DATA\n*/\n\n//----------------------------]\u003e\n\ngBot\n    .polling(onDefault)\n    .catch(onError)\n    \n    .use(bot =\u003e \"syncGotoMyMenu\")\n    .use((bot, data, next) =\u003e next(new Error(\"never get\")))\n    .use(\"/start\", bot =\u003e { })\n\n    .on(\"/start\", onCmdStart_1)\n    .on(\"/start\", onCmdStart_2)\n    .on(\"/start\", onCmdStart_3)\n\n    .on(\"enterChat\", onEnterChat)\n    .on(\"text:syncGotoMyMenu\", onText)\n    .on(\"photo document\", onPhotoOrDoc)\n    .on(\"pinnedMessage\", onPinnedMessage)\n\n    .on(/^id\\s+(\\d+)/i, onTextRegEx)\n    .on(/^(id)\\s+(\\d+)/i, \"type id\", onTextRegEx)\n    .on(/^(login)\\s+(\\w+)/i, [\"type\", \"login\"], onTextRegEx);\n\n\nfunction onDefault(bot) { }\nfunction onError(error) { }\n\nfunction onCmdStart_1(bot, params, next) { next(); } // \u003c-- Async\nfunction onCmdStart_2(bot, params) { }               // \u003c-- Sync\nfunction onCmdStart_3(bot, params) { }               // \u003c-- Sync | end\n\nfunction onEnterChat(bot, member) { }\nfunction onText(bot, text) { }\nfunction onPhotoOrDoc(bot, data) { }\nfunction onPinnedMessage(bot, message) { }\n\nfunction onTextRegEx(bot, data) { }\n\n//-----------]\u003e\n\n/*\n  bot                               | gBot -\u003e Sugar -\u003e CtxPerRequest\n  bot instanceof gBot.constructor   | true\n  \n  bot.command.type                  | common or private\n  \n  /start [text]         -\u003e common\n  /start@bot [text]     -\u003e private\n  @bot /start [text]    -\u003e private\n*/\n```\n\n\n\n\u003ca name=\"refProxy\"\u003e\u003c/a\u003e\n#### Proxy\n\n```js\nconst gBot      = rBot(process.env.TELEGRAM_BOT_TOKEN);\n\nconst gProxyStr = \"127.0.0.1:1337\", // \u003c-- Only HTTPS\n      gProxyArr = [\"127.0.0.1\", \"1337\"],\n      gProxyObj = {\n          \"host\": \"127.0.0.1\",\n          \"port\": 1337\n      };\n\n//------------------]\u003e\n\nfunction getMe(callback) { gBot.api.getMe(callback); }\n\n//------------------]\u003e\n\ngBot.proxy(gProxyObj);\n\ngetMe(t =\u003e {\n    objBot.proxy(gProxyStr);\n\n    getMe(t =\u003e {\n        objBot.proxy(); // \u003c-- Remove\n        getMe();\n    });\n});\n\nrBot.callJson({\n    \"token\":    process.env.TELEGRAM_BOT_TOKEN,\n    \"method\":   \"getMe\",\n    \"proxy\":    gProxyArr\n}, (e, d) =\u003e {});\n\nrBot.callJson(process.env.TELEGRAM_BOT_TOKEN, \"getMe\", (e, d) =\u003e {}, gProxyObj);\n```\n\n\n\n\u003ca name=\"refPolling\"\u003e\u003c/a\u003e\n#### Polling\n\n```js\nconst gBot      = rBot(process.env.TELEGRAM_BOT_TOKEN);\n\nconst gOptions  = {\n    \"limit\":    100,\n    \"timeout\":  0,\n    \"interval\": 2 // \u003c-- Default / Sec.\n};\n\n//------------------]\u003e\n\nconst gSrv = gBot\n    .polling(gOptions, onMsg)\n    .on(\"/stop\", onCmdStop);\n    \n//------------------]\u003e\n\nfunction onMsg(bot) {\n    const msg = bot.isGroup \u0026\u0026 bot.isReply ? \"\u003e_\u003e\" : \"Stop me: /stop\";\n    bot.answer().isReply().text(msg).send();\n}\n\nfunction onCmdStop(bot, params) {\n    gSrv.stop();\n    bot.answer().text(JSON.stringify(params)).send();\n}\n```\n\n\n\n\u003ca name=\"refHTTP\"\u003e\u003c/a\u003e\n#### HTTP\n\n```js\nconst rBot = require(\"telegram-bot-api-c\");\n\n//-----------------------------------------------------\n\nconst gSrvOptions   = {\n    // For Self-signed certificate, you need to upload your public key certificate\n    // \"selfSigned\":  \"fullPath/stream/buffer\",  // \u003c-- If you use Auto-Webhook\n\n    \"certDir\":  \"/www/site\",\n\n    \"key\":       \"/3_site.xx.key\",\n    \"cert\":      \"/2_site.xx.crt\",\n    \"ca\":       [\n        \"/AddTrustExternalCARoot.crt\",\n        \"/COMODORSAAddTrustCA.crt\",\n        \"/COMODORSADomainValidationSecureServerCA.crt\"\n    ],\n\n    \"host\":     \"site.xx\"\n};\n\n//------------------]\u003e\n\nconst gBotFather    = rBot();\n\nconst gMyBot        = rBot(process.env.TG_BOT_TOKEN_MY),\n      gOtherBot     = rBot(process.env.TG_BOT_TOKEN_OTHER);\n\nconst gSrv          = gBotFather.http(gSrvOptions);\n\ngSrv\n    .bot(gMyBot)                                    // \u003c-- Auto-Webhook: \"/tg_bot_\u003csha256(token)\u003e\"\n    .on(\"/start\", onCmdStart)\n    .on(\"/stop\", onCmdStop);\n\ngSrv\n    .bot(gOtherBot, \"/urlOtherBot\", onMsgOtherBot); // \u003c-- Auto-Webhook\n    \n//------------------]\u003e\n\nfunction onMsgOtherBot(bot) { }\n\nfunction onCmdStart(bot, params) { }\nfunction onCmdStop(bot, params) { }\n```\n\n\n\n\u003ca name=\"refVirtual\"\u003e\u003c/a\u003e\n#### Virtual\n\n```js\nconst gBot = rBot(process.env.TELEGRAM_BOT_TOKEN);\n\nconst gSrv = gBot\n    .virtual(function(bot) {\n        bot.answer().text(\"Not found!\").send();\n    })\n    .on(\"photo\", console.log);\n\n//----[Proxy: express]----}\u003e\n\ngBot\n    .api\n    .setWebhook({\"url\": \"https://site.xx/dev-bot\"})\n    .then(function(isOk) {\n        const rExpress      = require(\"express\"),\n              rBodyParser   = require(\"body-parser\");\n\n        rExpress()\n            .use(rBodyParser.json())\n            .post(\"/dev-bot\", gSrv.middleware)\n            .listen(3000, \"localhost\");\n    });\n    \n//----[Stress Tests]----}\u003e\n\ngSrv.input(null, {\n    \"update_id\": 0,\n    \"message\": {\n        \"message_id\": 0,\n\n        \"from\": {\n            \"id\": 0,\n            \"first_name\": \"D\",\n            \"username\": \"\"\n        },\n\n        \"chat\": {\n            \"id\": 0,\n            \"first_name\": \"D\",\n            \"username\": \"\",\n            \"type\": \"private\"\n        },\n\n        \"date\": 0,\n        \"text\": \"Hello\"\n    }\n});\n```\n\n\n\n\u003ca name=\"refMServer\"\u003e\u003c/a\u003e\n#### mServer\n\n```js\nconst gBot = rBot(process.env.TELEGRAM_BOT_TOKEN);\n\ngBot\n    .api\n    .setWebhook({\"url\": \"https://site.xx/myBot\"})\n    .then(function(isOk) {\n        if(!isOk) {\n            throw new Error(\"Oops...problem with the webhook...\");\n        }\n\n        gBot.http(gSrvOptions, cbMsg);\n    });\n```\n\n\n\n\u003ca name=\"refExampleNginxNodejs\"\u003e\u003c/a\u003e\n#### NGINX + Node.js\n\n```js\nconst gBot          = rBot();\nconst gSrvOptions   = {\n    \"ssl\":          false,\n\n    \"autoWebhook\":  \"site.xx:88\", // \u003c-- Default: (host + port); `false` - disable\n\n    \"host\":         \"localhost\",\n    \"port\":         1490\n};\n\ngBot.http(gSrvOptions, onMsg);\n\n//----[DEFAULT]----}\u003e\n\ngBot.http();\ngBot.http(onMsg);\n\n// host: localhost\n// port: 1488\n// autoWebhook: false\n// ssl: false\n```\n\n\n\n\u003ca name=\"refResponseBuilder\"\u003e\u003c/a\u003e\n#### Response Builder\n```js\nobjSrv\n    .use(function(bot) {\n        bot\n            .answer() // \u003c-- Builder + Queue\n\n            .chatAction(\"typing\") // \u003c-- Element\n\n            .text(\"https://google.com\", \"markdown\") // \u003c-- Element\n            //.parseMode(\"markdown\")\n            .disableWebPagePreview() // \u003c-- Modifier (for the last element)\n            .keyboard([[\"X\"], [\"Y\"]]) // \u003c-- Modifier\n            \n            .markdown(\"*text*\") // \u003c-- Element\n            .html(\"\u003ca\u003etext\u003c/a\u003e\")\n\n            .chatAction(\"upload_photo\")\n            \n            .photo(\"https://www.google.ru/images/logos/ps_logo2.png\", \"myCaption\")\n            .caption(\"#2EASY\") // \u003c-- Modifier\n            .keyboard(\"old\")\n            .keyboard(\"new\", \"selective\") // \u003c-- Uses: bot.mid (selective)\n\n            .location(69, 96)\n            .latitude(13)\n            .keyboard() // \u003c-- Hide\n\n            .send() // \u003c-- Uses: bot.cid\n\n            .then(console.log);  // \u003c-- Return: array | results\n        \n        //------[ONE ELEMENT]------}\u003e\n        \n        const customKb = {\n            \"keyboard\":         [[\"1\"], [\"2\"], [\"3\"]],\n            \"resize_keyboard\":  true\n        };\n\n        bot\n            .answer()\n            .text(\"Hi\")\n            .keyboard(customKb)\n            .send((e, r) =\u003e console.log(e || r));  // \u003c-- Return: hashTable | result\n\n        //------[RENDER]------}\u003e\n        \n        const template = \"Hi, {name}!\";\n        const buttons = [[\"{btnMenu}\", \"{btnOptions}\"]];\n        const input = {\n            \"name\":         \"MiElPotato\",\n\n            \"btnMenu\":      \"Menu +\",\n            \"btnOptions\":   \"Options\"\n        };\n\n        bot\n            .answer()\n            .text(template)\n            .keyboard(buttons, \"resize\")\n            .render(input) // \u003c-- text + keyboard\n            .send();\n            \n        bot\n            .answer()\n            .text(\"Msg: {0} + {1}\")\n            .render([\"H\", \"i\"]) // \u003c-- text\n            .keyboard([[\"X: {0}\", \"Y: {1}\"]])\n            .send();\n    });\n```\n\n| Name                    | Args                                                                                                          |\n|-------------------------|---------------------------------------------------------------------------------------------------------------|\n|                         | -                                                                                                             |\n| html                    |  text, disable_web_page_preview, disable_notification, reply_to_message_id, reply_markup                      |\n| markdown                |  text, disable_web_page_preview, disable_notification, reply_to_message_id, reply_markup                      |\n|                         | -                                                                                                             |\n| text                    |  text, parse_mode, disable_web_page_preview, disable_notification, reply_to_message_id, reply_markup          |\n| photo                   |  photo, caption, disable_notification, reply_to_message_id, reply_markup                                      |\n| audio                   |  audio, performer, title, duration, caption, disable_notification, reply_to_message_id, reply_markup          |\n| document                |  document, caption, disable_notification, reply_to_message_id, reply_markup                                   |\n| sticker                 |  sticker, disable_notification, reply_to_message_id, reply_markup                                             |\n| video                   |  video, width, height, duration, caption, disable_notification, reply_to_message_id, reply_markup             |\n| voice                   |  voice, duration, caption, disable_notification, reply_to_message_id, reply_markup                            |\n| videoNote               |  videoNote, duration, length, disable_notification, reply_to_message_id, reply_markup                         |\n| location                |  latitude, longitude, disable_notification, reply_to_message_id, reply_markup                                 |\n| venue                   |  latitude, longitude, title, address, foursquare_id, disable_notification, reply_to_message_id, reply_markup  |\n| contact                 |  phone_number, first_name, last_name, disable_notification, reply_to_message_id, reply_markup                 |\n| chatAction              |  action                                                                                                       |\n| game                    |  game_short_name, disable_notification, reply_to_message_id, reply_markup                                     |\n| invoice                 |  title ... \u003cargs-tg-doc-api\u003e ... reply_markup                                                                 |\n|                         | -                                                                                                             |\n| inlineQuery             |  results, next_offset, is_personal, cache_time, switch_pm_text, switch_pm_parameter                           |\n| callbackQuery           |  text, show_alert                                                                                             |\n| shippingQuery           |  ok, shipping_options, error_message                                                                          |\n| preCheckoutQuery        |  ok, error_message                                                                                            |\n\n\n\n\u003ca name=\"refTgUpload\"\u003e\u003c/a\u003e\n#### Tg Upload \n\n```js\ngBot.enable(\"tgUrlUpload\");\n\ngBot\n    .polling()\n    .on(\"text\", function(bot, url) {\n        bot.answer().photo(url).send();\n    });\n    \n/*\nAdded the option to specify an HTTP URL for a file in all methods where InputFile or file_id can be used (except voice messages).\nTelegram will get the file from the specified URL and send it to the user.\nFiles must be smaller than 5 MB for photos and smaller than 20 MB for all other types of content.\n*/\n```\n\n\n\n\u003ca name=\"refPlugin\"\u003e\u003c/a\u003e\n#### Plugin\n\n```js\ngSrv\n    .use(function(bot, data, next) {\n        console.log(\"Async | Type: any\");\n\n        if(data === \"next\") {\n            next();\n        }\n    })\n    .use(\"text\", function(bot) {\n        console.log(\"F:Sync | Type: text\");\n\n        bot.user = {};\n    })\n    .use(function(bot) {\n        bot.user.id = 1;\n    });\n    \ngSrv\n    .on(\"text\", function(bot, data) {\n        bot.user.id;\n    });\n```\n\n\n\n\u003ca name=\"refGoto\"\u003e\u003c/a\u003e\n#### Goto \n\n```js\ngSrv\n    .use(function(bot, data, next) {\n        next(data === \"room\" ? \"room.menu\" : \"\");\n    })\n    .use(function(bot) {\n        console.log(\"If not the room\");\n        \n        // return \"room.menu\";\n    })\n    \n    .on(\"text\", function(bot, data) { })\n    .on(\"text:room.menu\", function(bot, data) { });\n```\n\n\n\n\u003ca name=\"refJSGenerators\"\u003e\u003c/a\u003e\n#### JS Generators \n\n```js\ngBot\n    .polling(function* (bot) {\n        const result = yield send(bot);\n        console.info(result);\n\n        yield error();\n    })\n    .catch(function* (error) {\n        console.error(error);\n    })\n    \n    .use(function* (bot) {\n        yield auth(\"D\", \"13\");\n    })\n    .use(\"text\", function* (bot, data) {\n        yield save();\n\n        if(data === \"key\") {\n            return \"eventYield\";\n        }\n    })\n\n    .on(\"text:eventYield\", function* (bot, data) {\n        console.log(\"eventYield:\", data);\n    });\n\n//----------------]\u003e\n\nfunction auth(login, password) {\n    return new Promise(x =\u003e setTimeout(x, 1000));\n}\n\nfunction send(bot) {\n    return bot.answer().text(\"Ok, let's go...\").send();\n}\n```\n\n\n\n\u003ca name=\"refRender\"\u003e\u003c/a\u003e\n#### Render \n\n```js\n//-----[EJS]-----}\u003e\n\ngBot.engine(require(\"ejs\"))\n\ndata = {\"x\": \"H\", \"y\": \"i\"};\nbot.render(\"EJS | Text: \u003c%= x %\u003e + \u003c%= y %\u003e\", data);\n\n//-----[DEFAULT]-----}\u003e\n\ndata = [\"H\", \"i\"];\nbot.render(\"Array | Text: {0} + {1}\", data);\n\ndata = {\"x\": \"H\", \"y\": \"i\"};\nbot.render(\"Hashtable | Text: {x} + {y}\", data);\n```\n\n\n\n\u003ca name=\"refKeyboard\"\u003e\u003c/a\u003e\n#### Keyboard \n\n```js\nconst rBot = require(\"telegram-bot-api-c\");\n\nfunction onMsg(bot) {\n    const data = {};\n    \n    data.chat_id = bot.cid;\n    data.text = \"Hell Word!\";\n    \n    data.reply_markup = bot.keyboard(); // Or: bot.keyboard.hide()\n    data.reply_markup = bot.keyboard([[\"1\", \"2\"], [\"3\"]]);\n    \n    data.reply_markup = bot.keyboard.hOx();\n    data.reply_markup = bot.keyboard.inline.hOx();\n    \n    bot.api.sendMessage(data);\n}\n\nrBot.keyboard.numpad(true); // \u003c-- Once\nrBot.keyboard.numpad(false, true); // \u003c-- Selective\n\nrBot.keyboard.inline.numpad();\n\n//------------------------------\n\nrBot.keyboard(buttons[, params])\nrBot.keyboard.inline(inlButtons, isVertically)\n\n/*\n  buttons:    `string`, `array of array` or `false`\n  inlButtons: `string`, `array of array` or `object`\n  params:     \"resize once selective\"\n  \n  v - vertically; h - horizontally;\n  \n  vOx, hOx, vPn, hPn, vLr, hLr, vGb, hGb\n  abcd, numpad, hide\n  \n  Normal keyboard:\n   vOx(once, selective)\n   numpad(once, selective)\n*/\n```\n\n| Name              | Note                                 |\n|-------------------|--------------------------------------|\n|                   | -                                    |\n| _Ox               | O / X                                |\n| _Pn               | + / -                                |\n| _Ud               | Upwards / Downwards arrow            |\n| _Lr               | Leftwards / Rightwards arrow         |\n| _Gb               | Like / Dislike                       |\n|                   | -                                    |\n| abcd              | ABCD                                 |\n| numpad            | 0-9                                  |\n|                   | -                                    |\n| hide              |                                      |\n\n\n\n\u003ca name=\"refDownload\"\u003e\u003c/a\u003e\n#### Download\n\n```js\ngBot.download(\"file_id\", \"dir\"/*, callback*/);\ngBot.download(\"file_id\", \"dir\", \"name.mp3\"/*, callback*/);\n\n\ngBot\n    .download(\"file_id\")\n    .then(function(info) {\n        info.stream.pipe(require(\"fs\").createWriteStream(\"./\" + info.name));\n    });\n\n\ngBot\n    .download(\"file_id\", function(error, info) {\n        info.stream.pipe(require(\"fs\").createWriteStream(\"./myFile\"));\n    });\n```\n\n\n\n\u003ca name=\"refInlineQuery\"\u003e\u003c/a\u003e\n#### InlineQuery\n\nhttps://core.telegram.org/bots/inline\n\n```js\ngBot\n    .polling()\n    .on(\"inlineQuery\", function(bot, data) {\n        const idx = Date.now().toString(32) + Math.random().toString(24);\n        const results = [\n            {\n                \"type\":         \"article\",\n                \"title\":        \"Title #1\",\n                \"message_text\": \"Text...\",\n\n                \"thumb_url\":    \"https://pp.vk.me/c627530/v627530230/2fce2/PF9loxF4ick.jpg\"\n            },\n\n            {\n                \"type\":         \"article\",\n                \"title\":        \"Title #2: \" + data.query,\n                \"message_text\": \"Text...yeah\"\n            },\n\n            {\n                \"type\":         \"photo\",\n\n                \"photo_width\":  128,\n                \"photo_height\": 128,\n\n                \"photo_url\":    \"https://pp.vk.me/c627530/v627530230/2fce2/PF9loxF4ick.jpg\",\n                \"thumb_url\":    \"https://pp.vk.me/c627530/v627530230/2fce2/PF9loxF4ick.jpg\"\n            }\n        ]\n            .map((t, i) =\u003e { t.id = idx + i; return t; });\n\n        // results = {results};\n\n        bot\n            .answer()\n            .inlineQuery(results)\n            .send()\n            .then(console.info, console.error);\n    });\n\n//------------]\u003e\n\nbot\n    .api\n    .answerInlineQuery({\n        \"inline_query_id\": 0,\n        \"results\":         results\n    })\n    .then(console.info, console.error);\n```\n\n\n\u003ca name=\"refSendFileAsBuffer\"\u003e\u003c/a\u003e\n#### Send file as Buffer\n\n```js\n\nconst imgBuffer = require(\"fs\").readFileSync(__dirname + \"/MiElPotato.jpg\");\n\n//------------]\u003e\n\nobjSrv\n    .use(function(bot, next) {\n        bot\n            .answer()\n            .photo(imgBuffer)\n            .filename(\"MiElPotato.jpg\") // \u003c-- It is important\n            .filename(\"/path/MiElPotato.jpg\") // \u003c-- Same as above\n            .send();\n    });\n    \n//------------]\u003e\n\napi.sendPhoto({\n    \"chat_id\":      0,\n    \"photo\":        imgBuffer,\n\n    \"filename\":      \"MiElPotato.jpg\" // \u003c-- It is important\n});\n\napi.sendDocument({\n    \"chat_id\":      0,\n    \"document\":     imgBuffer\n});\n```\n\n\n\n\u003ca name=\"refCLI\"\u003e\u003c/a\u003e\n#### CLI\n\n| Key               | Note                                                                          |\n|-------------------|-------------------------------------------------------------------------------|\n|                   | -                                                                             |\n| -j                | insert white space into the output JSON string for readability purposes       |\n|                   | -                                                                             |\n| --token           | high priority                                                                 |\n| --method          | high priority                                                                 |\n| --proxy           | \"ip:port\"                                                                     |\n\n\n```js\n// Environment variables: low priority\n\n\u003e set TELEGRAM_BOT_TOKEN=X\n\u003e set TELEGRAM_BOT_METHOD=X\n\u003e set TELEGRAM_BOT_PROXY=X\n\n...\n\n\u003e tg-bot --token X --method sendMessage --key val -bool\n\u003e node telegram-bot-api-c --token X --method sendMessage --key val -bool\n\n...\n\n\u003e tg-bot --token X --method sendMessage --chat_id 0 --text \"Hi\" -disable_web_page_preview\n\u003e tg-bot --token X --method sendMessage \u003c \"./examples/msg.json\"\n\n\u003e tg-bot --token X --method sendPhoto --chat_id 0 --photo \"/path/MiElPotato.jpg\"\n\u003e tg-bot --token X --method sendPhoto --chat_id 0 --photo \"https://www.google.ru/images/logos/ps_logo2.png\"\n\n...\n\n\u003e tg-bot\n\u003e {\"token\": \"\", \"method\": \"sendMessage\", \"chat_id\": 0, \"text\": \"1\"}\n\u003e \u003center\u003e\n\n(result)\n\n\u003e {\"chat_id\": 0, \"text\": \"2\", \"j\": true, \"proxy\": \"ip:port\"}\n\u003e \u003center\u003e\n\n(result)\n```\n\n\n\n\u003ca name=\"refTest\"\u003e\u003c/a\u003e\n#### Test\n\n```js\nnpm -g install mocha\nnpm install chai\n\nset TELEGRAM_BOT_TOKEN=X\nset TELEGRAM_CHAT_ID=X\nset TELEGRAM_MSG_ID=X\n\ncd \u003cmodule\u003e\n\nnpm test\n```\n\n![npm test][image-test]\n\n\n\n#### Module \n\n| Method            | Arguments                                                                             | Note                                                                      |\n|-------------------|---------------------------------------------------------------------------------------|---------------------------------------------------------------------------|\n|                   | -                                                                                     |                                                                           |\n| keyboard          | buttons[, params]                                                                     | return: object; buttons: string/array; params: \"resize once selective\"    |\n| parseCmd          | text[, strict]                                                                        | return: {type, name, text, cmd}; strict: maxLen32 + alphanum + underscore |\n|                   | -                                                                                     |                                                                           |\n| call              | token, method[, data][, callback(error, buffer, response)][, proxy][, tgUrlUpload]    |                                                                           |\n| call              | options{token, method, proxy, tgUrlUpload}[, data][, callback]                        |                                                                           |\n| callJson          | token, method[, data][, callback(error, json, response)][, proxy][, tgUrlUpload]      |                                                                           |\n| callJson          | options{token, method, proxy, tgUrlUpload}[, data][, callback]                        |                                                                           |\n\n\n#### Instance\n\n| Attribute         | Type           | Note                                 |\n|-------------------|----------------|--------------------------------------|\n|                   | -              |                                      |\n| api               | object         | See [Telegram Bot API][3]            |\n|                   | -              |                                      |\n| keyboard          | function       |                                      |\n| parseCmd          | function       |                                      |\n\n\n| Method            | Arguments                                                             | Return                            |\n|-------------------|-----------------------------------------------------------------------|-----------------------------------|\n|                   | -                                                                     |                                   |\n|                   | -                                                                     |                                   |\n| enable            | key                                                                   | this                              |\n| disable           | key                                                                   | this                              |\n| enabled           | key                                                                   | true/false                        |\n| disabled          | key                                                                   | true/false                        |\n|                   | -                                                                     |                                   |\n| engine            | instance                                                              | this                              |\n| promise           | instance                                                              | this                              |\n| token             | [token]                                                               | this or token                     |\n| proxy             | [proxy]                                                               | this                              |\n|                   | -                                                                     |                                   |\n| call              | method[, data][, callback(error, buffer, response)]                   |                                   |\n| callJson          | method[, data][, callback(error, json, response)]                     |                                   |\n|                   | -                                                                     |                                   |\n| render            | template, data                                                        | string                            |\n| download          | fid[, dir][, name][, callback(error, info {id,size,file,stream})]     | promise or undefined              |\n|                   | -                                                                     |                                   |\n| http              | [options][, callback(bot, cmd)]                                       | object                            |\n| polling           | [options][, callback(bot, cmd)]                                       | object                            |\n| virtual           | [callback(bot, cmd)]                                                  | object                            |\n\n\n#### Methods: Response Builder\n\n| Name          | Args                                  | Note                                                              |\n|---------------|---------------------------------------|-------------------------------------------------------------------|\n|               | -                                     |                                                                   |\n| inlineQuery   | (results)                             |                                                                   |\n| callbackQuery | ([message])                           |                                                                   |\n|               | -                                     |                                                                   |\n| render        | (data)                                |                                                                   |\n| keyboard      | (buttons[, params])                   |                                                                   |\n| inlineKeyboard| (buttons[, isVertically])             |                                                                   |\n|               | -                                     |                                                                   |\n| isReply       | ([flag])                              |                                                                   |\n| send          | ([callback])                          |                                                                   |\n|               | -                                     |                                                                   |\n| text          |                                       |                                                                   |\n| photo         |                                       | Ext: jpg, jpeg, gif, tif, png, bmp                                |\n| audio         |                                       | Ext: mp3                                                          |\n| document      |                                       |                                                                   |\n| sticker       |                                       | Ext: webp [, jpg, jpeg, gif, tif, png, bmp]                       |\n| video         |                                       | Ext: mp4                                                          |\n| voice         |                                       | Ext: ogg                                                          |\n| location      |                                       |                                                                   |\n| venue         |                                       |                                                                   |\n| contact       |                                       |                                                                   |\n| chatAction    |                                       |                                                                   |\n| game          |                                       |                                                                   |\n\n#### Methods: Server\n\n| Name          | Arguments                                     | Return                                    |\n|---------------|-----------------------------------------------|-------------------------------------------|\n|               | -                                             |                                           |\n|               | POLLING                                       |                                           |\n|               | -                                             |                                           |\n| start         |                                               | this                                      |\n| stop          |                                               | this                                      |\n|               | HTTP                                          |                                           |\n|               | -                                             |                                           |\n| bot           | bot[, path][, onMsg(json, request)]           | new srvInstance                           |\n|               | -                                             |                                           |\n|               | VIRTUAL                                       |                                           |\n|               | -                                             |                                           |\n| input         | error, data                                   |                                           |\n| middleware    |                                               |                                           |\n|               | -                                             |                                           |\n|               | ALL                                           |                                           |\n|               | -                                             |                                           |\n| catch         | callback(error)                               | this                                      |\n| use           | [type], [params], callback(bot[, data, next]) | this                                      |\n| on            | type[, params], callback(data, params[, next])| this                                      |\n| off           | [type][, callback]                            | this                                      |\n\n\n\u003ca name=\"refFieldsSrvBot\"\u003e\u003c/a\u003e\n#### Fields: bot | srv.on('', bot =\u003e 0)\n\n| Name              | Type                  | Note                                                   |\n|-------------------|-----------------------|--------------------------------------------------------|\n|                   | -                     |                                                        |\n| isGroup           | boolean               | bot.isGroup = bot.message.chat.type === [super]group   |\n| isReply           | boolean               | bot.isReply = !!bot.message.reply_to_message           |\n|                   | -                     |                                                        |\n| cid               | number                | bot.cid = bot.message.chat.id                          |\n| mid               | number                | bot.mid = bot.message.message_id                       |\n| qid               | string                | bot.qid = bot.inlineQuery.id                           |\n| cqid              | string                | bot.cqid = bot.callbackQuery.id                        |\n| sid               | string                | bot.sid = bot.shipping_query.id                        |\n| pqid              | string                | bot.pqid = bot.pre_checkout_query.id                   |\n|                   | -                     |                                                        |\n| command           | object                | Incoming command                                       |\n|                   | -                     |                                                        |\n| updateType        | string                |                                                        |\n| updateSubType     | string                |                                                        |\n| eventType         | string                |                                                        |\n| eventSubType      | string                |                                                        |\n| gotoState         | string                |                                                        |\n|                   | -                     |                                                        |\n| from              | object                | Persistent                                             |\n|                   | -                     |                                                        |\n| message           | object                | Incoming message                                       |\n| inlineQuery       | object                | Incoming inline query                                  |\n| chosenInlineResult| object                | The result of an inline query that was chosen          |\n| callbackQuery     | object                | Incoming callback query                                |\n|                   | -                     |                                                        |\n| answer            | function()            | Response Builder; message; Uses: cid, mid              |\n| answer            | function()            | Response Builder; inlineQuery; Uses: qid               |\n| answer            | function()            | Response Builder; callbackQuery; Uses: cqid            |\n\n\n\n#### Events: use / on\n\n| Name              | Args                                  | Note                                      |\n|-------------------|---------------------------------------|-------------------------------------------|\n|                   | -                                     |                                           |\n| message           | bot, message[, next]                  |                                           |\n| editedMessage     | bot, message[, next]                  |                                           |\n|                   | -                                     |                                           |\n| channelPost       | bot, post[, next]                     |                                           |\n| editedChannelPost | bot, post[, next]                     |                                           |\n|                   | -                                     |                                           |\n| inlineQuery       | bot, data[, next]                     |                                           |\n| chosenInlineResult| bot, data[, next]                     |                                           |\n| callbackQuery     | bot, data[, next]                     |                                           |\n|                   | -                                     |                                           |\n| pinnedMessage     | bot, message[, next]                  |                                           |\n|                   | -                                     |                                           |\n| invoice           | bot, data[, next]                     |                                           |\n| successfulPayment | bot, data[, next]                     |                                           |\n|                   | -                                     |                                           |\n| enterChat         | bot, data[, next]                     |                                           |\n| leftChat          | bot, data[, next]                     |                                           |\n|                   | -                                     |                                           |\n| chatTitle         | bot, data[, next]                     |                                           |\n| chatNewPhoto      | bot, data[, next]                     |                                           |\n| chatDeletePhoto   | bot, data[, next]                     |                                           |\n|                   | -                                     |                                           |\n| chatCreated       | bot, data[, next]                     |                                           |\n| superChatCreated  | bot, data[, next]                     |                                           |\n| channelChatCreated| bot, data[, next]                     |                                           |\n|                   | -                                     |                                           |\n| migrateToChatId   | bot, data[, next]                     |                                           |\n| migrateFromChatId | bot, data[, next]                     |                                           |\n|                   | -                                     |                                           |\n| text              | bot, data[, next]                     |                                           |\n| photo             | bot, data[, next]                     |                                           |\n| audio             | bot, data[, next]                     |                                           |\n| document          | bot, data[, next]                     |                                           |\n| sticker           | bot, data[, next]                     |                                           |\n| video             | bot, data[, next]                     |                                           |\n| voice             | bot, data[, next]                     |                                           |\n| videoNote         | bot, data[, next]                     |                                           |\n| location          | bot, data[, next]                     |                                           |\n| venue             | bot, data[, next]                     |                                           |\n| contact           | bot, data[, next]                     |                                           |\n| game              | bot, data[, next]                     |                                           |\n|                   | -                                     |                                           |\n| *                 | bot, data[, next]                     |                                           |\n| /[name]           | bot, params[, next]                   | CMD                                       |\n|                   | -                                     |                                           |\n| (regexp)          | bot, params[, next]                   |                                           |\n\n\n## License\n\nMIT\n\n----------------------------------\n[@ Daeren][1]\n[@ Telegram][2]\n\n\n[1]: http://666.io\n[2]: https://telegram.me/io666\n[3]: https://core.telegram.org/bots/api\n[4]: https://npmjs.com/package/tgb-pl-botanio\n[5]: https://core.telegram.org/bots/games\n[10]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n[100]: https://core.telegram.org/bots/2-0-intro\n[150]: https://github.com/Daeren/telegram-bot-api-c/blob/master/examples/sendMediaGroup.js\n\n[image-architecture]: https://666.io/assets/img/telegram-bot-api-c/architecture.png?x=16\n[image-test]: https://666.io/assets/img/telegram-bot-api-c/test.png?x=13\n\n[cod_b]: https://img.shields.io/codacy/178f90f3c89945e7acb97b21140da7db.svg\n[cod_l]: https://www.codacy.com/app/daeren/telegram-bot-api-c/dashboard\n\n[node_sec_b]: https://nodesecurity.io/orgs/xiii/projects/58db156e-47b1-4d11-a406-aae26b97604d/badge","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaeren%2Ftelegram-bot-api-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDaeren%2Ftelegram-bot-api-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDaeren%2Ftelegram-bot-api-c/lists"}