Ни на одном сайте нету нормальной инструкции.Неправда, есть офф. доки - docs.aiogram.dev. Но так как я не работал с данной библиотекой и не планирую - то я их читать за вас не хочу.
@dp.message_handler(content_types=['photo'])
async def scan_message(msg: types.Message):
document_id = msg.photo[0].file_id
file_info = await bot.get_file(document_id)
print(f'file_id: {file_info.file_id}')
print(f'file_path: {file_info.file_path}')
print(f'file_size: {file_info.file_size}')
print(f'file_unique_id: {file_info.file_unique_id}')
file_id: AgACAgIAAxkBAAIO2WBd12gIEuhnEzsUgfS_VguqIVMLAAK5sDEb0qrwSiETN9pic8VjZPdZoi4AAwEAAwIAA20AA3dRAAIeBA
file_path: photos/file_48.jpg
file_size: 12946
file_unique_id: AQADZPdZoi4AA3dRAAI
dp.register_message_handler(secret_command, IDFilter(user_id=admin_id), commands="abracadabra")
class SomeState(StatesGroup):
name = State()
@dp.message_handler(commands='timer')
async def register_executor(msg):
await msg.answer('Отправь мне свое имя')
SomeState.name.set()
@dp.message_handler(state=SomeState.name)
async def re_get_about(msg):
state.update_data(name=msg.text)
user_data = await state.get_data()
await msg.answer(f'Твое имя {user_data["name"]}')
SomeState.finish()
def simple_numbers(m, n):
for i in range(m, n):
for j in range(2, i):
if i % j == 0:
break
else:
yield i
def test(g, m, n):
lst = []
for i in simple_numbers(m, n):
lst.append(i)
if len(lst)>1:
if abs(lst[-1] - lst[-2]) == g:
return [lst[-1], lst[-2]]
return False
g = 6
m = 2
n = 1100000
rez = test(g, m, n)
if rez:
print("{} - {} = {}".format(rez[0], rez[1], g))
else:
print("No")
def isPrime(n):
# Corner case
if (n <= 1):
return False
# Check from 2 to sqrt(n)
for i in range(2, int(n**.5)+1):
if (n % i == 0):
return False
return True
def gap(distance, range_lower, range_upper):
worked_area = list(range(range_lower,range_upper+1))
find_primes = [el for el in worked_area if isPrime(el)]
if len(find_primes) == 0:
return []
for i in range(1, len(find_primes)):
if find_primes[i] - find_primes[i-1] == distance:
return [find_primes[i-1], find_primes[i]]
return []
def isPrime(n):
# Corner case
if (n <= 1):
return False
# Check from 2 to sqrt(n)
for i in range(2, int(n**.5)+1):
if (n % i == 0):
return False
return True
def gap(g, m, n):
start = 0
end = 0
for i in range(m,n+1):
if isPrime(i):
if start == 0:
start = i
elif end == 0:
end = i
else:
start = end
end = i
if end - start == g:
return [start, end]
return None