added room commands, started room communication scheduler
This commit is contained in:
parent
3c71a07f6c
commit
3e30365c90
4 changed files with 35 additions and 11 deletions
BIN
.fdb_spider_interface.py.swp
Normal file
BIN
.fdb_spider_interface.py.swp
Normal file
Binary file not shown.
|
@ -5,13 +5,14 @@ import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('/root/fdb-spider-interface/config.ini')
|
config.read('config.ini')
|
||||||
|
|
||||||
botname = config['Chat']['username']
|
botname = config['Chat']['username']
|
||||||
botpassword = config['Chat']['password']
|
botpassword = config['Chat']['password']
|
||||||
server_url = config['Chat']['URL']
|
server_url = config['Chat']['URL']
|
||||||
room_id = config['Chat']['room_id']
|
room_id = config['Chat']['room_id']
|
||||||
bot_user_id = config['Chat']['bot_user_id']
|
bot_user_id = config['Chat']['bot_user_id']
|
||||||
|
spider_directory = config['Spider']['spider_directory']
|
||||||
|
|
||||||
# here comes the functions to talk to gpt
|
# here comes the functions to talk to gpt
|
||||||
|
|
||||||
|
@ -47,15 +48,10 @@ if __name__ == '__main__':
|
||||||
n = 0
|
n = 0
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import datetime
|
import schedule
|
||||||
from datetime import timedelta
|
|
||||||
while True:
|
|
||||||
time.sleep(4)
|
|
||||||
|
|
||||||
|
def getroomdata():
|
||||||
|
|
||||||
# get all the rooms
|
|
||||||
import os
|
|
||||||
|
|
||||||
room_list = []
|
room_list = []
|
||||||
rooms = os.listdir('rooms')
|
rooms = os.listdir('rooms')
|
||||||
for room in rooms:
|
for room in rooms:
|
||||||
|
@ -65,9 +61,19 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
room_file_list = room_file_raw.split('§%§%')
|
room_file_list = room_file_raw.split('§%§%')
|
||||||
room_list.append([room[:-3], room_file_list[0], room_file_list[1], room_file_list[2]])
|
room_list.append([room[:-3], room_file_list[0], room_file_list[1], room_file_list[2]])
|
||||||
|
|
||||||
|
return room_list
|
||||||
|
|
||||||
#print(room_list)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from datetime import timedelta
|
||||||
|
while True:
|
||||||
|
time.sleep(4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
n += 1
|
n += 1
|
||||||
print(n)
|
print(n)
|
||||||
|
@ -126,6 +132,20 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
if user_input_list[0] == 'printrooms':
|
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)
|
answer = str(room_list)
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,7 +177,7 @@ if __name__ == '__main__':
|
||||||
members=[latest_message_user_username],
|
members=[latest_message_user_username],
|
||||||
read_only=True)
|
read_only=True)
|
||||||
|
|
||||||
# The logic here is that a new room with the same name gets overwritten
|
|
||||||
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)
|
||||||
|
@ -170,6 +190,9 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# here comes the code interacting with the spiders output json
|
# here comes the code interacting with the spiders output json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#answer = 'the up to date entries are: oi Oi Oi!'
|
#answer = 'the up to date entries are: oi Oi Oi!'
|
||||||
|
|
||||||
api.send_message(answer, room_id)
|
api.send_message(answer, room_id)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
printrooms§%§%6DQP8M4wYhgWroAx7
|
printrooms§%§%P6rQGgS9u7RqZM2iz
|
|
@ -3,4 +3,5 @@ charset-normalizer==3.2.0
|
||||||
idna==3.4
|
idna==3.4
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
rocket-python==1.3.4
|
rocket-python==1.3.4
|
||||||
|
schedule==1.2.1
|
||||||
urllib3==2.0.4
|
urllib3==2.0.4
|
||||||
|
|
Loading…
Reference in a new issue