Функции, используемые в запросах, могут сделать их медленными. Проверьте, какие функции вы используете и как они влияют на производительность. В SQLAlchemy это функции из модуля `func`.
query = (
select(
func.coalesce(A.id, "").label("card_1"),
func.coalesce(A.serial_number, "").label("card_2"),
func.coalesce(B.name, "").label("card_3"),
func.coalesce(C.name, "").label("card_4"),
func.coalesce(A.user_name, "").label("card_5"),
func.coalesce(A.user_phone_number, "").label("card_6"),
func.coalesce(A.balance_current, "").label("card_7"),
func.coalesce(A.balance_bonus, "").label("card_8"),
func.coalesce(A.active, "").label("card_9"),
func.coalesce(D.name, "0").label("card_10"),
func.coalesce(A.type, "").label("card_11") if filter_body.is_active == 1 else None,
)
.filter(A.company_id.in_(filter_body.prj_ids))
.join(B, A.company_id == B.id)
.join(C, A.voc_id == C.id)
.outerjoin(D, A.tariff_plan == D.id)
.offset(filter_body.offset)
.limit(filter_body.limit)
)
async with self._async_session_scope() as s:
result = await s.execute(query)
return result.fetchall()
t = "310_089-2"
with open('file.txt', 'r') as file:
lines = file.readlines()
result = [line.strip() for line in lines if t in line]
print(result)
import requests
def check_telegram_username(username: str):
api_url = "https://api.telegram.org/bot<твой токен бота>/createChat"
params = {
'user_id': 't10000', # любой user_id (например, 't10000')
'type': 'private',
'title': 'test_group',
'first_name': 'Test',
'last_name': 'User',
'username': username
}
response = requests.post(api_url, json=params)
if response.status_code == 200:
data = response.json()
if 'result' in data and 'chat' in data['result']:
return True
else:
return False
# пример использования
username_to_check = 'your_username'
result = check_telegram_username(username_to_check)
if result is not None:
if result:
print(f"Username '{username_to_check}' доступен.")
else:
print(f"Username '{username_to_check}' занят.")
import ctypes
signed_byte = ctypes.c_int8 # знаковый 8битный
unsigned_byte = ctypes.c_uint8 # беззнаковый 8битный
signed_value = signed_byte(-5)
unsigned_value = unsigned_byte(255)
print(signed_value.value) # -5
print(unsigned_value.value) # 255
video_kb = types.InlineKeyboardMarkup()
music_bt = types.InlineKeyboardButton(text=' Скачать музыку', callback_data=f'get_music|{info_video["aweme_list"][0]["aweme_id"]}')
info_bt = types.InlineKeyboardButton(text=' Статистика', callback_data=f'get_stat|{info_video["aweme_list"][0]["aweme_id"]}')
authorinfo_bt = types.InlineKeyboardButton(text=' О авторе', callback_data=f'author|{info_video["aweme_list"][0]["aweme_id"]}')
video_kb.row(music_bt,info_bt)
video_kb.row(authorinfo_bt)
if info_video['aweme_list'][0]['video']['height'] == 0:
getphoto_bt = types.InlineKeyboardButton(text=' Скачать фото', callback_data=f'getphoto|{info_video["aweme_list"][0]["aweme_id"]}')
video_kb.row(getphoto_bt)
else:
getvideo_bt = types.InlineKeyboardButton(text=' Скачать видео', callback_data=f'getvideo|{info_video["aweme_list"][0]["aweme_id"]}')
video_kb.row(getvideo_bt)
bot.send_sticker(message.chat.id,'CAACAgIAAxkBAAEKGfJk5iH1z2RktPZ4FwrS7ZGKd7A5lAACFgADDkfHKEcrF76w95k0MAQ')
bot.send_message(message.chat.id,f' Видео получено!\n\n<b>Что с ним сделать? </b>', parse_mode='HTML', reply_markup=video_kb)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.data == <нужный колл>:
print(123)
# Import smtplib for the actual sending function
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
# Open a plain text file for reading. For this example, assume that
# the text file contains only ASCII characters.
with open(textfile, 'rb') as fp:
# Create a text/plain message
msg = MIMEText(fp.read())
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP('localhost')
s.sendmail(me, [you], msg.as_string())
s.quit()
from telegram.ext import Updater
updater = Updater(token='<YOUR TOKEN HERE>')
dispatcher = updater.dispatcher
def startCommand(bot, update):
bot.send_message(chat_id=update.message.chat_id, text='Hello!')
start_command_handler = CommandHandler('start', startCommand)
updater.start_polling(clean=True)
updater.idle()