from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
from config import TOKEN
from sqlite import db_start, create_profile, edit_profile
async def on_startup(_):
await db_start()
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)
balance = 0
limit = 15000000000000
use = 0
@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
await message.reply("Привет!\nЯ бот-кликер валюты в боте BFG!\n\nЧтобы получить помощь напишите /help")
await create_profile(user_id=message.from_user.id)
await edit_profile(user_id=message.from_user.id)
@dp.message_handler(commands=['help'])
async def help_command(message: types.Message):
await message.reply("/click - кликать игровую валюту (1 клик - 500 ИГ)\n/balance - ваш баланс\n/sell - вывод\n/stat - статистика за этот день\n\nПРИМЕЧАНИЕ - баланс отчищается каждый день")
@dp.message_handler(commands=['stat'])
async def limit_command(message: types.Message):
await message.reply(f"Владелец может вывести ещё - {limit}\nвыведено за сегодня: - {use}")
@dp.message_handler(commands=['balance'])
async def player_balance(message: types.Message):
await message.reply(f"У вас на балансе {balance} тысяч")
@dp.message_handler(commands=['sell'])
async def sell_command(message: types.Message):
await message.reply("Для вывода напишите ? в лс и отправь ему сообщение с балансом")
@dp.message_handler(commands=['click'])
async def plus_balance(message: types.Message):
global balance
await message.reply("+500 к балансу")
balance += 0.5
@dp.message_handler(commands=['Minus_limit'])
async def game(message: types.Message):
global limit
global use
args = message.get_args()
limit -= int(args)
use -= int(args)
if __name__ == '__main__':
executor.start_polling(dp, on_startup=on_startup)
import sqlite3 as sq
from main import balance
async def db_start():
global db, cur
db = sq.connect('new.db')
cur = db.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS profile(user_id TEXT PRIMARY KEY, balance TEXT)")
db.commit()
async def create_profile(user_id):
user = cur.execute("SELECT 1 FROM profile WHERE user_id == '{key}'".format(key=user_id)).fetchone()
if not user:
cur.execute("INSERT INTO profile VALUES(?, ?",(user_id, balance))
db.commit()
async def edit_profile(state, user_id):
async with state.proxy() as data:
cur.execute("UPDATE profile WHERE user_id == '{}' SET balance == '{}'".format(user_id, data['balance']))
db.commit()
Traceback (most recent call last):
File "main.py", line 6, in <module>
from sqlite import db_start, create_profile, edit_profile
File "/home/runner/CrispWrongDigits/sqlite.py", line 2, in <module>
from main import balance
File "/home/runner/CrispWrongDigits/main.py", line 6, in <module>
from sqlite import db_start, create_profile, edit_profile
ImportError: cannot import name 'db_start' from partially initialized module 'sqlite' (most likely due to a circular import) (/home/runner/CrispWrongDigits/sqlite.py)
from sqlite import db_start, create_profile, edit_profile
from main import balance