def getAccess(user_id):
with sqlite3.connect('users.db') as conn:
cursor = conn.cursor()
cursor.execute('SELECT user_group_id FROM users WHERE user_id=?',(user_id,))
result = cursor.fetchall()
return result
@bot.message_handler(commands=['auth'])
def Authorization(message):
access = getAccess(message.chat.id)
if access:
for acc in access:
if acc == 1:
bot.send_message(message.chat.id,'Привет Admin!')
else:
bot.send_message(message.chat.id,'Привет User!')
else:
bot.send_message(message.chat.id,'Вы не зарегистрированны в системе!')
tkinter exit event
elif message.text == 'Случайная песня':
files = os.listdir('songs1')
list = []
for x in files:
list.append(x)
song = random.choice(list)
bot.send_audio(message.chat.id, song)
elif message.text == 'Случайная песня':
song = random.choice([x for x in os.listdir('songs1')])
bot.send_audio(message.chat.id, song)
import cv2
import pyautogui
import numpy as np
small_image = cv2.imread('mask.png')
image = pyautogui.screenshot()
image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
result = cv2.matchTemplate(small_image, image, cv2.TM_CCOEFF)
_,_,_,xy = cv2.minMaxLoc(result)
MPx,MPy = xy
trows,tcols = small_image.shape[:2]
cropped_image = image[MPy:MPy+trows, MPx:MPx+tcols]
cv2.imwrite("CroppedImage.png", cropped_image)
aa = input()
bb = input()
a = complex(int(aa.split(' ')[0]), int(aa.split(' ')[1]))
b = complex(int(bb.split(' ')[0]), int(bb.split(' ')[1]))
s1 = (a+b)
s2 = (a-b)
s3 = (a*b)
print(a,' + ',b,' = ', s1)
print(a,' - ',b,' = ', s2)
print(a,' * ',b,' = ', s3)
let form = document.querySelector('.form'),
formRequired = document.querySelectorAll('.required');
form.onsubmit = function () {
if(document.querySelectorAll('.form-error')){
for(let x of document.querySelectorAll('.form-error')){
x.remove();
}
}
formRequired.forEach(function (input) {
if (input.value === '') {
input.classList.add('error');
var error = document.createElement('p');
error.innerHTML = 'Поле является обязательным';
error.classList.add('form-error');
input.after(error);
} else {
input.classList.remove('error');
}
})
return false;
}
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installati...
You do not need to install all supported external libraries to use Pillow’s basic features. Zlib and libjpeg are required by default.
mount -o remount, rw /
passwd pi
sync
exec /sbin/init
sudo poweroff
import random
import asyncio
from telethon import TelegramClient, events
import config as cfg
bot = TelegramClient('Bot', cfg.api_id, cfg.api_hash)
@bot.on(events.NewMessage(pattern=r'^(?i)(idchat){1}$'))
async def echoidchat(event):
await bot.send_message(event.chat, 'ответ')
async def parseurls():
while True:
ts = abs(int(random.random()*10))
print(f'parseurls({ts})')
await sendmsg(ts)
await asyncio.sleep(ts)
async def sendmsg(msg):
print(f'sendmsg({msg}) - start')
channel = await bot.get_entity('https://t.me/elvistest')
await bot.send_message(channel, f'ответ из другого потока {msg}')
print(f'sendmsg({msg}) - done')
def main():
bot.start(bot_token=cfg.bot_token)
loop = asyncio.get_event_loop()
tasks = [
loop.create_task(parseurls()),
loop.create_task(bot.run_until_disconnected()),
]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
if __name__ == '__main__':
main()