The Interface of the fdb-spider, based on rocketchat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

751 lines
37 KiB

  1. import os
  2. from rocketchat.api import RocketChatAPI
  3. import configparser
  4. import json
  5. import requests
  6. import yaml
  7. import dateutil.parser
  8. import subprocess
  9. config = configparser.ConfigParser()
  10. config.read('config.ini')
  11. botname = config['Chat']['username']
  12. botpassword = config['Chat']['password']
  13. server_url = config['Chat']['URL']
  14. room_id = config['Chat']['room_id']
  15. bot_user_id = config['Chat']['bot_user_id']
  16. spider_directory = config['Spider']['spider_directory']
  17. # here comes the functions to talk to gpt
  18. # For local streaming, the websockets are hosted without ssl - http://
  19. HOST = 'localhost:5000'
  20. URI = f'http://{HOST}/api/v1/chat'
  21. #URI = f'http://{HOST}/api'
  22. # http://192.168.9.197:5000/api/v1/chat
  23. # For reverse-proxied streaming, the remote will likely host with ssl - https://
  24. # URI = 'https://your-uri-here.trycloudflare.com/api/v1/chat'
  25. if __name__ == '__main__':
  26. api = RocketChatAPI(settings={'username': botname, 'password': botpassword, 'domain': server_url})
  27. # api.send_message('Ciao, I am the fdb-spider', room_id)
  28. #myinfo = api.get_my_info()
  29. #room_history = api.get_private_room_history(room_id)
  30. #print(room_history['messages'][0]['msg'])
  31. # print(myinfo)
  32. rooms = api.get_private_rooms()
  33. print('blubidab oioioi', rooms)
  34. # api.send_message('Ole', room_id)
  35. n = 0
  36. import time
  37. import schedule
  38. #change to False here, if you want to have the update run at server start
  39. already_updated = True
  40. start = True
  41. import datetime
  42. from datetime import timedelta
  43. while True:
  44. time.sleep(2)
  45. #already_updated = True
  46. now = datetime.datetime.now()
  47. current_hour = now.strftime("%H")
  48. #print(current_hour)
  49. # run variable update and creation at start
  50. if start == True:
  51. room_list = []
  52. rooms = os.listdir('rooms')
  53. for room in rooms:
  54. room_file = open('rooms/' + room, 'r')
  55. room_file_raw = room_file.read()
  56. room_file.close()
  57. room_file_list = room_file_raw.split('§%§%')
  58. print(room_list)
  59. print(room)
  60. print(room_file_list)
  61. room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]])
  62. with open(spider_directory + '/spiders/config.yaml' , "r") as stream:
  63. try:
  64. config = yaml.safe_load(stream)
  65. except yaml.YAMLError as exc:
  66. print(exc)
  67. fdb_list = []
  68. #print(config)
  69. for key in config:
  70. fdb_list.append(key)
  71. start = False
  72. if int(current_hour) > 11:
  73. aftersix = True
  74. if int(current_hour) <= 11:
  75. aftersix = False
  76. already_updated = False
  77. if aftersix == True and already_updated == False and aftersix == False:
  78. room_list = []
  79. rooms = os.listdir('rooms')
  80. for room in rooms:
  81. room_file = open('rooms/' + room, 'r')
  82. room_file_raw = room_file.read()
  83. room_file.close()
  84. room_file_list = room_file_raw.split('§%§%')
  85. room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]])
  86. with open(spider_directory + '/spiders/config.yaml' , "r") as stream:
  87. try:
  88. config = yaml.safe_load(stream)
  89. except yaml.YAMLError as exc:
  90. print(exc)
  91. fdb_list = []
  92. #print(config)
  93. for key in config:
  94. fdb_list.append(key)
  95. data = dict({})
  96. for room in room_list:
  97. print(room[0])
  98. room_fdbs = room[2]
  99. room_tags = room[3]
  100. #subprocess.run(["python", spider_directory + 'main.py', fdbs])
  101. room_history_list = []
  102. try:
  103. room_history_file = open('roomhistories/' + room[0] + '.txt', 'x')
  104. room_history_file.close()
  105. except:
  106. print('reading from roomhistory')
  107. with open('roomhistories/' + room[0] + '.txt') as room_history_file:
  108. lines = room_history_file.readlines()
  109. for line in lines:
  110. room_history_list.append(line)
  111. #date = datetime.datetime.now() - timedelta(days=3)
  112. #room_history = api.get_room_history(room[0], oldest=date, latest=datetime.datetime.now())
  113. for room_fdb in eval(room_fdbs):
  114. #print('room_fdb',room_fdb, 'fdb_list',fdb_list)
  115. try:
  116. iteration_var_list = config.get(room_fdb).get("entry-list").get("iteration-var-list")
  117. except Exception as e:
  118. print('there was an error with the entry-list parameter in the config regarding the fdb ', room_fdb)
  119. if room_fdb in fdb_list and room_fdb not in [key for key in data]:
  120. iterdict = {}
  121. for i in eval(iteration_var_list):
  122. f = open(spider_directory + "/spiders/output/" + room_fdb + str(i) + "entryList.txt")
  123. text = f.read()
  124. dictionary_entry_list = eval(text)
  125. iterdict[i] = dictionary_entry_list
  126. data[room_fdb] = iterdict
  127. for i in eval(iteration_var_list):
  128. try:
  129. print(room_fdb, i)
  130. for key in data[room_fdb][i]:
  131. contains_tag = False
  132. period_data_formatted = dateutil.parser.parse(data[room_fdb][i][key]["period"])
  133. name_data_lower = [word.lower() for word in data[room_fdb][i][key]["name"].split(' ')]
  134. info_data_lower = [word.lower() for word in data[room_fdb][i][key]["info"].split(' ')]
  135. text_data_lower = [word.lower() for word in data[room_fdb][i][key]["text"].split(' ')]
  136. tag_list = []
  137. for tag in eval(room_tags):
  138. if '_' in tag:
  139. ntags = tag.split('_')
  140. ntags_length = len(ntags)
  141. ntag_count = 0
  142. for nword in name_data_lower:
  143. for ntag in ntags:
  144. if ntag.lower() in nword:
  145. ntag_count += 1
  146. if ntag_count == ntags_length:
  147. contains_tag = True
  148. tag_list.append(tag + ' in name')
  149. ntag_count = 0
  150. for iword in info_data_lower:
  151. for ntag in ntags:
  152. if ntag.lower() in iword:
  153. ntag_count += 1
  154. if ntag_count == ntags_length:
  155. contains_tag = True
  156. tag_list.append(tag + ' in info')
  157. ntag_count = 0
  158. for tword in text_data_lower:
  159. ntag_count = 0
  160. for ntag in ntags:
  161. if ntag.lower() in tword:
  162. ntag_count += 1
  163. if ntag_count == ntags_length:
  164. contains_tag = True
  165. tag_list.append(tag + ' in text')
  166. else:
  167. for nword in name_data_lower:
  168. if tag.lower() in nword:
  169. contains_tag = True
  170. tag_list.append(tag + ' in name')
  171. for iword in info_data_lower:
  172. if tag.lower() in iword:
  173. contains_tag = True
  174. tag_list.append(tag + ' in info')
  175. for tword in text_data_lower:
  176. if tag.lower() in tword:
  177. contains_tag = True
  178. tag_list.append(tag + ' in text')
  179. if contains_tag == True:
  180. try:
  181. url = data[room_fdb][i][key]["domain"]
  182. except:
  183. url = data[room_fdb][i][key]["link"]
  184. entry_message = '<' + url + '|' + data[room_fdb][i][key]["name"]+ '>' + '\n' + data[room_fdb][i][key]["info"] + '\n' + 'The period of the entry is:' + str(period_data_formatted) + '\n' + str(tag_list)
  185. entry_message_identifier = '<' + url + '|' + data[room_fdb][i][key]["name"]+ '>'
  186. message_was_already_there = False
  187. for message in room_history_list:
  188. print('message that gets checked with identifier ', message[:-1])
  189. print('the entry message identifier is:', entry_message_identifier)
  190. if url in message[:-1] or data[room_fdb][i][key]["name"] in message:
  191. message_was_already_there = True
  192. if message_was_already_there == False:
  193. print('went into already there false')
  194. api.send_message(entry_message, room[0])
  195. print('before writing')
  196. try:
  197. room_file = open('roomhistories/' + room[0] + '.txt', 'x')
  198. room_file.close()
  199. except:
  200. print('appending to roomhistory')
  201. room_file = open('roomhistories/' + room[0] + '.txt', 'a')
  202. room_file.write(entry_message_identifier + '\n')
  203. room_file.close()
  204. print('after writing')
  205. except Exception as e:
  206. print("probably i was not there in last page, original error is:", e)
  207. #print('data',data['giz'][2],'data')
  208. already_updated = True
  209. # if datestime.split over etc and updated= true etc
  210. n += 1
  211. if n%100 == 0:
  212. print(n)
  213. try:
  214. #print('getting the room history')
  215. date = datetime.datetime.now() - timedelta(days=3)
  216. room_history = api.get_private_room_history(room_id, oldest=date)
  217. except Exception as e:
  218. time.sleep(10)
  219. api = RocketChatAPI(settings={'username': botname, 'password': botpassword, 'domain': server_url})
  220. time.sleep(5)
  221. room_history = api.get_private_room_history(room_id, oldest=date)
  222. print('got a connection error, original message is:',e)
  223. messages_list = []
  224. for message in room_history['messages']:
  225. messages_list.append(message)
  226. if len(messages_list) >= 1:
  227. #print('blub', messages_list)
  228. latest_message_user_id = messages_list[0]['u']['_id']
  229. latest_message_user_username = messages_list[0]['u']['username']
  230. latest_message = messages_list[0]['msg']
  231. latest_message_id = messages_list[0]['_id']
  232. new_message_file = open('new_message_file.txt', 'r')
  233. new_message = new_message_file.read()
  234. new_message_file.close()
  235. new_message_list = new_message.split('§%§%')
  236. #print(latest_message, new_message_list[0])
  237. if new_message_list[0] != latest_message and new_message_list[1] != latest_message_id and latest_message_user_id != bot_user_id:
  238. answer = 'Ich habe kein Kommando erhalten.'
  239. new_message_file = open('new_message_file.txt', 'w')
  240. new_message_file.write(latest_message + '§%§%' + latest_message_id)
  241. new_message_file.close()
  242. user_input = latest_message
  243. user_input_list = user_input.split(' ')
  244. if user_input_list[0] == 'addtags':
  245. try:
  246. room_id_add_tags = user_input_list[1]
  247. except:
  248. room_id_add_tags = 'NONE'
  249. try:
  250. new_tags = user_input_list[2]
  251. except:
  252. new_tags = 'NONE'
  253. try:
  254. thirdarg = user_input_list[3]
  255. except:
  256. thirdarg = 'NONE'
  257. if len(room_id_add_tags) >= 1 and len(new_tags) >= 1 and thirdarg == 'NONE':
  258. try:
  259. room_file_add_tags = open('rooms/' + user_input_list[1] + '.txt', 'r')
  260. room_info_raw = room_file_add_tags.read()
  261. room_file_add_tags.close()
  262. room_info = room_info_raw.split('§%§%')
  263. tag_list = eval(room_info[-1])
  264. for tag in eval(user_input_list[2]):
  265. if tag not in tag_list:
  266. tag_list.append(tag)
  267. room_file_add_tags = open('rooms/' + user_input_list[1] + '.txt', 'w')
  268. room_file_add_tags.write( str(room_info[0]) + '§%§%' + str(room_info[1]) + '§%§%' + str(tag_list))
  269. room_file_add_tags.close()
  270. answer = 'the updated tag list is' + str(tag_list)
  271. except Exception as e:
  272. print('error opening, original error is:', e)
  273. answer = "The room_id to update the tags was not found"
  274. if user_input_list[0] == 'printtags':
  275. try:
  276. room_id_to_print_tags = user_input_list[1]
  277. except:
  278. answer = "after the command printtags, the second argument has to be the room id.. use printrooms and look up the id of the room you want to print the tags"
  279. room_id_to_print_tags = 'NONE'
  280. if room_id_to_print_tags != 'NONE':
  281. try:
  282. room_file = open('rooms/' + room_id_to_print_tags + '.txt', 'r')
  283. room_info_raw = room_file.read()
  284. room_file.close()
  285. room_info = room_info_raw.split('§%§%')
  286. tag_list = eval(room_info[-1])
  287. answer = tag_list
  288. except Exception as e:
  289. print('error opening, original error is:', e)
  290. answer = "The room_id to get the tags was not found"
  291. if user_input_list[0] == 'printcommands':
  292. answer = """
  293. To print all available rooms and their configuration, use
  294. command : `printrooms`
  295. -----------------------------------------------------------------------------------------
  296. To print all available fdbs, use
  297. command : `printfdbs`
  298. -----------------------------------------------------------------------------------------
  299. To update all rooms use
  300. command : `updaterooms`
  301. -----------------------------------------------------------------------------------------
  302. To update one room use the room_id from the output of printrooms:
  303. command : `updaterooms <room-id>`
  304. example : `updaterooms 6572012bebb39dd248d08320`
  305. -----------------------------------------------------------------------------------------
  306. To create a room use following command, but be sure to **not have spaces** in your lists,
  307. as a space indicates a new command argument:
  308. command : `createroom <room-name> <list-fdbs> <list-tags>`
  309. example : `createroom room-test-1 ['giz','fdb2'] ['tag1','tag2','tag3']`
  310. -----------------------------------------------------------------------------------------
  311. To delete a room use
  312. command : `deleteroom <room-id>`
  313. example : `deleteroom 6572012bebb39dd248d08320`
  314. -----------------------------------------------------------------------------------------
  315. To print the tags of a room use
  316. command : `printtags <room-id>`
  317. example : `printtags 6572012bebb39dd248d08320`
  318. -----------------------------------------------------------------------------------------
  319. To add tags to the existing tags use
  320. command : `addtags <room-id> <tag-list-without-spaces>`
  321. example : `addtags 6572012bebb39dd248d08320 ['tag1','tag2','tag3']`
  322. """
  323. if user_input_list[0] == 'printrooms':
  324. room_was_found = False
  325. # get all the rooms
  326. import os
  327. room_list = []
  328. rooms = os.listdir('rooms')
  329. for room in rooms:
  330. room_file = open('rooms/' + room, 'r')
  331. room_file_raw = room_file.read()
  332. room_file.close()
  333. room_file_list = room_file_raw.split('§%§%')
  334. room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]])
  335. room_list_string = ''
  336. for room in room_list:
  337. room_list_string += str(room) + '\n' + '------------------------------------------------------------------------------' + '\n'
  338. #print(room_list)
  339. answer = room_list_string
  340. if user_input_list[0] == 'updaterooms':
  341. try:
  342. if len(user_input_list[1]) >= 1:
  343. room_to_update = user_input_list[1]
  344. except Exception as e:
  345. room_to_update = 'NONE'
  346. room_list = []
  347. rooms = os.listdir('rooms')
  348. for room in rooms:
  349. room_file = open('rooms/' + room, 'r')
  350. room_file_raw = room_file.read()
  351. room_file.close()
  352. room_file_list = room_file_raw.split('§%§%')
  353. room_list.append([room[:-4], room_file_list[0], room_file_list[1], room_file_list[2]])
  354. with open(spider_directory + '/spiders/config.yaml' , "r") as stream:
  355. try:
  356. config = yaml.safe_load(stream)
  357. except yaml.YAMLError as exc:
  358. print(exc)
  359. fdb_list = []
  360. #print(config)
  361. for key in config:
  362. fdb_list.append(key)
  363. answer = "Ich update die Rooms auf Basis der Daten von heute morgen um 6 Uhr.."
  364. data = dict({})
  365. for room in room_list:
  366. if room[0] == room_to_update or room_to_update == 'NONE':
  367. room_was_found = True
  368. print(room[0])
  369. room_fdbs = room[2]
  370. room_tags = room[3]
  371. # not running get_rooms because disfunctional
  372. #subprocess.run(["python", spider_directory + 'main.py', fdbs])
  373. #myinfo = api.get_room_info(room[0])
  374. #print(myinfo)
  375. #roomid = "'657cbeccebb39dd248d38ec3'"
  376. #roomoioioi = api.get_user_info(bot_user_id)
  377. #print(roomoioioi)
  378. #room_history_updateroom = api.get_private_room_history(room[0])
  379. # reading from txt state history instead
  380. try:
  381. room_history_file = open('roomhistories/' + room[0] + '.txt', 'x')
  382. room_history_file.close()
  383. except:
  384. print('reading from roomhistory which is already there')
  385. room_history_list = []
  386. with open('roomhistories/' + room[0] + '.txt') as room_history_file:
  387. lines = room_history_file.readlines()
  388. for line in lines:
  389. room_history_list.append(line)
  390. #
  391. #for message in room_history_raw:
  392. # print(message)
  393. for room_fdb in eval(room_fdbs):
  394. #print('room_fdb',room_fdb, 'fdb_list',fdb_list)
  395. try:
  396. iteration_var_list = config.get(room_fdb).get("entry-list").get("iteration-var-list")
  397. except Exception as e:
  398. print('there was an error with the entry-list parameter in the config regarding the fdb ', room_fdb)
  399. if room_fdb in fdb_list and room_fdb not in [key for key in data]:
  400. iterdict = {}
  401. for i in eval(iteration_var_list):
  402. f = open(spider_directory + "/spiders/output/" + room_fdb + str(i) + "entryList.txt")
  403. text = f.read()
  404. dictionary_entry_list = eval(text)
  405. iterdict[i] = dictionary_entry_list
  406. data[room_fdb] = iterdict
  407. for i in eval(iteration_var_list):
  408. try:
  409. print(room_fdb, i)
  410. for key in data[room_fdb][i]:
  411. contains_tag = False
  412. period_data_formatted = dateutil.parser.parse(data[room_fdb][i][key]["period"])
  413. name_data_lower = [word.lower() for word in data[room_fdb][i][key]["name"].split(' ')]
  414. info_data_lower = [word.lower() for word in data[room_fdb][i][key]["info"].split(' ')]
  415. text_data_lower = [word.lower() for word in data[room_fdb][i][key]["text"].split(' ')]
  416. tag_list = []
  417. for tag in eval(room_tags):
  418. if '_' in tag:
  419. ntags = tag.split('_')
  420. ntags_length = len(ntags)
  421. print(ntags)
  422. ntag_count = 0
  423. for ntag in ntags:
  424. print('searching for ntag: ', ntag)
  425. for nword in name_data_lower:
  426. if ntag.lower() in nword:
  427. if nword != '':
  428. ntag_count += 1
  429. print(ntag, ' ntag was found')
  430. break
  431. print('ntag count is ', ntag_count, 'ntag_length is ', ntags_length)
  432. if ntag_count == ntags_length:
  433. contains_tag = True
  434. tag_list.append('_'.join(ntags) + ' in name')
  435. ntag_count = 0
  436. for ntag in ntags:
  437. for iword in info_data_lower:
  438. if ntag.lower() in iword:
  439. if iword != '':
  440. ntag_count += 1
  441. break
  442. if ntag_count == ntags_length:
  443. contains_tag = True
  444. tag_list.append('_'.join(ntags) + ' in info')
  445. ntag_count = 0
  446. for ntag in ntags:
  447. for tword in text_data_lower:
  448. if ntag.lower() in tword:
  449. if tword != '':
  450. ntag_count += 1
  451. break
  452. if ntag_count == ntags_length:
  453. contains_tag = True
  454. tag_list.append('_'.join(ntags) + ' in text')
  455. else:
  456. #print('------------------')
  457. print(name_data_lower, info_data_lower, text_data_lower, room[0], room_tags)
  458. nword_contains_tag = False
  459. for nword in name_data_lower:
  460. print(tag.lower(), nword)
  461. if tag.lower() in nword:
  462. print('goooot heeeere')
  463. print(nword)
  464. if nword != '':
  465. print('goot behind nword check')
  466. nword_contains_tag = True
  467. if nword_contains_tag == True:
  468. contains_tag = True
  469. tag_list.append(tag + ' in name')
  470. iword_contains_tag = False
  471. for iword in info_data_lower:
  472. if tag.lower() in iword:
  473. if iword != '':
  474. iword_contains_tag = True
  475. print('oioiOIOIOIoioioiOIOIword', iword)
  476. if iword_contains_tag == True:
  477. contains_tag = True
  478. tag_list.append(tag + ' in info')
  479. tword_contains_tag = False
  480. for tword in text_data_lower:
  481. if tag.lower() in tword:
  482. if tword != '':
  483. tword_contains_tag = True
  484. if tword_contains_tag == True:
  485. contains_tag = True
  486. tag_list.append(tag + ' in text')
  487. if contains_tag == True:
  488. #print('------------------')
  489. #print(name_data_lower, info_data_lower, text_data_lower)
  490. try:
  491. url = data[room_fdb][i][key]["domain"]
  492. except:
  493. url = data[room_fdb][i][key]["link"]
  494. print('101110001101010010010101000111')
  495. entry_message = '<' + url + '|' + data[room_fdb][i][key]["name"]+ '>' + '\n' + data[room_fdb][i][key]["info"] + '\n' + 'The period of the entry is:' + str(period_data_formatted) + '\n' + str(tag_list)
  496. entry_message_identifier = '<' + url + '|' + data[room_fdb][i][key]["name"]+ '>'
  497. message_was_already_there = False
  498. for message in room_history_list:
  499. print('message', message[:-1], 'identifier', entry_message_identifier)
  500. if url in message[:-1] or data[room_fdb][i][key]["name"] in message:
  501. message_was_already_there = True
  502. if message_was_already_there == False:
  503. api.send_message(entry_message, room[0])
  504. try:
  505. room_file = open('roomhistories/' + room[0] + '.txt', 'x')
  506. room_file.close()
  507. except:
  508. print('appending to roomhistory')
  509. room_file = open('roomhistories/' + room[0] + '.txt', 'a')
  510. room_file.write(entry_message_identifier + '\n')
  511. room_file.close()
  512. except Exception as e:
  513. print("probably i was not there in last page, original error is:", e)
  514. if room_to_update == 'NONE':
  515. answer = 'No room was specified, all rooms will get an update based on the data available'
  516. if room_was_found == False and room_to_update != 'NONE':
  517. answer = 'The room you specified does not exist, or there are no rooms configured, try the command without argument -> updaterooms'
  518. if room_was_found == True and room_to_update != 'NONE':
  519. answer = "I am updating the specified room based on the data in fdb-spider/spiders/output.."
  520. if user_input_list[0] == 'printfdbs':
  521. answer = str(fdb_list)
  522. if len(user_input_list) > 1:
  523. answer = 'Die Syntax zum Ausgeben der konfigurierten Förderdatenbanken hat einen Fehler. Versuche es erneut, mit -> printfdbs'
  524. if user_input_list[0] == 'deleteroom':
  525. try:
  526. room_id_del = user_input_list[1]
  527. except Exception as e:
  528. room_id_del = 'NONE'
  529. print(e)
  530. os.remove("rooms/" + room_id_del + ".txt")
  531. anwer = 'deleting the requested room..'
  532. if len(user_input_list) > 2:
  533. answer = 'Die Syntax zum Löschen eines Raumes hat einen Fehler. Versuche es erneut, nach dem Muster -> deleteroom <room_id>'
  534. if user_input_list[0] == 'createroom':
  535. try:
  536. room_name = user_input_list[1]
  537. except Exception as e:
  538. room_name = 'NONE'
  539. print(e)
  540. try:
  541. databases = user_input_list[2]
  542. except Exception as e:
  543. databases = 'NONE'
  544. print(e)
  545. try:
  546. filters = user_input_list[3]
  547. except Exception as e:
  548. filters = 'NONE'
  549. print(e)
  550. if len(user_input_list) > 3:
  551. 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"]'
  552. if room_name == 'NONE' or databases == 'NONE' or filters == 'NONE':
  553. answer = 'Um einen Raum zu erstellen, in dem neueste Einträge geteilt werden, lautet die Syntax: createroom <Raumname> <Liste-Datenbanken> <Liste-Filtertags>'
  554. else:
  555. try:
  556. new_room = api.create_public_room(room_name,
  557. members=[latest_message_user_username],
  558. read_only=False)
  559. new_room_id = new_room['channel']['_id']
  560. room_file = open('rooms/' + new_room_id + '.txt', 'w')
  561. room_file.write( room_name + '§%§%' + databases + '§%§%' + filters)
  562. room_file.close()
  563. answer = 'Der Command wurde übermittelt'
  564. except Exception as e:
  565. print('it was not able to create the room, the original error message is:', e)
  566. answer = 'There was an error creating the room, look up the logs.. the original error was: ' + str(e)
  567. #print('oi', user_input)
  568. api.send_message('Die Anfrage wird bearbeitet..', room_id)
  569. # here comes the code interacting with the spiders output json
  570. #answer = 'the up to date entries are: oi Oi Oi!'
  571. api.send_message(answer, room_id)
  572. time.sleep(1)
  573. api.send_message('Ich bin wieder bereit für Konfigurationsinput : )', room_id)
  574. time.sleep(1)