forked from onlysharifjon/Sheetsbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (33 loc) · 1.45 KB
/
main.py
File metadata and controls
44 lines (33 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import logging
import openpyxl
from aiogram import Bot, Dispatcher, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.contrib.middlewares.logging import LoggingMiddleware
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.state import State, StatesGroup
TOKEN = '6988980301:AAHtfRkFbZo1R-HexBLovgrm0OX3Bl-Dalo'
bot = Bot(token=TOKEN, parse_mode='HTML')
dp = Dispatcher(bot, storage=MemoryStorage())
logging.basicConfig(level=logging.INFO)
# Middleware for logging
dp.middleware.setup(LoggingMiddleware())
import os
@dp.message_handler(commands='start')
async def start_command(message: types.Message):
await message.reply('Assalomu Aleykum {}!'.format(message.from_user.first_name))
await message.answer('.XLSX yoki .xlsx formatdagi file jo`nating !')
from excel import read_excel_part1
#
@dp.message_handler(content_types=types.ContentTypes.DOCUMENT)
async def file_handler(message: types.Message):
file_name = message.document.file_name
if file_name.lower().endswith('.xlsx'):
await message.document.download(f'uploads/{file_name}')
await message.answer('Fayl yuklandi!')
txt = await read_excel_part1(path=f'uploads/{file_name}', file_name=file_name)
await message.answer(txt)
else:
await message.answer('.XLSX yoki .xlsx formatdagi faylni yuboring!')
if __name__ == '__main__':
from aiogram import executor
executor.start_polling(dp, skip_updates=True)