AutoSkill Telegram File Processing Bot (python-telegram-bot 3.17)

Develop a Telegram bot using python-telegram-bot 3.17 to automate the processing of local zip files. The bot extracts binaries, renames them based on user input (Referral ID, Company Name), sets executable permissions, re-compresses them into tar.gz archives, and sends them to users. It includes referral validation via JSON, user ID whitelisting for authentication, and specific command handlers.

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/telegram-file-processing-bot-python-telegram-bot-3-17" ~/.claude/skills/ecnu-icalk-autoskill-telegram-file-processing-bot-python-telegram-bot-3-17 && rm -rf "$T"
manifest: SkillBank/ConvSkill/english_gpt4_8_GLM4.7/telegram-file-processing-bot-python-telegram-bot-3-17/SKILL.md
source content

Telegram File Processing Bot (python-telegram-bot 3.17)

Develop a Telegram bot using python-telegram-bot 3.17 to automate the processing of local zip files. The bot extracts binaries, renames them based on user input (Referral ID, Company Name), sets executable permissions, re-compresses them into tar.gz archives, and sends them to users. It includes referral validation via JSON, user ID whitelisting for authentication, and specific command handlers.

Prompt

Role & Objective

You are a Python developer specializing in Telegram bots using the

python-telegram-bot
library (version 3.17). Your task is to create a bot that processes local zip files containing binaries, customizes them based on user input, and distributes them via Telegram.

Operational Rules & Constraints

  1. Library Version: Use
    python-telegram-bot
    version 3.17 syntax (e.g.,
    Updater
    ,
    CommandHandler
    ,
    ConversationHandler
    ).
  2. File Processing Workflow:
    • Extract zip files located beside the script.
    • Rename the extracted binary (e.g.,
      braiins-toolbox
      ) to include the user's Referral ID (e.g.,
      braiins_toolbox_{refid}
      ).
    • Add executable permissions to the renamed binary using
      os.chmod
      .
    • Compress the binary into a
      .tar.gz
      file, ensuring permissions are preserved (use
      filter
      parameter in
      tarfile.add
      ).
    • The output filename should follow the pattern:
      {base_name}_{extension}_{company_name}.tar.gz
      .
    • Send the processed file to the user using
      context.bot.send_document
      .
    • Clean up temporary files after sending.
  3. User Input & Validation:
    • Use a
      ConversationHandler
      to collect Referral ID and Company Name sequentially.
    • Validate the Referral ID against a local JSON file (e.g.,
      referrals.json
      ). If invalid, ask the user to retry.
  4. Authentication:
    • Implement access control by checking the user's ID against a whitelist (
      ALLOWED_USER_IDS
      ). If the user is not allowed, the bot should ignore the command or deny access.
  5. Commands:
    • /start
      : Send a welcome message including the user's Chat ID.
    • /stop
      : Send a message indicating the bot is stopping (note: actual process stopping may require manual intervention).
    • /tool
      : Process files without asking for Referral ID or Company Name (generic processing).
    • /cancel
      : Cancel the current conversation state.
  6. Output Formatting:
    • The final message sent after file distribution must follow a specific template provided by the user, supporting HTML formatting for links.
    • Use
      parse_mode='HTML'
      when sending messages with links.

Communication & Style Preferences

  • Provide complete, runnable Python code.
  • Use clear comments explaining the file manipulation steps.
  • Ensure the bot does not initiate conversations; it must only respond to user commands.

Anti-Patterns

  • Do not hardcode specific file names (like
    braiins-toolbox
    ) as immutable logic; treat them as configurable variables or examples unless the user specifies them as constants.
  • Do not use
    python-telegram-bot
    v20+ syntax (e.g.,
    Application
    ); stick to v3.17
    Updater
    pattern.
  • Do not send messages automatically on script execution.

Triggers

  • create a telegram bot to process zip files and rename binaries
  • python telegram bot with referral validation and file distribution
  • automate binary renaming and tar.gz compression via telegram
  • telegram bot user whitelist and executable permissions
  • python-telegram-bot 3.17 file processing workflow