diff --git a/.fdb_spider_interface.py.swp b/.fdb_spider_interface.py.swp new file mode 100644 index 0000000..73853a6 Binary files /dev/null and b/.fdb_spider_interface.py.swp differ diff --git a/fdb_spider_interface.py b/fdb_spider_interface.py index 7faa046..94345e3 100644 --- a/fdb_spider_interface.py +++ b/fdb_spider_interface.py @@ -5,13 +5,14 @@ import json import requests config = configparser.ConfigParser() -config.read('/root/fdb-spider-interface/config.ini') +config.read('config.ini') botname = config['Chat']['username'] botpassword = config['Chat']['password'] server_url = config['Chat']['URL'] room_id = config['Chat']['room_id'] bot_user_id = config['Chat']['bot_user_id'] +spider_directory = config['Spider']['spider_directory'] # here comes the functions to talk to gpt @@ -47,15 +48,10 @@ if __name__ == '__main__': n = 0 import time - import datetime - from datetime import timedelta - while True: - time.sleep(4) + import schedule + def getroomdata(): - # get all the rooms - import os - room_list = [] rooms = os.listdir('rooms') for room in rooms: @@ -65,9 +61,19 @@ if __name__ == '__main__': room_file_list = room_file_raw.split('§%§%') room_list.append([room[:-3], room_file_list[0], room_file_list[1], room_file_list[2]]) + + return room_list + + + + + import datetime + from datetime import timedelta + while True: + time.sleep(4) - #print(room_list) + n += 1 print(n) @@ -126,6 +132,20 @@ if __name__ == '__main__': if user_input_list[0] == 'printrooms': + # get all the rooms + import os + + room_list = [] + rooms = os.listdir('rooms') + for room in rooms: + room_file = open('rooms/' + room, 'r') + room_file_raw = room_file.read() + room_file.close() + + room_file_list = room_file_raw.split('§%§%') + room_list.append([room[:-3], room_file_list[0], room_file_list[1], room_file_list[2]]) + + #print(room_list) answer = str(room_list) @@ -157,7 +177,7 @@ if __name__ == '__main__': members=[latest_message_user_username], read_only=True) - # The logic here is that a new room with the same name gets overwritten + new_room_id = new_room['channel']['_id'] room_file = open('rooms/' + new_room_id + '.txt', 'w') room_file.write( room_name + '§%§%' + databases + '§%§%' + filters) @@ -170,6 +190,9 @@ if __name__ == '__main__': # here comes the code interacting with the spiders output json + + + #answer = 'the up to date entries are: oi Oi Oi!' api.send_message(answer, room_id) diff --git a/new_message_file.txt b/new_message_file.txt index dec3879..e25d66d 100644 --- a/new_message_file.txt +++ b/new_message_file.txt @@ -1 +1 @@ -printrooms§%§%6DQP8M4wYhgWroAx7 \ No newline at end of file +printrooms§%§%P6rQGgS9u7RqZM2iz \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 14c6dca..3ee86d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ charset-normalizer==3.2.0 idna==3.4 requests==2.31.0 rocket-python==1.3.4 +schedule==1.2.1 urllib3==2.0.4