added session log to view your sessions

This commit is contained in:
xssdoctor 2024-04-20 11:56:01 -04:00
parent 017945f484
commit b5ee3d38a3
2 changed files with 12 additions and 0 deletions

View File

@ -31,6 +31,7 @@ def main():
parser.add_argument('--session', '-S', parser.add_argument('--session', '-S',
help="Continue your previous conversation. Default is your previous conversation", nargs="?", const="default") help="Continue your previous conversation. Default is your previous conversation", nargs="?", const="default")
parser.add_argument('--clearsession', help="deletes indicated session. Use 'all' to delete all dessions") parser.add_argument('--clearsession', help="deletes indicated session. Use 'all' to delete all dessions")
parser.add_argument('--sessionlog', help="View the log of a session")
parser.add_argument( parser.add_argument(
"--gui", help="Use the GUI (Node and npm need to be installed)", action="store_true") "--gui", help="Use the GUI (Node and npm need to be installed)", action="store_true")
parser.add_argument( parser.add_argument(
@ -133,6 +134,11 @@ def main():
else: else:
print(f"Session {args.clearsession} cleared") print(f"Session {args.clearsession} cleared")
sys.exit() sys.exit()
if args.sessionlog:
from .helper import Session
session = Session()
print(session.session_log(args.sessionlog))
sys.exit()
standalone = Standalone(args, args.pattern) standalone = Standalone(args, args.pattern)
if args.list: if args.list:
try: try:

View File

@ -49,3 +49,9 @@ class Session:
os.remove(os.path.join(self.sessions_folder, file)) os.remove(os.path.join(self.sessions_folder, file))
else: else:
os.remove(os.path.join(self.sessions_folder, session)) os.remove(os.path.join(self.sessions_folder, session))
def session_log(self, session):
file = os.path.join(self.sessions_folder, session)
if not os.path.exists(file):
return None
with open(file, "r") as f:
return f.read()