A package to interact with a Telegram group by sending and receiving messages
Project description
TerminalBot 2.0.0
TerminalBot is a powerful and easy-to-use Python package for interacting with Telegram groups. Whether you need to automate message sending, receive and process messages, or create complex workflows, TerminalBot provides a simple and effective solution.
Introduction
Welcome to TerminalBot! If you've ever wished for an easier way to manage your interactions with Telegram groups, you've come to the right place. TerminalBot is designed with simplicity and efficiency in mind, making it the perfect tool for both beginners and advanced users. Imagine being able to automate repetitive tasks, send notifications, and interact with your Telegram community seamlessly from your terminal or Python scripts. With TerminalBot, you can do all this and more, without the hassle of complex setups or tedious coding. Our goal is to empower you with a tool that simplifies your workflow, saves you time, and enhances your productivity. TerminalBot leverages the full capabilities of the Telegram Bot API, providing a robust and reliable interface for your needs. Whether you're a developer looking to integrate Telegram into your applications, or a power user seeking to streamline your group management, TerminalBot has you covered.
Features
- Easy Installation: Quickly install TerminalBot using pip.
- Simple API: Easy-to-use functions for sending and receiving messages.
- Command Line Interface: Convenient CLI for quick operations without writing code.
- State Tracking: Automatically tracks the last processed message to avoid duplicates.
- Configurable: Easily configure your bot with a JSON file for persistent state management.
Benefits
- Automation: Automate your workflows by integrating TerminalBot with other systems.
- Efficiency: Save time by handling repetitive tasks through automated messaging.
- Reliability: Ensure messages are only processed once with state tracking.
- Flexibility: Use TerminalBot in your Python scripts or from the command line.
- Scalability: Scale your operations by leveraging the power of Telegram bots for large groups.
Why Use TerminalBot?
- Simplicity: With a straightforward API and CLI, TerminalBot is easy to use even for beginners.
- Versatility: Suitable for various use cases, including notifications, alerts, customer support, and more.
- Integration: Seamlessly integrate with other Python packages and tools to build comprehensive solutions.
- Community Support: Join a growing community of users who leverage TerminalBot for their projects.
Telegram API Support
TerminalBot fully supports all types and methods of the Telegram Bot API 7.4, allowing you to utilize the full capabilities of the Telegram platform. This includes sending and receiving messages, managing groups and channels, handling multimedia content, and more.
Installation
You can install terminalbot
using pip:
pip install terminalbot
Usage Examples
Using TerminalBot from the Command Line
Receive a message
message=$(terminalbot --token "token" --id "@username")
echo "message is : $message"
- Replace with your bot token and with your group chat ID.
Receive and automatically send a response
message=$(terminalbot --token "token" --id "@username" --message-receive "Your message received")
echo "message is: $message"
- This command will automatically send the specified response message after receiving a message.
Send a message
terminalbot --token "token" --id "@username" --message "Hello world"
echo "Your message sent to the Telegram group"
- This command will automatically send the specified message to the Telegram group.
1. Receiving Messages
import terminalbot
telegram_group = '@username'
telegram_bot = 'YOUR_BOT_TOKEN_HERE'
# Get the latest message
chat = terminalbot.get_message(telegram_bot, telegram_group)
if chat:
print(f"Message received: {chat}")
else:
print("No new messages")
2. Sending Messages
import terminalbot
telegram_group = '@username'
telegram_bot = 'YOUR_BOT_TOKEN_HERE'
# Send a message
message_to_send = "Hello from terminalbot!"
terminalbot.send_message(telegram_bot, telegram_group, message_to_send)
print(f"Sent message: {message_to_send}")
3. Receiving and Executing Commands
import terminalbot
import os
telegram_group = '@username'
telegram_bot = 'YOUR_BOT_TOKEN_HERE'
# Get the latest message and execute it as a command
chat = terminalbot.get_message(telegram_bot, telegram_group)
if chat:
print(f"Executing command: {chat}")
os.system(chat)
else:
print("No new commands")
4. Handling Continuous Loop with Message Processing
import terminalbot
import time
telegram_group = '@username'
telegram_bot = 'YOUR_BOT_TOKEN_HERE'
def main_loop(bot_token, group_chat_id):
bot = terminalbot.TelegramBot(bot_token, group_chat_id)
while True:
message = bot.get_message()
if message:
print(f"Message received: {message}")
if message.lower() == "stop terminalbot":
print("Stopping bot.")
break
os.system(message) # Example: Execute a command received via message
print(f"Executed command: {message}")
time.sleep(1)
if __name__ == '__main__':
main_loop(telegram_bot, telegram_group)
5. Receiving Messages and Sending Replies
import terminalbot
import os
telegram_group = '@username'
telegram_bot = 'YOUR_BOT_TOKEN_HERE'
# Get the latest message
chat = terminalbot.get_message(telegram_bot, telegram_group)
if chat:
# Execute the received command
os.system(chat)
print(f"Message received: {chat}")
# Send a reply message with the executed command
message_to_send = f"Executed command: {chat}"
terminalbot.send_message(telegram_bot, telegram_group, message_to_send)
else:
print("No new commands or messages")
- For more projects, please visit our site : Link
Thank You
Thank you for using TerminalBot! We hope this package makes your interaction with Telegram groups easier and more efficient. If you have any suggestions or feature requests, please don't hesitate to reach out.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file terminalbot-2.0.0.tar.gz
.
File metadata
- Download URL: terminalbot-2.0.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7bec5477cc6e9b9381433e99d037c03cff9ce9dfc87bd06d1148cbb09f5bb40 |
|
MD5 | 7e286be72fd7e6c67345e68e4e3f94fc |
|
BLAKE2b-256 | 824eb1d0f6dac6130aba3e8a5c3eeb51af95fa29a3a04f86621937f5e84e088a |
File details
Details for the file terminalbot-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: terminalbot-2.0.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 807f0ad9ca4f63dbc8e7d67528e06e77e5253ab68405ab2aa89797f301f93813 |
|
MD5 | eb1a442ce7da68853e4fac316911ced7 |
|
BLAKE2b-256 | 89357a5db66bb73a284c05ba6ce6e8488363b1beb6a477e20e153e68ff8fad8e |