/Telegram_Bot_tutorials

Learn how to make a telegram bot from basics to sample bots

Primary LanguagePython

Telegram_Bot_tutorials

Learn how to make a telegram bot from basics to production

Bot Types in Telegram

  • Normal:
    • It can be added to a group for multiple people to access at a time.
  • Inline:
    • No need to add into any group
    • Access via @bot1 in the message box

Bot features

  • Add inline keyboards: contact, location, custom
    • Python
  • Add buttons
    • Python
  • Attach to Database
    • Python
  • Add bot to a group
  • Reply to any comment on a group

    It is identical to the feature "Reply to any comment on channel's post"

  • Verify a bot/human: by sending DM to that user & check for clicking a button
    • DM
    • Group
  • Create a UI with back button, options like an App
    • Python

Conversation

There are 5 ways to do a conversation with the bot in order to make them interactive:

  1. Commands with parameters like /pay 1000 @user1
  2. Dialogue with the bot like
User: /pay
Bot: Please enter the amount
User: 1000
Bot: Please enter the receiver's username
User: @user1
Bot: Done! Here is the transaction ID: 123456789
  1. Inline keyboard
User: /pay
Bot: [Yes][No]
User: Clicked on [Yes] button
Bot: Done!
  1. Reply keyboard
    • Works like inline keyboard but with a different UI coming from bottom of the screen. Mostly used for less options like Yes/No, etc.
  2. Open a Web App/Page & let the user interact with it
    1. Put the link in the bot's message
    2. Put the link in the bot's inline keyboard

Programming

Rust

Python

C++

Learning/Education

Github Repositories

Bots

Tools

  • Emoji

    • https://emojipedia.org/
    • https://apps.timwhitlock.info/emoji/tables/unicode
    • Or Google the required type with 'emoji' as suffix. E.g. "person standing emoji", "cow emoji", etc.
    • get bytes from unicode
      • M-1: Just copy the emoji & literally paste into unicode place here
      • M-2: Just copy the emoji & literally paste into the variable place inside the .py file
      • get the bytes & write like this:
    person_emoji = '👤'              # b'\xf0\x9f\x91\xa4'.decode('utf-8') U+1F464
    purse_emoji = '👛'             # b'\xf0\x9f\x91\x9b'.decode('utf-8') U+1F519
  • Usage

    itembtn0 = types.InlineKeyboardButton(f'{person_emoji} Account', callback_data = "home_account")
    itembtn1 = types.InlineKeyboardButton(f'{purse_emoji} Wallet', callback_data = "home_wallet")

TODO

  • Quiz Bot
    • owner can add set of quiz Q&A
    • pay the subscription & make it available for users
  • Birthday_bot: reminds other users (in a group) about the Birthday boy/girl.
  • Weather_bot: gives alert about weather of a place (given by user).
  • Stock_bot: gives all stock market info
    • API: https://mboum.com/api/welcome
    • Features inspiration: https://mboum.com/
    • Earning: user subscription for
      • specific price value alert for a share. E.g. alert when share price of Google reaches 1000 USD.
      • specific price of share daily e.g. Google, Uber, Amazon...
  • FlashLoan Helper: Develop a bot which would list down the price difference of same pairs across different DEXes. The objective is to then make a flash loan transaction using a NodeJS/Python script in order to replicate this: DeFi Lecture 1_ Introduction and Overview of DeFi 32-42 screenshot