import os
import signal
import keyboard
import multiprocessing
def hook(pid):
while True:
if keyboard.is_pressed('ctrl + 1'):
os.kill(pid,signal.SIGTERM)
os._exit(1)
if __name__ == '__main__':
pid = os.getpid()
multiprocessing.Process(target=hook,args=[pid]).start()
#-----------------------------------------------------#
#Здесь располагай свой код
# -----------------------------------------------------#
Я далеко не программист
import telebot
import threading
import os
bot = telebot.TeleBot('...................')
def voiceloop(bot,chatId):
files = set(os.listdir())
while True:
new = set(os.listdir())
if new != files:
try:
send = list(new.difference(files))[0]
bot.send_voice(chatId, open(send, 'rb'))
files = new
except:
pass
@bot.message_handler(commands=['start'])
def start(massage):
chatId = massage.chat.id
text = massage.text.lower
t = threading.Thread(target=voiceloop, args = (bot,chatId))
t.start()
bot.polling()
with TelegramClient (api_hash, api_id)as client:
msg = client.send_message(group, 'test')
edit.message(group, msg.id, 'текст')
message = client.send_message(chat_id, text)
message = client.send_message(chat_id, text)
print("ID сообщения: ", message.id)
message = client.send_message(chat_id, text)
client.edit_message(chat_id,message.id,text)