From 4b86dfee7a12bbaf4bacad299c9b295d6cd4825b Mon Sep 17 00:00:00 2001 From: alpcentaur Date: Tue, 6 Feb 2024 14:28:54 +0000 Subject: [PATCH] added name2id, added name functionality to first function addtags --- fdb_spider_interface.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/fdb_spider_interface.py b/fdb_spider_interface.py index 2fc87a0..0ff0800 100644 --- a/fdb_spider_interface.py +++ b/fdb_spider_interface.py @@ -34,6 +34,30 @@ URI = f'http://{HOST}/api/v1/chat' if __name__ == '__main__': + + + def name2id(name): + # 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[:-4], room_file_list[0], room_file_list[1], room_file_list[2], room_file_list[3]]) + + outputid = 'NONE' + for roo in room_list: + if roo[1] == name: + outputid = roo[0] + return outputid + + + api = RocketChatAPI(settings={'username': botname, 'password': botpassword, 'domain': server_url}) @@ -342,7 +366,8 @@ if __name__ == '__main__': if user_input_list[0] == 'addtags': try: - room_id_add_tags = user_input_list[1] + room_name_add_tags = user_input_list[1] + room_id_add_tags = name2id(room_name_add_tags) except: room_id_add_tags = 'NONE' try: