[Project #1] inventory management_bot - 6 week

jang·2026년 4월 20일

[Project #1]

목록 보기
6/6
post-thumbnail

🛠️ 주요 구현 내용

1. API 토큰 보안 설정 (python-dotenv)

소스 코드에 직접 노출되어 있던 텔레그램 API 토큰을 .env 파일로 격리했습니다. GitHub 등 외부 저장소에 코드를 공유할 때 보안 사고를 방지하기 위한 필수 조치로, 환경 변수를 로드하여 토큰을 호출하는 안전한 구조를 설계했습니다.

2. 재고 부족 자동 알림 시스템

단순히 재고를 보여주는 것에 그치지 않고, 수량이 특정 임계치(10개) 미만으로 떨어질 경우 사용자에게 ⚠️ 재고 부족 알림을 리스트로 묶어 전송하는 로직을 구현했습니다. 이를 통해 사용자가 재입고 시점을 직관적으로 파악할 수 있도록 했습니다.

3. 사용자 가이드 /start 명령어 구축

봇을 처음 사용하는 사용자나 기능이 생소한 사용자를 위해 봇의 용도와 사용 가능한 명령어 리스트를 안내하는 /start 기능을 추가했습니다. 서비스의 첫인상을 결정하는 UX(사용자 경험) 측면을 고려하여 마크다운 형식을 적용해 가독성을 높였습니다.

⚠️ 트러블슈팅 (Troubleshooting)

이슈: IndentationError와 .env 확장자 인식 문제

  • 현상: 코드 수정 중 들여쓰기가 꼬여 실행이 안 되거나, .env 파일을 만들었는데 시스템이 읽지 못함.
  • 원인: 파이썬의 엄격한 들여쓰기 규칙 위반 및 맥 텍스트 편집기에서 숨겨진 .txt 확장자가 붙어 파일명이 .env.txt가 됨.
  • 해결: IDLE의 인덴트 조정 기능을 활용해 코드 구조를 재정렬하고, 터미널을 통해 파일 확장자를 정확히 수정하여 해결했습니다.

결과


🇯🇵 Japanese Version

【週次報告】テレグラム在庫管理BOT開発 - 第6週:セキュリティ設定およびUXの改善


🛠️ 主な実装内容

1. APIトークンのセキュリティ設定

コード内に直接記述されていたトークンを .env ファイルに分離しました。GitHub などの公開リポジトリへの漏洩を防ぐための必須処置であり、環境変数をロードして呼び出す安全な設計を適用しました。

2. 在庫不足自動アラートシステム

在庫が特定のしきい値(10個)を下回った際、自動的に ⚠️ 在庫不足アラート をリスト形式で通知するロジックを実装しました。これにより、ユーザーが再発注のタイミングを即座に判断できるよう利便性を高めました。

3. ユーザーガイド /start コマンドの構築

初めてのユーザーでもスムーズに利用できるよう、BOTの用途と使用可能なコマンド一覧を案内する /start機能を実装しました。UX(ユーザーエクスペリエンス)を考慮し、マークダウン形式を活用して視認性の高いインターフェースを提供しました。

⚠️ トラブルシューティング

課題 1:macOSにおける .env ファイルの拡張子認識エラー

  • 事象: 環境変数のロードに失敗し、トークンが読み込めない。
  • 原因: テキストエディタの仕様により、不可視の .txt 拡張子が付与され、実ファイル名が .env.txt になっていた。
  • 解決: ターミナルでファイル構造を確認し、拡張子を強制的に削除することで正常に読み込みを完了。

課題 2:例外処理実装時のインデント(IndentationError)

  • 事象: try-except 構文の挿入中に文法エラーが発生し、プログラムが停止。
  • 原因: エディタ上でタブとスペースが混在し、Python特有のインデントルールが崩れたため。
  • 解決: IDLE のインデント調整機能を活用し、コードブロックの間隔をスペース4つに統一して解決。

結果


🇺🇸 English Version

[Weekly Report] Telegram Inventory Bot - Week 6: Security & UX Optimization


🛠️ Implementation Details

1. API Token Security Management

To prevent credential leaks, I migrated the Telegram API token from the source code to a separate .env file. This ensures security when sharing code on platforms like GitHub by using the python-dotenv library to load sensitive data.

2. Automated Low-Stock Alert System

I implemented a proactive monitoring logic that triggers a ⚠️ Low Stock Notification when an item's quantity falls below a defined threshold (10 units). This feature enables efficient inventory management by highlighting items that require immediate restocking.

3. User Onboarding via /start Command

To improve the user experience (UX), I designed a /start command that provides a comprehensive guide on how to use the bot. By using Markdown formatting, I ensured that the command list and instructions are clear and easy for new users to follow.

⚠️ Troubleshooting

Issue 1: Hidden File Extension Conflict on macOS

  • Symptoms: Failed to load environment variables from the .env file.
  • Root Cause: macOS TextEdit appended a hidden .txt extension, resulting in a filename of .env.txt.
  • Resolution: Used terminal commands to identify the hidden extension and renamed the file correctly.

Issue 2: IndentationError during Exception Handling

  • Symptoms: Syntax error triggered when adding try-except blocks.
  • Root Cause: Inconsistency between Tabs and Spaces in the IDLE editor, breaking Python's structural rules.
  • Resolution: Standardized the code indentation (4 spaces) using IDLE's "Indent Region" tool to ensure structural integrity.

Result

profile
비전공자가 AI 엔지니어가 되는 과정

0개의 댓글