You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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 :
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 getThe text was updated successfully, but these errors were encountered: