geekcomputers / geekcomputers/Python

Bot

オープン
#3,155 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
35.4k
フォーク
12.9k
平均マージ
2時間 37分
マージ済み PR(30日)
1

説明

import logging
import json
import os
from aiogram import Bot, Dispatcher, executor, types
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton

logging.basicConfig(level=logging.INFO)

Telegram tokenni Replit Secrets (🔒) dan oling

BOT_TOKEN = os.getenv("8680300677:AAEzbGu8DHv4B9n9cI9xgkmA9ueA5EvS_GE")
bot = Bot(token=8680300677:AAEzbGu8DHv4B9n9cI9xgkmA9ueA5EvS_GE)
dp = Dispatcher(bot)

Ma'lumotlar va fayllar saqlanishi

DATA_FILE = "users.json"
MEDIA_FOLDER = "files"

if not os.path.exists(MEDIA_FOLDER):
os.makedirs(MEDIA_FOLDER)

Foydalanuvchilarni yuklash / saqlash

def load_users():
if not os.path.exists(DATA_FILE):
return {}
with open(DATA_FILE, "r", encoding="utf-8") as f:
return json.load(f)

def save_users(data):
with open(DATA_FILE, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)

users = load_users()

Telefon yuborish tugmasi

phone_kb = ReplyKeyboardMarkup(resize_keyboard=True)
phone_kb.add(KeyboardButton("📞 Telefon raqamni yuborish", request_contact=True))

/start komandasi

@dp.message_handler(commands=["start"])
async def start(msg: types.Message):
await msg.answer(
"Assalomu alaykum!\nBot orqali ro‘yxatdan o‘tasiz.\nTelefon raqamingizni yuboring.",
reply_markup=phone_kb
)

Telefon raqam qabul qilish

@dp.message_handler(content_types=types.ContentType.CONTACT)
async def get_phone(msg: types.Message):
user_id = str(msg.from_user.id)
users[user_id] = {
"name": msg.from_user.full_name,
"phone": msg.contact.phone_number,
"passport": "",
"driver_license": "",
"car_passport": "",
"files": []
}
save_users(users)
await msg.answer("✅ Telefon qabul qilindi.\nEndi pasport ma’lumotini kiriting:", reply_markup=types.ReplyKeyboardRemove())

Pasport

@dp.message_handler(lambda m: str(m.from_user.id) in users and users[str(m.from_user.id)]["passport"] == "")
async def get_passport(msg: types.Message):
user_id = str(msg.from_user.id)
users[user_id]["passport"] = msg.text.strip()
save_users(users)
await msg.answer("✅ Pasport qabul qilindi.\nEndi haydovchilik guvohnomangizni kiriting:")

Haydovchilik guvohnomasi

@dp.message_handler(lambda m: str(m.from_user.id) in users and users[str(m.from_user.id)]["driver_license"] == "")
async def get_driver_license(msg: types.Message):
user_id = str(msg.from_user.id)
users[user_id]["driver_license"] = msg.text.strip()
save_users(users)
await msg.answer("✅ Haydovchilik guvohnomasi qabul qilindi.\nEndi mashina texnik pasportini kiriting:")

Mashina texnik pasporti

@dp.message_handler(lambda m: str(m.from_user.id) in users and users[str(m.from_user.id)]["car_passport"] == "")
async def get_car_passport(msg: types.Message):
user_id = str(msg.from_user.id)
users[user_id]["car_passport"] = msg.text.strip()
save_users(users)
await msg.answer("✅ Texnik pasport qabul qilindi.\nEndi hujjatlarni rasm/fayl sifatida yuborishingiz mumkin:")

Fayl / rasm qabul qilish

@dp.message_handler(content_types=[types.ContentType.DOCUMENT, types.ContentType.PHOTO])
async def handle_files(msg: types.Message):
user_id = str(msg.from_user.id)
if user_id not in users:
await msg.answer("Iltimos, /start buyrug‘i orqali ro‘yxatdan o‘ting.")
return

file_id = None
if msg.content_type == "document":
    file_id = msg.document.file_id
    file_name = msg.document.file_name
    await msg.document.download(os.path.join(MEDIA_FOLDER, file_name))
elif msg.content_type == "photo":
    file_id = msg.photo[-1].file_id
    file_name = f"{file_id}.jpg"
    await msg.photo[-1].download(os.path.join(MEDIA_FOLDER, file_name))

users[user_id]["files"].append(file_name)
save_users(users)
await msg.answer(f"✅ Fayl qabul qilindi va saqlandi: {file_name}")

Avto-javob

@dp.message_handler()
async def auto_reply(msg: types.Message):
await msg.answer("🤖 Avto-javob:\nIltimos, /start buyrug‘ini bosing va ro‘yxatdan o‘ting.")

Bot ishga tushadi

if name == "main":
executor.start_polling(dp, skip_updates=True)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

この issue には単独で動作する Python ボットのスニペットが含まれていますが、リポジトリ内のファイル、テスト、エントリーポイント、または要求された変更については何も示されていません。コーディングする前に、まず issue #3155 周辺のリポジトリのコンテキストを確認し、意図する結果とスコープを明確にしてください。完了条件は提供されていません。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
10/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。