Skip to main content

Creating Telegram Bots Made Simple

Project description

teleasy 2.0.2

Creating Telegram Bots Made Simple

Table of contents


from teleasy import TelegramBot, UpdateInfo

bot = TelegramBot(<YOUR_TOKEN>)

def on_normal_message(chat: ChatInstance):
    chat.print(f"hello {chat.first_name}")

def input_example(chat: ChatInstance):
    color = chat.input("what's your favorite color?")
    chat.print(f"Your favorite color is {color}")



See Examples-Folder for more


pip install teleasy
pip3 install teleasy
python3 -m pip install teleasy
# Now, you can import the relevant Classes using
from teleasy import TelegramBot, UpdateInfo

# or just do
import teleasy
# and access the classes from the 'teleasy' object directly

see Installation Help (Wiki) for more Help


# first import the relevant classes
from teleasy import TelegramBot, ChatInstance

# create bot object using your token as parameter
bot = TelegramBot(<YOUR_TOKEN>)

# let's define our first message handler that will respond
# to all messages with "Hello, World!"

# tell the bot to use the following function
# when encountering normal messages
def normal_message_handler(chat: ChatInstance):
    # every handler will be passed a custom ChatInstance
    # this object contains information about the message
    # and may be used to get user input
    chat.print("Hello World!")
# handlers are run in parallel using multithreading to enable
# very easy handling of user input

# now we need to start the bot

# and it's ready to go! Feel free to copy this code and try it out


command handlers

# we can also define command handlers:

@bot.on_command("/help") # optional "/" in front of command name
def help_command_handler(chat: ChatInstance):
    chat.print("Welcome to the Help-Function")


user input

# each telegram message handler will be given its own thread to operate in
# this allows us to get user input very easily by doing so:

def dialogue_command_handler(chat: ChatInstance):
    # the chat.input method works like the built-in 'input()' method in python
    color = chat.input("What's your favorite color?")
    food = chat.input("What's your favorite food?")
    chat.print(f"color: {color}\nfood: {food}")



Project is IN PROGRESS


This project is licensed under the terms of the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

teleasy-2.0.2.tar.gz (18.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page