From e4191523813e027346fa8baa92e777e1783ff273 Mon Sep 17 00:00:00 2001 From: alpcentaur Date: Mon, 22 Jan 2024 16:05:21 +0100 Subject: [PATCH] added deadline days functionality --- fdb_spider_interface.py | 40 ++++++++++++++++++++++++++++------------ new_message_file.txt | 2 +- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/fdb_spider_interface.py b/fdb_spider_interface.py index 428b124..8b401bd 100644 --- a/fdb_spider_interface.py +++ b/fdb_spider_interface.py @@ -120,7 +120,7 @@ if __name__ == '__main__': room_file.close() room_file_list = room_file_raw.split('§%§%') - room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]]) + room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2], room_file_list[3]]) with open(spider_directory + '/spiders/config.yaml' , "r") as stream: try: @@ -140,6 +140,7 @@ if __name__ == '__main__': print(room[0]) room_fdbs = room[2] room_tags = room[3] + room_deadline_days = room[4] #subprocess.run(["python", spider_directory + 'main.py', fdbs]) room_history_list = [] try: @@ -248,8 +249,12 @@ if __name__ == '__main__': if url in message[:-1] or data[room_fdb][i][key]["name"] in message: message_was_already_there = True + now = datetime.datetime.now() + now_formatted = dateutil.parser.parse(str(now)) + delta = period_data_formatted - now_formatted + - if message_was_already_there == False: + if message_was_already_there == False and delta.days < int(room_deadline_days): print('went into already there false') api.send_message(entry_message, room[0]) print('before writing') @@ -409,8 +414,8 @@ if __name__ == '__main__': ----------------------------------------------------------------------------------------- To create a room use following command, but be sure to **not have spaces** in your lists, as a space indicates a new command argument: - command : `createroom ` - example : `createroom room-test-1 ['giz','fdb2'] ['tag1','tag2','tag3']` + command : `createroom ` + example : `createroom room-test-1 ['giz','fdb2'] ['tag1','tag2','tag3'] 7` ----------------------------------------------------------------------------------------- To delete a room use command : `deleteroom ` @@ -463,7 +468,7 @@ if __name__ == '__main__': room_file.close() room_file_list = room_file_raw.split('§%§%') - room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]]) + room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2], room_file_list[3]]) with open(spider_directory + '/spiders/config.yaml' , "r") as stream: try: @@ -488,7 +493,7 @@ if __name__ == '__main__': print(room[0]) room_fdbs = room[2] room_tags = room[3] - + room_deadline_days = room[4] # not running get_rooms because disfunctional #subprocess.run(["python", spider_directory + 'main.py', fdbs]) @@ -647,7 +652,12 @@ if __name__ == '__main__': if url in message[:-1] or data[room_fdb][i][key]["name"] in message: message_was_already_there = True - if message_was_already_there == False: + now = datetime.datetime.now() + now_formatted = dateutil.parser.parse(str(now)) + delta = period_data_formatted - now_formatted + + + if message_was_already_there == False and delta < int(room_deadline_days): @@ -712,12 +722,18 @@ if __name__ == '__main__': except Exception as e: filters = 'NONE' print(e) - - if len(user_input_list) > 3: + try: + days_to_deadline = user_input_list[4] + except Exception as e: + days_to_deadline = 'NONE' + print(e) + + + if len(user_input_list) > 4: answer = 'Die Syntax hat einen Fehler. Wahrscheinlich sind Leerzeichen in den Listen. Leerzeichen definieren die Syntax. Versuche es erneut, nach dem Muster -> createroom room1 ["fdb1","fdb2"] ["tag1","tag2"]' - if room_name == 'NONE' or databases == 'NONE' or filters == 'NONE': - answer = 'Um einen Raum zu erstellen, in dem neueste Einträge geteilt werden, lautet die Syntax: createroom ' + if room_name == 'NONE' or databases == 'NONE' or filters == 'NONE' or days_to_deadline = 'NONE': + answer = 'Um einen Raum zu erstellen, in dem neueste Einträge geteilt werden, lautet die Syntax: createroom ' else: try: @@ -726,7 +742,7 @@ if __name__ == '__main__': read_only=False) new_room_id = new_room['channel']['_id'] room_file = open('rooms/' + new_room_id + '.txt', 'w') - room_file.write( room_name + '§%§%' + databases + '§%§%' + filters) + room_file.write( room_name + '§%§%' + databases + '§%§%' + filters + '§%§%' + days_to_deadline) room_file.close() answer = 'Der Command wurde übermittelt' diff --git a/new_message_file.txt b/new_message_file.txt index 982ba74..8c10874 100644 --- a/new_message_file.txt +++ b/new_message_file.txt @@ -1 +1 @@ -printcommands§%§%WM56LadJhkYBuGayZ \ No newline at end of file +printcommands§%§%RPDjNmahwDpHHhgkK \ No newline at end of file