├── README.md └── tutorials ├── create-a-bot.md ├── get-location.js ├── how-to-send-a-message.md ├── install-node-telegram-bot-api.md ├── set-proxy.md └── usage-node-telegram-bot-api.md /README.md: -------------------------------------------------------------------------------- 1 | # node-telegram-bot-api-persian-language 2 | 3 | [![https://telegram.me/NTBA_Persian_Developers](https://img.shields.io/badge/💬%20Telegram-node--telegram--bot--api--persian--language-blue.svg)](https://telegram.me/NTBA_Persian_Developers) 4 | [![https://telegram.me/saeedseo](https://img.shields.io/badge/💬%20Telegram-saeedseo-blue.svg)](https://telegram.me/saeedseo) 5 | 🇮🇷 به زبان فارسی **node-telegram-bot-api** ماژول 6 | 7 | 8 | 9 | ## بخش آموزش ها 10 | 11 | * [BotFather ساخت ربات تلگرام توسط][create-a-bot] 12 | * [node-telegram-bot-api نصب][install-node-telegram-bot-api] 13 | * [node-telegram-bot-api فراخوانی ماژول][usage-node-telegram-bot-api] 14 | * [ارسال و دریافت پیام][how-to-send-a-message] 15 | * [تنظیم پروکسی][set-proxy] 16 | 17 | 18 | 19 | 20 | [create-a-bot]:https://github.com/saeedhei/node-telegram-bot-api-persian-language/blob/master/tutorials/create-a-bot.md 21 | [install-node-telegram-bot-api]:https://github.com/saeedhei/node-telegram-bot-api-persian-language/blob/master/tutorials/install-node-telegram-bot-api.md 22 | [usage-node-telegram-bot-api]:https://github.com/saeedhei/node-telegram-bot-api-persian-language/blob/master/tutorials/usage-node-telegram-bot-api.md 23 | [how-to-send-a-message]:https://github.com/saeedhei/node-telegram-bot-api-persian-language/blob/master/tutorials/how-to-send-a-message.md 24 | [set-proxy]:https://github.com/saeedhei/node-telegram-bot-api-persian-language/blob/master/tutorials/set-proxy.md 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tutorials/create-a-bot.md: -------------------------------------------------------------------------------- 1 | ![BotFather](https://core.telegram.org/file/811140327/1/zlN4goPTupk/9ff2f2f01c4bd1b013) 2 |

3 | باید اول به ربات پدر برید و داخل این ربات برای رباتتون یک اسم و یوزر انتخاب کنید .. توجه کنید که اسم رو بعدا میتوانید تغییر بدهید اما یوزر را نمیتوان تغییر داد 4 |

5 | 6 | https://telegram.me/BotFather 7 |

8 | روی لینک بالا کلیک کنید و به ربات پدر بروید داخل پی وی ربات start را بزنید و یا کلمه کلیدی start/ را بنویسید و ارسال کنید 9 | پیامی برای شما ارسال میشود که گزینه به گزینه توضیح میدهیم 10 |

11 | They call me the Botfather, I can help you create and set up Telegram bots. Please read this manual before we begin: 12 | https://core.telegram.org/bots 13 | 14 | You can control me by sending these commands: 15 | 16 | /newbot – create a new bot 17 | 18 |

ساخت ربات

19 | /token – generate authorization token 20 | 21 |

گرفتن توکن

22 | /revoke – revoke bot access token 23 | 24 |

تغییر توکن

25 | /setname – change a bot’s name 26 | 27 |

انتخاب نام برای ربات

28 | /setdescription – change bot description 29 | 30 |

نوشتن توضیحات برای ربات

31 | /setabouttext – change bot about info 32 | 33 |

تنظیم درباره ما در ربات

34 | /setuserpic – change bot profile photo 35 | 36 |

انتخاب عکس برای ربات

37 | /setcommands – change bot commands list 38 | 39 |

به این قسمت نیازی ندارید

40 | /setjoingroups – can your bot be added to groups? 41 | 42 |

تنظیم اینکه بتوانند ربات را به گروه ها اضافه کنند یا خیر

43 | /setprivacy – what messages does your bot see in groups? 44 | 45 |

یک گزینه برنامه نویسی هستش

46 | /deletebot – delete a bot 47 | 48 |

حذف کردن ربات

49 | /cancel – cancel the current operation 50 | 51 |

کنسل کردن دستور

52 |

53 | خب اکنون کاری که باید بکنید این است گزینه newbot/ را بزنید یا اینکه تایپ کنید و ارسال کنید 54 | 1- ربات از شما میخواهد که یک نام برای رباتتان انتخاب کنید 55 | 2- یک یوزر برای رباتتان انتخاب کنید توجه کنید که اخر اسم ربات شما باید کلمه bot داشته باشید مثال : permag_bot 56 | خب کار تمام است ربات یک پیام برای شما میفرستد که یک کد داخل آن است ( توکن ) 57 |

58 | Done! Congratulations on your new bot. You will find it at telegram.me/permag2_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. 59 | 60 | Use this token to access the HTTP API: 61 | 120837920:AAHkXeiBhrfvIyzQSDacrGeoLB2ph8OfuyM 62 | 63 | For a description of the Bot API, see this page: https://core.telegram.org/bots/api 64 |

65 | خب اکنون باید عکس ، توضیحات و اجازه ورود به گروه ها را برای ربات تنظیم کنید پس با توجه به توضیحات بالا این کارو انجام میدیم 66 | گزینه setuserpic/ را زده و یک عکس ارسال میکنیم تا روی ربات قرار بگیرید 67 | گزینه setdescription/ را زده و توضیحاتی در مورد ربات مینویسیم و ارسال میکنیم 68 | گزینه setjoingroups/ را زده و پس از انتخاب ربات از بین دو گزینه ENABLED را انتخاب میکنیم 69 | خب اکنون کارمان در این ربات تمام است و ربات خود را ساخته ایم اما در حال حاضر ربات ما هیچ کاری نمیکند . 70 |

71 | -------------------------------------------------------------------------------- /tutorials/get-location.js: -------------------------------------------------------------------------------- 1 | bot.onText(/getLocation/, (msg) => { 2 | const opts = { 3 | reply_markup: JSON.stringify({ 4 | keyboard: [ 5 | [{text: 'Location', request_location: true}], 6 | [{text: 'Contact', request_contact: true}], 7 | ], 8 | resize_keyboard: true, 9 | one_time_keyboard: true, 10 | }), 11 | }; 12 | bot.sendMessage(msg.chat.id, 'Contact and Location request', opts); 13 | }); 14 | 15 | bot.on('location', (msg) => { 16 | console.log(msg.location.latitude); 17 | console.log(msg.location.longitude); 18 | }); 19 | 20 | //END 21 | //https://github.com/saeedhei 22 | -------------------------------------------------------------------------------- /tutorials/how-to-send-a-message.md: -------------------------------------------------------------------------------- 1 | ## How to Send/Receive a Message 2 | 3 |

4 | برای ارسال و در یافت پیام می توان از دستورات زیر استفاده نمود 5 |

6 | 7 | ```js 8 | const TelegramBot = require('node-telegram-bot-api'); 9 | 10 | // replace the value below with the Telegram token you receive from @BotFather 11 | const token = 'YOUR_TELEGRAM_BOT_TOKEN'; 12 | 13 | // Create a bot that uses 'polling' to fetch new updates 14 | const bot = new TelegramBot(token, {polling: true}); 15 | 16 | // Matches "/echo [whatever]" 17 | bot.onText(/\/echo (.+)/, (msg, match) => { 18 | // 'msg' is the received Message from Telegram 19 | // 'match' is the result of executing the regexp above on the text content 20 | // of the message 21 | 22 | const chatId = msg.chat.id; 23 | const resp = match[1]; // the captured "whatever" 24 | 25 | // send back the matched "whatever" to the chat 26 | bot.sendMessage(chatId, resp); 27 | }); 28 | 29 | // Listen for any kind of message. There are different kinds of 30 | // messages. 31 | bot.on('message', (msg) => { 32 | const chatId = msg.chat.id; 33 | 34 | // send a message to the chat acknowledging receipt of their message 35 | bot.sendMessage(chatId, 'Received your message'); 36 | }); 37 | ``` 38 | 39 | # مثال 40 | 41 | ```js 42 | bot.onText(/\/start/, (msg) => { 43 | 44 | const opts = { 45 | reply_to_message_id: msg.message_id, 46 | reply_markup: JSON.stringify({ 47 | keyboard: [[A,B,C]], 48 | }) 49 | }; 50 | bot.sendMessage(msg.chat.id, `سلام به ربات خوش آمدید.`, opts); 51 | }); 52 | ``` 53 | -------------------------------------------------------------------------------- /tutorials/install-node-telegram-bot-api.md: -------------------------------------------------------------------------------- 1 | ## Install 2 |

3 | ابتدا نود جی اس را در سیستم عامل خود نصب و سپس در ترمینال خود این دستور را وارد نمائید. 4 |

5 | 6 | [Node.js Download][node.js] 7 | 8 | ```bash 9 | npm install --save node-telegram-bot-api 10 | ``` 11 | 12 | [node.js]:https://nodejs.org/en/download/ 13 | 14 | -------------------------------------------------------------------------------- /tutorials/set-proxy.md: -------------------------------------------------------------------------------- 1 | ## تنظیم پروکسی 2 | 3 |

4 | برای تنظیم پروکسی از نمونه کد زیر استفاده کنید: 5 |

6 | 7 | ```js 8 | const bot = new TelegramBot(token, { 9 | polling: true, 10 | request: { 11 | proxy: "http://127.0.0.1:1234", 12 | }, 13 | }); 14 | ``` 15 | 16 |

17 | پارامترهای بیشتری که می‌توانید در request تنظیم کنید را از اینجا ببینید: 18 |

19 | 20 | 21 | 22 |

23 | در غیر این صورت، اگر از وب‌هوک استفاده می‌کنید، به اینجا سر بزنید: 24 |

25 | 26 | 27 | 28 | [Updated by @NabiKAZ](https://github.com/NabiKAZ) 29 | 30 | -------------------------------------------------------------------------------- /tutorials/usage-node-telegram-bot-api.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 3 | 4 |

5 | ابتدا یک فایل جاوا اسکریپت در مسیر پروژه خود بسازید و دستور زیر را در مربوط به فراخوانی ماژول می باشد را در آن اضافه نمائید. 6 |

7 | 8 | ```js 9 | const TelegramBot = require('node-telegram-bot-api'); 10 | ``` 11 | 12 |

13 | سپس توکنی که از بات فادر دریافت نمودید را در دستور زیر وارد نمائید 14 |

15 | 16 | ```js 17 | const token = 'YOUR_TELEGRAM_BOT_TOKEN'; 18 | ``` 19 |

20 | و در انتها با این دستور یک ربات جدید بسازید. 21 |

22 | 23 | ```js 24 | const bot = new TelegramBot(token, {polling: true}); 25 | ``` 26 | 27 | 28 | 29 | --------------------------------------------------------------------------------