Browse Source

added deadline days functionality

master
alpcentaur 9 months ago
parent
commit
e419152381
2 changed files with 29 additions and 13 deletions
  1. +28
    -12
      fdb_spider_interface.py
  2. +1
    -1
      new_message_file.txt

+ 28
- 12
fdb_spider_interface.py View File

@ -120,7 +120,7 @@ if __name__ == '__main__':
room_file.close() room_file.close()
room_file_list = room_file_raw.split('§%§%') 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: with open(spider_directory + '/spiders/config.yaml' , "r") as stream:
try: try:
@ -140,6 +140,7 @@ if __name__ == '__main__':
print(room[0]) print(room[0])
room_fdbs = room[2] room_fdbs = room[2]
room_tags = room[3] room_tags = room[3]
room_deadline_days = room[4]
#subprocess.run(["python", spider_directory + 'main.py', fdbs]) #subprocess.run(["python", spider_directory + 'main.py', fdbs])
room_history_list = [] room_history_list = []
try: try:
@ -248,8 +249,12 @@ if __name__ == '__main__':
if url in message[:-1] or data[room_fdb][i][key]["name"] in message: if url in message[:-1] or data[room_fdb][i][key]["name"] in message:
message_was_already_there = True 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') print('went into already there false')
api.send_message(entry_message, room[0]) api.send_message(entry_message, room[0])
print('before writing') 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, 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: as a space indicates a new command argument:
command : `createroom <room-name> <list-fdbs> <list-tags>`
example : `createroom room-test-1 ['giz','fdb2'] ['tag1','tag2','tag3']`
command : `createroom <room-name> <list-fdbs> <list-tags> <days-to-deadline>`
example : `createroom room-test-1 ['giz','fdb2'] ['tag1','tag2','tag3'] 7`
----------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------
To delete a room use To delete a room use
command : `deleteroom <room-id>` command : `deleteroom <room-id>`
@ -463,7 +468,7 @@ if __name__ == '__main__':
room_file.close() room_file.close()
room_file_list = room_file_raw.split('§%§%') 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: with open(spider_directory + '/spiders/config.yaml' , "r") as stream:
try: try:
@ -488,7 +493,7 @@ if __name__ == '__main__':
print(room[0]) print(room[0])
room_fdbs = room[2] room_fdbs = room[2]
room_tags = room[3] room_tags = room[3]
room_deadline_days = room[4]
# not running get_rooms because disfunctional # not running get_rooms because disfunctional
#subprocess.run(["python", spider_directory + 'main.py', fdbs]) #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: if url in message[:-1] or data[room_fdb][i][key]["name"] in message:
message_was_already_there = True 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: except Exception as e:
filters = 'NONE' filters = 'NONE'
print(e) 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"]' 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 <Raumname> <Liste-Datenbanken> <Liste-Filtertags>'
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 <Raumname> <Liste-Datenbanken> <Liste-Filtertags> <Tage-bis-zur-Frist>'
else: else:
try: try:
@ -726,7 +742,7 @@ if __name__ == '__main__':
read_only=False) read_only=False)
new_room_id = new_room['channel']['_id'] new_room_id = new_room['channel']['_id']
room_file = open('rooms/' + new_room_id + '.txt', 'w') 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() room_file.close()
answer = 'Der Command wurde übermittelt' answer = 'Der Command wurde übermittelt'

+ 1
- 1
new_message_file.txt View File

@ -1 +1 @@
printcommands§%§%WM56LadJhkYBuGayZ
printcommands§%§%RPDjNmahwDpHHhgkK

Loading…
Cancel
Save