def check_users_in_DB(message):
conn = lite.connect(bd)
cursor = conn.cursor()
cursor.execute("SELECT chat_id FROM 'base'")
userslist = str(cursor.fetchall())
conn.close()
if str(message.chat.id) not in userslist:
bot.send_message(message.chat.id, "Sorry!")
else:
#хз как сюда прикрутить выполнение команды, которую выбрал пользователь
@bot.message_handler(func=lambda message: str(message.chat.id) not in users)
def send_deny_message(message):
bot.send_message(message.chat.id, "Нет доступа!")
conn = lite.connect(bd)
cursor = conn.cursor()
conn.begin()
cursor.execute("SELECT chat_id FROM 'base'")
users = str(cursor.fetchall())
conn.commit()
conn.close()
conn.begin()
AttributeError: 'sqlite3.Connection' object has no attribute 'begin'
conn = lite.connect(bd)
cursor = conn.cursor()
cursor.execute("SELECT chat_id FROM 'base'")
users = str(cursor.fetchall())
conn.commit()
conn.close()
conn = lite.connect(bd)
cursor = conn.cursor()
cursor.execute("INSERT.....")
conn.commit()
conn.close()
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = 'path' + message.document.file_name;
with open(src, 'wb') as new_file:
new_file.write(downloaded_file)
new_file.close()
После чего все работает как часы. @bot.callback_query_handler(func=lambda call: True)
def query_handler(call):
chat_id=call.message.chat.id
if call.data == 'man':
bot.send message(chat_id, <i>What i must put in it?</i>)
parse_mode="HTML"
if os.path.splitext(src)[1] == ".zip":
zip_ref = zipfile.ZipFile(filename, 'r')
zip_ref.extractall("path")
zip_ref.close()
bot.send_message(chat_id, "It's a ZIP file")
else:
bot.send_message(chat_id, "WRONG FILE!!!")