Video file
شروع سریع
ساخت اولین بازو:
۱− در اولین مرحله باید با بازوی پدر به نشانی @botfather در بله گفتوگو کنید و بازوی خودتان را بسازید( برای آموزش بیشتر میتوانید فیلم کوتاه بالا را برای ساخت بازو در بازوی پدر ببینید)
۲− در این قسمت باید یک زبان برنامه نویسی به دلخواه خودتان انتخاب کنید. ما پایتون را انتخاب میکنیم
۳- و اگر شما هم مثل ما پایتون را انتخاب کنید میتوانید کد زیر را امتحان و یا این کد را از این لینک دریافت کنید. همانطور که ملاحظه میکنید این کد هم در تلگرام و هم در بله قابل اجرا است.
#!/usr/bin/env python # -*- coding: utf-8 -*- """Simple Bot to reply messages. This is built on the API wrapper, see echobot2.py to see the same example built on the telegram.ext bot fra
mework. This program is dedicated to the public domain under the CC0 license. """ import logging from time import sleep import telegram from telegram.error import NetworkError, Unauthorized update_id = None def main(): """Run the bot.""" global update_id # Telegram Bot Authorization Token bot = telegram.Bot(token='TOKEN', base_url="https://tapi.bale.ai/") # get the first pending update_id, this is so we can skip over it in case # we get an "Unauthorized" exception. try: bot.delete_webhook() update_id = bot.get_updates()[0].update_id except IndexError: update_id = None # Enable logging logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG) while True: try: echo(bot) sleep(2) except NetworkError: sleep(1) except Unauthorized: # The user has removed or blocked the bot. update_id += 1 def echo(bot): """Echo the message the user sent.""" global update_id # Request updates after the last update_id for update in bot.get_updates(offset=update_id, timeout=10): update_id = update.update_id + 1 if update.message: # your bot can receive updates without messages # Reply to the message update.message.reply_text(update.message.text) if __name__ == '__main__': main()
۴ - و در آخر کافیست که توکنی که در مرحله ۱ از @botfather دریافت کردید در خط زیر قرار دهید و سپس کد خودتان را با دستور زیر اجرا کنید
۵- وارد برنامه بله شوید و نام کاربری بازوی خودتان را جستوجو کنید و برروی دکمه شروع کلیک کنید. نمونه مثالی که ما انتخاب کردیم بازویی است که هر پیامی که بگیرد مانند همان جواب میدهد. میتوانید امتحان کنید.
سه شنبه, اسفند ۲۱, ۱۳۹۷ - ۱۰:۴۷