Telegram-InstaPy-Scheduling
Telegram-InstaPy-Scheduling copied to clipboard
LogNow get live logs in Action
Thanks to @Tkd-Alex for helping and making this happen.
I would like to share this Function that you can have Live logs sent to your Telegram chat.
Add this Function :
def lognow(bot, update, args):
if str(update.message.chat_id) in allowed_id:
message1 = ""
messagecounter = int( args[1] )
time.sleep(2)
for x in range(messagecounter):
usernames = [ a['username'].lower() for a in users ]
if not args[0].lower() in usernames:
update.message.reply_text("Sorry, username <b>{}</b> is not saved.".format(args[0]), parse_mode='HTML')
return
logsline = 1
with open('{}/logs/{}/general.log'.format(settings['instapy_folder'], args[0].lower()), "r") as f:
lines = f.readlines()
lines = lines[-(logsline+20):] # Prevent empty lines
message = '\n'.join(x for x in lines)
message = clear_lines( '\n'.join(x for x in lines), username=args[0].lower() )
lines = message.split('\n')[-logsline:]
message = '\n'.join(x for x in lines)
if message1 != message:
update.message.reply_text(message, parse_mode='HTML')
message1 = message
time.sleep(2)
else:
time.sleep(4)
ADD
dp.add_handler(CommandHandler("lognow", lognow, pass_args=True))
AFTER
if __name__ == '__main__':
Usage /lognow username number
Number
is the number of logs you wish to get
I'm not sure this feature is a good idea. The bot will be a spammer :/
Yes i was testing and its not a good idea 💡
Your totally right