Add weixin support and adapt to mojo-webqq 2.0

This commit is contained in:
Richard Chien
2016-12-29 23:45:34 +08:00
parent c2433aef13
commit 0af4a3dbdc
13 changed files with 240 additions and 54 deletions

View File

@ -8,7 +8,6 @@ from filter import add_filter
from command import CommandNotExistsError, CommandScopeError, CommandPermissionError
from little_shit import *
from commands import core
from apiclient import client as api
from command import hub as cmdhub
_fallback_command = config.get('fallback_command')
@ -40,14 +39,11 @@ def _dispatch_command(ctx_msg):
raise SkipException
at_me = '@' + my_group_nick
if not content.startswith(at_me):
my_nick = api.get_user_info().json().get('nick', my_group_nick)
at_me = '@' + my_nick
if not content.startswith(at_me):
raise SkipException
raise SkipException
content = content[len(at_me):]
else:
# Not starts with '@'
if ctx_msg.get('type') == 'group_message':
if ctx_msg.get('type') == 'group_message' or ctx_msg.get('type') == 'discuss_message':
# And it's a group message, so we don't reply
raise SkipException
content = content.lstrip()

View File

@ -4,6 +4,7 @@ from filter import add_filter
def _log_message(ctx_msg):
print(ctx_msg.get('sender', '')
+ (('@' + ctx_msg.get('group')) if ctx_msg.get('type') == 'group_message' else '')
+ (('@' + ctx_msg.get('discuss')) if ctx_msg.get('type') == 'discuss_message' else '')
+ ': ' + ctx_msg.get('content'))