Answer the question
In order to leave comments, you need to log in
Python / Telebot - how to send text from a file to a bot?
Hello!
I decided to simplify my life by blocking accounts in the domain.
Sometimes I am out of place, and the accounts are blocked and users cannot normally use the network, printers, etc.
In the scheduler, on EventID #4740, a PowerShell script is launched and writes the names of blocked users to the blocked.txt file.
Then the Python script reads this list and the data is sent by the bot to Telegram, where I analyze it. If there is an urgent need to unlock the account (for example: the CEO or some other bump) , then I send the /unblock command to the bot and the PowerShell script with the unlock is launched.
I can't solve this issue:
import os
import telebot
def read_blocked():
with open("blocked.txt", "r") as file:
content = file.read()
print(content)
bot = telebot.TeleBot('TOKEN')
bot.send_message(chat_id='##', text='ДАННЫЕ ИЗ ФАЙЛА blocked.txt')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question