2023-03-05 14:07:25 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import json
|
|
|
|
import asyncio
|
|
|
|
from bot import Bot
|
|
|
|
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
fp = open('config.json', 'r')
|
|
|
|
config = json.load(fp)
|
|
|
|
matrix_bot = Bot(homeserver=config['homeserver'],
|
|
|
|
user_id=config['user_id'],
|
2023-03-14 14:37:30 +00:00
|
|
|
password=config.get('password', ''), # provide a default value when the key does not exist
|
2023-03-05 14:07:25 +00:00
|
|
|
device_id=config['device_id'],
|
2023-03-14 14:37:30 +00:00
|
|
|
room_id=config.get('room_id', ''),
|
2023-03-10 00:29:12 +00:00
|
|
|
api_key=config.get('api_key', ''),
|
2023-03-10 15:45:38 +00:00
|
|
|
bing_api_endpoint=config.get('bing_api_endpoint', ''),
|
2023-03-17 23:20:55 +00:00
|
|
|
access_token=config.get('access_token', ''),
|
|
|
|
jailbreakEnabled=config.get('jailbreakEnabled', False),
|
2023-03-22 14:28:22 +00:00
|
|
|
bing_auth_cookie=config.get('bing_auth_cookie', ''),
|
2023-03-10 00:29:12 +00:00
|
|
|
)
|
2023-03-12 15:24:05 +00:00
|
|
|
if config.get('access_token', '') == '':
|
|
|
|
await matrix_bot.login()
|
2023-03-05 14:07:25 +00:00
|
|
|
await matrix_bot.sync_forever()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-03-10 13:43:18 +00:00
|
|
|
print("matrix chatgpt bot start.....")
|
2023-03-05 14:07:25 +00:00
|
|
|
try:
|
2023-03-09 16:21:12 +00:00
|
|
|
loop = asyncio.get_running_loop()
|
|
|
|
except RuntimeError:
|
|
|
|
loop = asyncio.new_event_loop()
|
|
|
|
asyncio.set_event_loop(loop)
|
|
|
|
asyncio.run(main())
|