Python
- 9 ответов
- 0 вопросов
9
Вклад в тег
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()
#-----------------------------------------------------#
#Здесь располагай свой код
# -----------------------------------------------------#
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)
Я далеко не программист
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()
import os
prefix = '\\\\?\\'
path = 'C:\Program Files (x86)'
print(os.listdir(prefix+path))