githubEdit

Creating a TeleBot

Getting Started

  1. Open up the IDE of your choice (PyCharm, VS Code, Google Colab, etc.)

  2. Locate the terminal - usually found in a panel at the bottom or side of your IDE

  3. Install the telebot package by typing pip install python-telegram-bot Note: Colab uses ! as a prefix to shell commands

  4. Run the command

Link to the Library: https://github.com/python-telegram-bot/python-telegram-botarrow-up-right

Creating a Bot

  • Launch Telegram

  • Search for the user @BotFather

BotFather on Telegram
  • Create a new bot by using the command '/start '

  • Follow the prompts and set the bot's name and username Username must end with "bot" -> e.g. 'untitled_bot'

  • Receive your bot token: BotFather will provide you with a unique token that will be used to authenticate your bot

Your Bot's Token

Keep your token secure and do not share it publicly

  • Input token into your environment

  • (Optional) Add a description, profile picture, etc.

Import Packages

We will be creating the telebot in the context of Google Colab!

So, let's get started! Paste the following code blocks into your file:

  1. Allow for asynchronous programming capabilities

  1. Enable logging

This is setting up logging module, so you know when (and why) things don't work as expected.

Click herearrow-up-right for more info.

  1. Import from telegram package

  1. (Optional) Other useful packages

Last updated