Partially initialized module functions has no attribute first_join (most likely due to a circula)
from telebot import logger
import datetime
import sqlite3 as lite
import logging
import telebot
from telebot import types as t
import functions
import menu
import settings
bot_token = settings.test_token
logger.setLevel(logging.INFO)
bot = telebot.TeleBot(bot_token)
commands = ['/command', '/add']
def start_add_command(message, start, add, dark):
if message.text == '/start' and start is True:
choose_good1(message)
elif message.text == '/add' and message.chat.id in settings.admin and add is True:
start_uploading(message)
elif message.text == '/command' and message.chat.id in settings.superadmin and dark is True:
admin_panel(message)
elif message.text == '/help':
return help_menu(message)
@bot.message_handler(commands=['start'])
def choose_good1(message):
chat_id = message.chat.id
functions.first_join(chat_id, message.from_user.username)
if message.text == '/start':
bot.send_message(chat_id, 'Добро пожаловать в магазин ! У нас вы найдете лучшие цены и лучшее качество.\nЧаты и отзывы: ', reply_markup=t.ReplyKeyboardRemove())
msg = bot.send_message(chat_id, 'Выберите товар', reply_markup=menu.drugs_crutches())
bot.register_next_step_handler(msg, choose_weight_2, chat_id)
if message.text == 'Назад к выбору товара':
msg = bot.send_message(chat_id, 'Выберите товар', reply_markup=menu.drugs_crutches())
bot.register_next_step_handler(msg, choose_weight_2, chat_id)
import datetime
import json
import sqlite3 as lite
from re import findall
from parsedatetime import Calendar
import requests
# noinspection PyUnresolvedReferences
import requests_random_user_agent
from telebot import types as t
from os.path import exists
import main
from main import bot
import settings
import fitz
from time import mktime, time
def first_join(user_id, username):
con = lite.connect('database.sqlite')
cur = con.cursor()
row = cur.execute(f'SELECT * FROM users WHERE user_id = ?', [user_id]).fetchall()
if len(row) == 0:
cur.execute(
f'INSERT INTO users (user_id, name, data) VALUES (?,?,?)', [user_id, username, datetime.datetime.now()])
con.commit()
if len(row) != 0:
cur.execute(
f'update users set name=?, activity=? where user_id=?', [username, datetime.datetime.now(), user_id])
con.commit()
con.close()