close
close
install telegram cli on centos

install telegram cli on centos

2 min read 19-10-2024
install telegram cli on centos

Installing Telegram CLI on CentOS: A Step-by-Step Guide

The Telegram CLI is a powerful tool for managing your Telegram accounts from the command line. It allows you to send messages, control groups, download files, and more, all without needing to open the graphical Telegram app. This article will guide you through installing the Telegram CLI on CentOS.

Why Choose the Telegram CLI?

  • Efficiency: Automate tasks like sending messages to multiple contacts or managing large groups.
  • Flexibility: Control your Telegram account without a graphical interface.
  • Security: Securely store and manage your API keys locally.

Prerequisites:

  • CentOS Server: Ensure you have a CentOS server set up and running.
  • Terminal Access: You need access to a terminal or SSH client to execute commands.

Installation Steps:

  1. Update System Packages:

    sudo yum update -y
    

    This command updates all installed packages to the latest versions, ensuring compatibility.

  2. Install Dependencies:

    sudo yum install -y epel-release
    sudo yum install -y python3-pip
    

    The epel-release package provides additional software repositories, and python3-pip is essential for installing Python packages.

  3. Install Telegram CLI:

    sudo pip3 install telethon
    

    Telethon is a Python library that allows you to interact with the Telegram API using the command line.

  4. Generate API Credentials:

    • Visit https://my.telegram.org/auth to log in to your Telegram account.
    • Click on "API Development Tools."
    • Create a new application by providing a name and short description.
    • You will receive an API ID and API Hash - keep these safe!
  5. Configure Telegram CLI:

    • Create a configuration file (e.g., ~/.telegramcli.conf):
      [telethon]
      api_id = YOUR_API_ID
      api_hash = YOUR_API_HASH
      
      Replace YOUR_API_ID and YOUR_API_HASH with the credentials you received from Telegram.
  6. Start the Telegram CLI:

    telethon --config ~/.telegramcli.conf
    

    You will be prompted to log in to Telegram using your phone number and verification code.

Using the Telegram CLI:

Once you're logged in, you can use the Telegram CLI with commands like:

  • Send a message: send "Hello World" to @username
  • Get chat history: get_history chat @username
  • Download a file: download_media chat @username message_id
  • Create a group: create_group "New Group" "Member1" "Member2"
  • Add members to a group: add_members group @group_name "Member1" "Member2"

Note: You can find a detailed list of commands and their usage in the Telethon documentation: https://docs.telethon.dev/en/latest/

Security Considerations:

  • API Key Security: Keep your API ID and API Hash confidential. Do not share them with anyone.
  • Two-Factor Authentication: Enable two-factor authentication on your Telegram account for extra security.

Conclusion:

Installing and using the Telegram CLI on CentOS provides a powerful command-line interface for interacting with your Telegram account. This guide helps you get started with the Telegram CLI, enabling efficient and flexible management of your Telegram presence. Remember to prioritize security by protecting your API credentials and enabling two-factor authentication.

This article was created with the help of information from the following GitHub resources:

I encourage you to explore the Telethon documentation and the Telegram CLI's capabilities for enhanced management of your Telegram accounts.

Related Posts