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.
git clone https://github.com/ECNU-ICALK/AutoSkill
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"
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/telegram-file-processing-bot-python-telegram-bot-3-17/SKILL.mdTelegram 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
- Library Version: Use
version 3.17 syntax (e.g.,python-telegram-bot
,Updater
,CommandHandler
).ConversationHandler - File Processing Workflow:
- Extract zip files located beside the script.
- Rename the extracted binary (e.g.,
) to include the user's Referral ID (e.g.,braiins-toolbox
).braiins_toolbox_{refid} - Add executable permissions to the renamed binary using
.os.chmod - Compress the binary into a
file, ensuring permissions are preserved (use.tar.gz
parameter infilter
).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.
- User Input & Validation:
- Use a
to collect Referral ID and Company Name sequentially.ConversationHandler - Validate the Referral ID against a local JSON file (e.g.,
). If invalid, ask the user to retry.referrals.json
- Use a
- Authentication:
- Implement access control by checking the user's ID against a whitelist (
). If the user is not allowed, the bot should ignore the command or deny access.ALLOWED_USER_IDS
- Implement access control by checking the user's ID against a whitelist (
- Commands:
: Send a welcome message including the user's Chat ID./start
: Send a message indicating the bot is stopping (note: actual process stopping may require manual intervention)./stop
: Process files without asking for Referral ID or Company Name (generic processing)./tool
: Cancel the current conversation state./cancel
- Output Formatting:
- The final message sent after file distribution must follow a specific template provided by the user, supporting HTML formatting for links.
- Use
when sending messages with links.parse_mode='HTML'
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
) as immutable logic; treat them as configurable variables or examples unless the user specifies them as constants.braiins-toolbox - Do not use
v20+ syntax (e.g.,python-telegram-bot
); stick to v3.17Application
pattern.Updater - 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