@r1dddy4sv

Module 'dbworker' has no attribute 'get_md'?

import config
import telebot
import random
import time
import dbworker
import requests
from telebot import types

Token='token'
bot=telebot.TeleBot(Token)
photo='url photo'
def menu(message):
    m=dbworker.get_md(message.chat.id)
    bot.send_message(message.chat.id,'Ниже представлен каталог товаров!',reply_markup=menu_back)
    m1=bot.send_message(message.chat.id,'Ниже представлен каталог товаров!',reply_markup=menu_back).message_id
    bot.send_photo(message.chat.id,photo,caption='товар №1\nописание',reply_markup=size1)
    m2=bot.send_photo(message.chat.id,photo,caption='товар №1\nописание',reply_markup=size1).message_id
    bot.send_photo(message.chat.id,photo,caption='товар №2\nописание',reply_markup=size2)
    m3=bot.send_photo(message.chat.id,photo,caption='товар №2\nописание',reply_markup=size2).message_id
    bot.send_photo(message.chat.id,photo,caption='товар №3\nописание',reply_markup=size3)
    m4=bot.send_photo(message.chat.id,photo,caption='товар №3\nописание',reply_markup=size3).message_id
    md=[]
    md.append(m1,m2,m3,m4)
    if md.append(m)>10:
        md=md.append(m)
        md=md.pop(0,1,2,3)
        dbworker.set_md(message.chat.id, md)
    else:
        dbworker.set_md(message.chat.id, md.append(m))

@bot.message_handler(commands=['start'])
def welcome(message):
    dbworker.set_state(message.chat.id, config.States.S_GL.value)
    gl(message)
@bot.message_handler(func=lambda message: dbworker.get_current_state(message.chat.id) == config.States.S_GL.value)
def otv(message):
    if message.chat.type=='private':
        if message.text=='Сделать Заказ Онлайн!':
            dbworker.set_state(message.chat.id, config.States.S_MENU.value)
            menu(message)  
if __name__ == "__main__":
    bot.infinity_polling()


dbworker:
from vedis import Vedis
import config

def get_md(user_id):
    with Vedis(config.db_file4) as db4:
        try:
            return db4[user_id].decode()  
        except KeyError: 
            return   
        
def set_md(user_id, value):
    with Vedis(config.db_file4) as db4:
        try:
            db4[user_id] = value
            return True
        except:
            
            return False
        
def get_current_state(user_id):
    with Vedis(config.db_file) as db:
        try:
            return db[user_id].decode() 
        except KeyError: 
            return config.States.S_GL.value  

def set_state(user_id, value):
    with Vedis(config.db_file) as db:
        try:
            db[user_id] = value
            return True
        except:
            return False

config:
from enum import Enum
Token='1419935533:AAG5blXisxySbyZHgYWcSwIC8P_9iehCOHY'
db_file = "database.vdb"
db_file2 = "database2.vdb"
class States(Enum):
    S_INFO= "0"  
    S_MENU = "1"
    S_GL= "2"
    S_AMOUNT='3'
    S_OPLATI='4'


ошибка:
module 'dbworker' has no attribute 'get_md'

в функции menu я сохраняю id отправленных ботом сообщений в базу данных, чтобы позже эти сообщения удалить.

config и dbworker находятся в одной папке с основным кодом

(я представил далеко не весь код, но думаю этого достаточно, чтобы увидеть проблему, если необходимо что-то добавить, пишите)

прошу Вас о помощи
спасибо!
  • Вопрос задан
  • 197 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы