Example #1
0
def cmdHelp(context):
    str = "以下是目前所有的命令:\n\n"
    for help in cmdHelpers:
        str += "┌─[{0}] {1}\n".format(help.cmd, help.desc)
        str += "├─中文指令:{0}\n".format(help.cmdCN)
        str += "└─使用方法:{0}\n".format(help.etc)
    send(context, str)
Example #2
0
def downloadLink(context):
    CONTENT = context.content.upper()
    if any(k in CONTENT for k in ['AS','ANDROID STUDIO']):
        send(context, 'Android Studio官方下载地址:https://developer.android.google.cn/studio/')
    elif 'GRADLE' in CONTENT:
        send(context, 'Gradle下载地址:https://gradle.org/install/')
    elif 'JDK10' in CONTENT:
        send(context, 'JDK-10下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html')
    elif 'JDK8' in CONTENT:
        send(context, 'JDK-8下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html')
    elif any(k in CONTENT for k in ['JAVA','JDK']):
        send(context, 'JDK下载地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html')
Example #3
0
def toolProcess(context):
    txt = context.content.replace('[@ME]', '')
    cmd = getToolCMD(txt)
    if cmd == None:
        send(
            context,
            '解析错误,请以【@QQBot tool cmd】或者【@QQBot 工具 命令】格式发送。发送【@QQBot tool help】查询所有命令'
        )
        return
    for helper in cmdHelpers:
        if any(k in cmd for k in [helper.cmd, helper.cmdCN]):
            helper.method(context, cmd)
            return
    if any(k in cmd for k in ['help', '帮助']):
        cmdHelp(context)
    else:
        send(context, '未知命令,发送【@QQBot tool help】查询所有命令')
Example #4
0
def onQQMessage(bot, contact, member, content):
    context = Context(bot, contact, member, content)
    # 当收到 QQ 消息时被调用
    # bot     : QQBot 对象,提供 List/SendTo/GroupXXX/Stop/Restart 等接口,详见文档第五节
    # contact : QContact 对象,消息的发送者
    # member  : QContact 对象,仅当本消息为 群或讨论组 消息时有效,代表实际发消息的成员
    # content : str 对象,消息内容
    if bot.isMe(contact, member) == False:
        CONTENT = content.upper()
        if contact.ctype == 'group':
            if '下载' in content:
                downloadLink(context)
            elif any(k in CONTENT for k in ['文档', 'API', 'DOCUMENT']):
                documentLink(context)
            elif any(k in CONTENT for k in ['教程', '基础', '学习', 'GUIDE', '指南']):
                learnLink(context)
        if '@ME' in content:
            if any(k in CONTENT for k in ['TOOL', '工具']):
                toolProcess(context)
            else:
                send(context, member.name + choice(LongText.aStupidGuyAtMe))
Example #5
0
def cmdNslookup(context, cmd):
    help = cmdHelpers[0]
    p = re.compile("^\s*[{0}|{1}]+\s*(\S.*)$".format(help.cmd, help.cmdCN))
    m = p.match(cmd)
    if cmdIsInvalid(cmd):
        send(context, "包含非法字符")
        return
    if m == None or len(m[1]) <= 1:  #不要问我这里为什么会等于1,鬼知道
        send(context, '参数错误。{0}'.format(help.etc))
    else:
        send(context, subprocess.getoutput(help.cmd + ' ' + m[1]))
Example #6
0
def learnLink(context):
    CONTENT = context.content.upper()
    if 'JAVA' in CONTENT:
        send(context, LongText.learnJava)
    elif any(k in CONTENT for k in ['ANDROID', '安卓']):
        send(context, LongText.learnAndroid)
Example #7
0
def documentLink(context):
    CONTENT = context.content.upper()
    if any(k in CONTENT for k in ['JAVA', 'JDK']) and '7' not in CONTENT:
        send(
            context,
            '这有一份OpenJDK 8的文档链接,请保存书签:https://docs.oracle.com/javase/8/docs/api/。如果想要jdk7的文档请回复“请皇上赐我一份JDK7的文档”。'
        )
    elif 'JDK7' in CONTENT:
        send(
            context,
            '这有一份OpenJDK 7的文档链接,请保存书签:https://docs.oracle.com/javase/7/docs/api/'
        )
    elif any(k in CONTENT
             for k in ['ANDROID', '安卓']) and 'STUDIO' not in CONTENT:
        send(
            context,
            '这里有一份Android的文档链接,请保存书签:https://developer.android.google.cn/reference/'
        )
    elif any(k in CONTENT for k in ['ANDROID STUDIO', 'AS', '安卓死丢丢']):
        send(
            context,
            '这里有一份Android Studio的文档链接,请保存书签:https://developer.android.google.cn/studio/intro/'
        )
    elif 'OKHTTP' in CONTENT:
        send(context, '这里有一份OKHttp的文档链接,请保存书签:http://square.github.io/okhttp/')
    elif 'RETROFIT' in CONTENT:
        send(context,
             '这里有一份Retrofit的文档链接,请保存书签:http://square.github.io/retrofit/')