Skip to content

Commit

Permalink
cqhttp update
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Feb 7, 2021
1 parent 0f338af commit fcd9be1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions ChatBridge_cqhttp.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# -*- coding: UTF-8 -*-
import html
import os
import json
import os
import threading
import time
import traceback
from typing import Optional

import ChatBridge_client
import websocket
from ChatBridgeLibrary import ChatBridge_lib as lib

import ChatBridge_client
from ChatBridgeLibrary import ChatBridge_utils as utils

CQHttpConfigFile = 'ChatBridge_CQHttp.json'
ClientConfigFile = 'ChatBridge_client.json'
LogFile = 'ChatBridge_CQHttp.log'
cq_bot = None
chatClient = None
chatClient = None # type: Optional[ChatClient]

CQHelpMessage = '''
!!help: 显示本条帮助信息
Expand Down Expand Up @@ -87,7 +88,7 @@ def on_message(self, message):

if len(args) == 1 and args[0] == '!!ping':
log('!!ping command triggered')
self.send_text('pong!')
self.send_text('pong!!')

if len(args) >= 2 and args[0] == '!!mc':
log('!!mc command triggered')
Expand Down Expand Up @@ -172,8 +173,8 @@ def on_recieve_message(self, data):
except:
pass
else:
log('Triggered command, sending message to qq')
if prefix == '!!qq':
log('Triggered command, sending message to qq')
cq_bot.send_message(data['client'], data['player'], message)
except:
self.log('Error in on_message()')
Expand Down Expand Up @@ -214,6 +215,8 @@ def ChatBridge_guardian():
except (KeyboardInterrupt, SystemExit):
chatClient.stop()
exit(1)
except:
traceback.print_exc()


if __name__ == '__main__':
Expand All @@ -226,6 +229,7 @@ def ChatBridge_guardian():
thread = threading.Thread(target=ChatBridge_guardian, args=())
thread.setDaemon(True)
thread.start()
print('Starting CQ Bot')
cq_bot = CQBot(CQHttpConfigFile)
cq_bot.start()
print('Bye~')
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ MyFolder

### Client as a CooqHttp client

:ghost: CoolQ is down so rip

**python3 only**

Needs [coolq-http-api](https://github.com/richardchien/coolq-http-api) server running
~~Needs [coolq-http-api](https://github.com/richardchien/coolq-http-api) server running~~ (:ghost: it's down)

Needs any CoolQ Http protocol provider to work. e.g. [go-cqhttp](https://github.com/Mrs4s/go-cqhttp)

`pip install websocket websocket-client` first

Expand Down

0 comments on commit fcd9be1

Please sign in to comment.