Esempio n. 1
0
async def delalltest(session: CommandSession):
    if not headdeal(session):
        return
    await asyncio.sleep(0.2)
    message_type = session.event['message_type']
    group_id = (session.event['group_id'] if message_type == 'group' else None)
    user_id = session.event['user_id']
    if perm_check(session, '-listener', user=True):
        await session.send('操作被拒绝,权限不足(p)')
        return
    sent_id = 0
    if message_type == 'private':
        sent_id = user_id
    elif message_type == 'group':
        if not perm_check(session, 'listener'):
            await session.send('操作被拒绝,权限不足(g)')
            return
        sent_id = group_id
    else:
        await session.send('未收录的消息类型:' + message_type)
        return
    logger.info(CQsessionToStr(session))
    sent_id = str(sent_id)
    res = push_list.delPushunitFromPushTo(message_type,
                                          int(sent_id),
                                          self_id=int(
                                              session.event['self_id']))
    push_list.savePushList()
    await session.send('已移除此地所有监测' if res[0] == True else res[1])
Esempio n. 2
0
async def globalRemove(session: CommandSession):
    await asyncio.sleep(0.2)
    stripped_arg = session.current_arg_text.strip().lower()
    if stripped_arg == '':
        await session.send("缺少参数")
        return
    cs = commandHeadtail(stripped_arg)
    cs = {'messagetype': cs[0], 'pushto': cs[2].strip()}
    if cs['pushto'] == '' or cs['messagetype'] == '':
        await session.send("缺少参数")
        return
    if not cs['pushto'].isdecimal():
        await session.send("Q号或群号不合法:" + cs['pushto'])
        return
    messagetype_list = {
        '私聊': 'private',
        'private': 'private',
        '群聊': 'group',
        'group': 'group',
        '好友': 'private',
        '群': 'group',
    }
    if cs['messagetype'] in messagetype_list:
        res = push_list.delPushunitFromPushTo(
            messagetype_list[cs['messagetype']],
            int(cs['pushto']),
            self_id=int(session.event['self_id']))
        push_list.savePushList()
        logger.info(CQsessionToStr(session))
        await session.send(res[1])
    else:
        await session.send("此消息类型不支持:" + cs['messagetype'])
        return
Esempio n. 3
0
async def delOne(session: CommandSession):
    stripped_arg = session.current_arg_text.strip()
    if stripped_arg == '':
        await session.send("缺少参数")
        return
    if stripped_arg == re.match('[A-Za-z0-9_]+', stripped_arg, flags=0):
        await session.send("用户名/用户ID 只能包含字母、数字或下划线")
        return
    try:
        if stripped_arg.isdecimal():
            userinfo = tweetListener.api.get_user(user_id=int(stripped_arg))
        else:
            userinfo = tweetListener.api.get_user(screen_name=stripped_arg)
    except TweepError:
        s = traceback.format_exc(limit=5)
        logger.error('tweepy错误:' + s)
        await session.send("查询不到信息,bksn")
        return

    tweetListener.tweet_event_deal.seve_image(userinfo.screen_name,
                                              userinfo.profile_image_url_https,
                                              'userinfo')
    file_suffix = os.path.splitext(userinfo.profile_image_url_https)[1]
    res = push_list.delPushunitFromPushToAndTweetUserID(
        session.event['message_type'],
        session.event[('group_id' if session.event['message_type'] == 'group'
                       else 'user_id')], userinfo.id)
    s = '用户UID:'+ str(userinfo.id) + "\n" + \
        '用户ID:' + userinfo.screen_name + "\n" + \
        '用户昵称:' + userinfo.name + "\n" + \
        '头像:' + '[CQ:image,timeout='+config.img_time_out+',file='+config.img_path+'userinfo/' + userinfo.screen_name + file_suffix + ']'+ "\n" + \
        ('此用户已移出监听列表' if res[0] == True else '移除失败:'+res[1])
    push_list.savePushList()
    logger.info(CQsessionToStr(session))
    await session.send(s)
Esempio n. 4
0
async def group_increase_leave_me(session: NoticeSession):
    await asyncio.sleep(0.3)
    if session.event['sub_type'] == 'kick_me' or int(
            session.event['self_id']) == int(session.event['user_id']):
        push_list.delPushunitFromPushTo("group",
                                        int(session.event['group_id']),
                                        self_id=int(session.event['self_id']))
        push_list.savePushList()
        msgSendToBot(
            logger,
            '已被移出或退出 ' + str(session.event['group_id']) + ' 群组,相关侦听已移除')
Esempio n. 5
0
async def addOne(session: CommandSession):
    stripped_arg = session.current_arg_text.strip()
    if stripped_arg == '':
        await session.send("缺少参数")
        return
    if stripped_arg == re.match('[A-Za-z0-9_]+', stripped_arg, flags=0):
        await session.send("用户名/用户ID 只能包含字母、数字或下划线")
        return
    cs = commandHeadtail(stripped_arg)
    try:
        if cs[0].isdecimal():
            userinfo = tweetListener.api.get_user(user_id=int(cs[0]))
        else:
            userinfo = tweetListener.api.get_user(screen_name=cs[0])
    except TweepError:
        s = traceback.format_exc(limit=5)
        logger.error('tweepy错误:' + s)
        await session.send("查询不到信息,你D都能D歪来")
        return
    tweetListener.tweet_event_deal.seve_image(userinfo.screen_name,
                                              userinfo.profile_image_url_https,
                                              'userinfo')
    file_suffix = os.path.splitext(userinfo.profile_image_url_https)[1]
    nick = ''
    des = ''
    if cs[2] != '':
        cs = commandHeadtail(cs[2])
        nick = cs[0]
        des = cs[2]
    if des == '':
        des = userinfo.name + '(' + userinfo.screen_name + ')'
    PushUnit = push_list.baleToPushUnit(
        session.event['self_id'],
        session.event['message_type'],
        session.event[('group_id' if session.event['message_type'] == 'group'
                       else 'user_id')],
        userinfo.id,
        des,
        nick=nick)
    res = push_list.addPushunit(PushUnit)
    s = '用户UID:'+ str(userinfo.id) + "\n" + \
        '用户ID:' + userinfo.screen_name + "\n" + \
        '用户昵称:' + userinfo.name + "\n" + \
        '头像:' + '[CQ:image,timeout='+config.img_time_out+',file='+config.img_path+'userinfo/' + userinfo.screen_name + file_suffix + ']'+ "\n" + \
        ('此用户已添加至监听列表' if res[0] == True else '添加失败:'+res[1])
    push_list.savePushList()
    logger.info(CQsessionToStr(session))
    await session.send(s)
Esempio n. 6
0
async def delOne(session: CommandSession):
    if not headdeal(session):
        return
    message_type = session.event['message_type']
    #group_id = (session.event['group_id'] if message_type == 'group' else None)
    #user_id = session.event['user_id']
    if perm_check(session, '-listener', user=True):
        await session.send('操作被拒绝,权限不足(p)')
        return
    if message_type == 'group':
        if not perm_check(session, 'listener'):
            await session.send('操作被拒绝,权限不足(g)')
            return
    else:
        await session.send('未收录的消息类型:' + message_type)
        return
    logger.info(CQsessionToStr(session))

    stripped_arg = session.current_arg_text.strip()
    if stripped_arg == '':
        await session.send("在?为什么看别的女人连单推的名字都忘了写?")
        return
    if re.match('[A-Za-z0-9_]+$', stripped_arg, flags=0) == None:
        await session.send("用户名/用户ID 只能包含字母、数字或下划线")
        return
    #获取数据
    res = tweetListener.tweet_event_deal.getUserInfo(stripped_arg)
    if not res[0]:
        await session.send("查询不到信息,不愧是你(๑´ㅂ`๑)")
        return
    userinfo = res[1]
    res = push_list.delPushunitFromPushToAndTweetUserID(
        message_type,
        session.event[('group_id' if session.event['message_type'] == 'group'
                       else 'user_id')], userinfo['id'])
    s = '标识:'+ str(userinfo['id']) + "\n" + \
        '用户ID:' + userinfo['screen_name'] + "\n" + \
        '用户昵称:' + userinfo['name'] + "\n" + \
        '头像:' + '[CQ:image,timeout='+config.img_time_out+',file=' + userinfo['profile_image_url_https'] + ']'+ "\n" + \
        ('已经从监听列表中叉出去了哦' if res[0] == True else '移除失败了Σ(゚д゚lll):'+res[1])
    push_list.savePushList()
    logger.info(CQsessionToStr(session))
    await session.send(s)
Esempio n. 7
0
async def delalltest(session: CommandSession):
    await asyncio.sleep(0.2)
    message_type = session.event['message_type']
    sent_id = 0
    if message_type == 'private':
        sent_id = session.event['user_id']
    elif message_type == 'group':
        sent_id = session.event['group_id']
    else:
        await session.send('未收录的消息类型:' + message_type)
        return
    sent_id = str(sent_id)
    res = push_list.delPushunitFromPushTo(message_type,
                                          int(sent_id),
                                          self_id=int(
                                              session.event['self_id']))
    push_list.savePushList()
    logger.info(CQsessionToStr(session))
    await session.send('已移除此地所有监测' if res[0] == True else res[1])
Esempio n. 8
0
async def addOne(session: CommandSession):
    if not headdeal(session):
        return
    message_type = session.event['message_type']
    group_id = (session.event['group_id'] if message_type == 'group' else None)
    user_id = session.event['user_id']
    if perm_check(session, '-listener', user=True):
        await session.send('操作被拒绝,权限不足(p)')
        return
    sent_id = 0
    if message_type == 'private':
        sent_id = user_id
    elif message_type == 'group':
        if not perm_check(session, 'listener'):
            await session.send('操作被拒绝,权限不足(g)')
            return
        sent_id = group_id
    else:
        await session.send('未收录的消息类型:' + message_type)
        return
    logger.info(CQsessionToStr(session))

    arglimit = [
        {
            'name': 'tweet_user_id',  #参数名
            'des': '推特用户ID',  #参数错误描述
            'type':
            'str',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': False,  #是否转换为小写
            'default': None,  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': '[A-Za-z0-9_]+$',  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示匹配任意字符串,值不为空时任意字符串将被转变为这个值
            }
        },
        {
            'name': 'nick',  #参数名
            'des': '昵称',  #参数错误描述
            'type':
            'str',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': False,  #是否转换为小写
            'default': '',  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': r'[\s\S]{0,50}',  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示匹配任意字符串,值不为空时任意字符串将被转变为这个值
            }
        },
        {
            'name': 'des',  #参数名
            'des': '描述',  #参数错误描述
            'type':
            'str',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': False,  #是否转换为小写
            'default': '',  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': r'[\s\S]{0,100}',  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示匹配任意字符串,值不为空时任意字符串将被转变为这个值
            }
        }
    ]
    args = argDeal(session.current_arg_text.strip(), arglimit)
    if not args[0]:
        await session.send(args[1] + '=>' + args[2])
        return
    args = args[1]
    tweet_user_id = args['tweet_user_id']
    #获取数据
    res = tweetListener.tweet_event_deal.getUserInfo(tweet_user_id)
    if not res[0]:
        await session.send("查询不到信息,你D都能D歪来!?(・_・;?")
        return
    userinfo = res[1]

    nick = args['nick']
    des = args['des']
    if des == '':
        des = userinfo['name'] + '(' + userinfo['screen_name'] + ')'

    PushUnit = push_list.baleToPushUnit(session.event['self_id'],
                                        message_type,
                                        sent_id,
                                        userinfo['id'],
                                        user_id,
                                        user_id,
                                        des,
                                        nick=nick)
    res = push_list.addPushunit(PushUnit)
    s = '标识:'+ str(userinfo['id']) + "\n" + \
        '用户ID:' + userinfo['screen_name'] + "\n" + \
        '用户昵称:' + userinfo['name'] + "\n" + \
        '头像:' + '[CQ:image,timeout='+config.img_time_out+',file=' + userinfo['profile_image_url_https'] + ']'+ "\n" + \
        ('已经加入了DD名单了哦' if res[0] == True else '添加失败:'+res[1])
    push_list.savePushList()
    await session.send(s)
Esempio n. 9
0
async def globalRemove(session: CommandSession):
    if not headdeal(session):
        return
    await asyncio.sleep(0.2)
    message_type = session.event['message_type']
    #group_id = (session.event['group_id'] if message_type == 'group' else None)
    #user_id = session.event['user_id']
    if perm_check(session, '-listener', user=True):
        await session.send('操作被拒绝,权限不足(p)')
        return
    if message_type == 'group' and not perm_check(session, 'listener'):
        await session.send('操作被拒绝,权限不足(g)')
        return
    logger.info(CQsessionToStr(session))

    arglimit = [
        {
            'name': 'msgtype',  #参数名
            'des': '消息类型',  #参数错误描述
            'type':
            'str',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': True,  #是否转换为小写
            'default': None,  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': None,  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示允许任意字符串,值不为空时任意字符串将被转变为这个值
                '私聊': 'private',
                'private': 'private',
                '群聊': 'group',
                'group': 'group',
                '好友': 'private',
                '群': 'group',
            }
        },
        {
            'name': 'send_id',  #参数名
            'des': '对象ID',  #参数错误描述
            'type':
            'int',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': False,  #是否转换为小写
            'default': None,  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': None,  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示匹配任意字符串,值不为空时任意字符串将被转变为这个值
            }
        }
    ]
    res = argDeal(session.current_arg_text.strip(), arglimit)
    if not res[0]:
        await session.send(res[1] + '=>' + res[2])
        return
    args = res[1]
    res = push_list.delPushunitFromPushTo(args['message_type'],
                                          args['send_id'],
                                          self_id=int(
                                              session.event['self_id']))
    push_list.savePushList()
    await session.send(res[1])
Esempio n. 10
0
async def setAttr(session: CommandSession):
    if not headdeal(session):
        return
    await asyncio.sleep(0.2)
    message_type = session.event['message_type']
    group_id = (session.event['group_id'] if message_type == 'group' else None)
    user_id = session.event['user_id']
    if perm_check(session, '-listener', user=True):
        await session.send('操作被拒绝,权限不足(p)')
        return
    sent_id = 0
    if message_type == 'private':
        sent_id = user_id
    elif message_type == 'group':
        if not perm_check(session, 'listener'):
            await session.send('操作被拒绝,权限不足(g)')
            return
        sent_id = group_id
    else:
        await session.send('未收录的消息类型:' + message_type)
        return
    logger.info(CQsessionToStr(session))

    arglimit = [
        {
            'name': 'tweet_user_id',  #参数名
            'des': '推特用户ID',  #参数错误描述
            'type':
            'int',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': False,  #是否转换为小写
            'default': None,  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': None,  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示匹配任意字符串,值不为空时任意字符串将被转变为这个值
            }
        },
        {
            'name': 'key',  #参数名
            'des': '设置名称',  #参数错误描述
            'type':
            'str',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': False,  #是否转换为小写
            'default': None,  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': None,  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示匹配任意字符串,值不为空时任意字符串将被转变为这个值
                #携带图片发送
                'upimg': 'upimg',
                '图片': 'upimg',
                'img': 'upimg',
                #描述设置
                'des': 'des',
                '描述': 'des',
                #昵称设置
                'nick': 'nick',
                '昵称': 'nick',
                #消息模版
                'retweet_template': 'retweet_template',
                '转推模版': 'retweet_template',
                'quoted_template': 'quoted_template',
                '转推并评论模版': 'quoted_template',
                'reply_to_status_template': 'reply_to_status_template',
                '回复模版': 'reply_to_status_template',
                'reply_to_user_template': 'reply_to_user_template',
                '被提及模版': 'reply_to_user_template',
                'none_template': 'none_template',
                '发推模版': 'none_template',
                #推特转发各类型开关
                'retweet': 'retweet',
                '转推': 'retweet',
                'quoted': 'quoted',
                '转推并评论': 'quoted',
                'reply_to_status': 'reply_to_status',
                '回复': 'reply_to_status',
                'reply_to_user': '******',
                '提及': 'reply_to_user',
                'none': 'none',
                '发推': 'none',
                #智能推送开关
                'ai_retweet': 'ai_retweet',
                '智能转推': 'ai_retweet',
                'ai_reply_to_status': 'ai_reply_to_status',
                '智能转发回复': 'ai_reply_to_status',
                'ai_passive_reply_to_status': 'ai_passive_reply_to_status',
                '智能转发被回复': 'ai_passive_reply_to_status',
                'ai_passive_quoted': 'ai_passive_quoted',
                '智能转发被转推并评论': 'ai_passive_quoted',
                'ai_passive_reply_to_user': '******',
                '智能转发被提及': 'ai_passive_reply_to_user',
                #推特个人信息变动推送开关
                'change_id': 'change_ID',
                'ID改变': 'change_ID',
                'ID修改': 'change_ID',
                'change_name': 'change_name',
                '名称改变': 'change_name',
                '名称修改': 'change_name',
                '名字改变': 'change_name',
                '名字修改': 'change_name',
                '昵称修改': 'change_name',
                '昵称改变': 'change_name',
                '昵称修改': 'change_name',
                'change_description': 'change_description',
                '描述改变': 'change_description',
                '描述修改': 'change_description',
                'change_headimgchange': 'change_headimgchange',
                '头像改变': 'change_headimgchange',
                '头像修改': 'change_headimgchange'
            }
        },
        {
            'name': 'value',  #参数名
            'des': '设置值',  #参数错误描述
            'type':
            'str',  #参数类型int float str list dict (list与dict需要使用函数或正则表达式进行二次处理)
            'strip': True,  #是否strip
            'lower': False,  #是否转换为小写
            'default': '',  #默认值
            'func': None,  #函数,当存在时使用函数进行二次处理
            're': None,  #正则表达式匹配(match函数)
            'vlimit': {
                #参数限制表(限制参数内容,空表则不限制),'*':''表示匹配任意字符串,值不为空时任意字符串将被转变为这个值
                'true': '1',
                '开': '1',
                '打开': '1',
                '开启': '1',
                'false': '0',
                '关': '0',
                '关闭': '0',
                '*': ''
            }
        }
    ]
    args = argDeal(session.current_arg_text.strip(), arglimit)
    if not args[0]:
        await session.send(args[1] + '=>' + args[2])
        return
    args = args[1]
    template_attr = ('retweet_template', 'quoted_template',
                     'reply_to_status_template', 'reply_to_user_template',
                     'none_template')
    tweet_user_id = args['tweet_user_id']
    attr = args['key']
    attrv = args['value']
    if str(tweet_user_id) not in push_list.spylist:
        await session.send("用户不在监测列表内!")
        return
    if attr == 'des' or attr == 'nick' or attr in template_attr:
        res = push_list.setPushunitAttr(message_type, sent_id, tweet_user_id,
                                        attr, attrv)
    elif attrv in ('0', '1'):
        res = push_list.setPushunitAttr(message_type, sent_id, tweet_user_id,
                                        attr, int(attrv))
    else:
        res = (False, '属性的值不合法!')
        return
    push_list.savePushList()
    await session.send(res[1])
Esempio n. 11
0
async def setAttr(session: CommandSession):
    await asyncio.sleep(0.2)
    stripped_arg = session.current_arg_text.strip().lower()
    if stripped_arg == '':
        await session.send("缺少参数")
        return
    cs = commandHeadtail(stripped_arg)
    cs = {0: cs[0], 1: cs[1], 2: cs[2].strip()}
    if cs[0] == '' or cs[2] == '':
        await session.send("缺少参数")
        return
    #处理用户ID
    tweet_user_id: int = -1
    if cs[0].isdecimal():
        tweet_user_id = int(cs[0])
    else:
        await session.send("用户ID错误")
        return
    if cs[2].strip() == '':
        await session.send("缺少参数")
        return
    tcs = commandHeadtail(cs[2])
    cs[2] = tcs[0]
    cs[3] = tcs[1]
    cs[4] = tcs[2].strip()
    PushTo: int = 0
    if session.event['message_type'] == 'group':
        PushTo = int(session.event['group_id'])
    elif session.event['message_type'] == 'private':
        PushTo = int(session.event['user_id'])
    else:
        await session.send('不支持的消息类型!')
        return
    Pushunit_allowEdit = {
        #携带图片发送
        'upimg': 'upimg',
        '图片': 'upimg',
        'img': 'upimg',
        #昵称设置
        'nick': 'nick',
        '昵称': 'nick',
        #描述设置
        'des': 'des',
        '描述': 'des',
        #消息模版
        'retweet_template': 'retweet_template',
        '转推模版': 'retweet_template',
        'quoted_template': 'quoted_template',
        '转推并评论模版': 'quoted_template',
        'reply_to_status_template': 'reply_to_status_template',
        '回复模版': 'reply_to_status_template',
        'reply_to_user_template': 'reply_to_user_template',
        '被提及模版': 'reply_to_user_template',
        'none_template': 'none_template',
        '发推模版': 'none_template',
        #推特转发各类型开关
        'retweet': 'retweet',
        '转推': 'retweet',
        'quoted': 'quoted',
        '转推并评论': 'quoted',
        'reply_to_status': 'reply_to_status',
        '回复': 'reply_to_status',
        'reply_to_user': '******',
        '被提及': 'reply_to_user_template',
        'none': 'none',
        '发推': 'none',
        #推特个人信息变动推送开关
        'change_id': 'change_ID',
        'ID改变': 'change_ID',
        'change_name': 'change_name',
        '名称改变': 'change_name',
        'change_description': 'change_description',
        '描述改变': 'change_description',
        'change_headimgchange': 'change_headimgchange',
        '头像改变': 'change_headimgchange'
    }
    template_attr = ('retweet_template', 'quoted_template',
                     'reply_to_status_template', 'reply_to_user_template',
                     'none_template')
    if str(tweet_user_id) not in push_list.spylist:
        await session.send("用户不在监测列表内!")
        return
    if cs[2] not in Pushunit_allowEdit:
        await session.send('属性值不存在!')
        return
    if Pushunit_allowEdit[cs[2]] == 'des' or Pushunit_allowEdit[
            cs[2]] == 'nick':
        res = push_list.setPushunitAttr(session.event['message_type'], PushTo,
                                        tweet_user_id,
                                        Pushunit_allowEdit[cs[2]], cs[4])
    elif cs[4] != '' and Pushunit_allowEdit[cs[2]] in template_attr:
        res = push_list.setPushunitAttr(session.event['message_type'], PushTo,
                                        tweet_user_id,
                                        Pushunit_allowEdit[cs[2]], cs[4])
    elif cs[4] in ('true', '开', '打开', '开启', '1'):
        res = push_list.setPushunitAttr(session.event['message_type'], PushTo,
                                        tweet_user_id,
                                        Pushunit_allowEdit[cs[2]], 1)
    elif cs[4] in ('false', '关', '关闭', '0'):
        res = push_list.setPushunitAttr(session.event['message_type'], PushTo,
                                        tweet_user_id,
                                        Pushunit_allowEdit[cs[2]], 0)
    else:
        res = (False, '属性的值不合法!')
        await session.send(res[1])
        return
    push_list.savePushList()
    await session.send(res[1])
    logger.info(CQsessionToStr(session))
Esempio n. 12
0
async def setGroupAttr(session: CommandSession):
    await asyncio.sleep(0.2)
    stripped_arg = session.current_arg_text.strip().lower()
    if stripped_arg == '':
        await session.send("缺少参数")
        return
    Pushunit_allowEdit = {
        #携带图片发送
        'upimg': 'upimg',
        '图片': 'upimg',
        'img': 'upimg',
        #昵称设置
        #'nick':'nick','昵称':'nick',
        #消息模版
        'retweet_template': 'retweet_template',
        '转推模版': 'retweet_template',
        'quoted_template': 'quoted_template',
        '转推并评论模版': 'quoted_template',
        'reply_to_status_template': 'reply_to_status_template',
        '回复模版': 'reply_to_status_template',
        'reply_to_user_template': 'reply_to_user_template',
        '被提及模版': 'reply_to_user_template',
        'none_template': 'none_template',
        '发推模版': 'none_template',
        #推特转发各类型开关
        'retweet': 'retweet',
        '转推': 'retweet',
        'quoted': 'quoted',
        '转推并评论': 'quoted',
        'reply_to_status': 'reply_to_status',
        '回复': 'reply_to_status',
        'reply_to_user': '******',
        '被提及': 'reply_to_user_template',
        'none': 'none',
        '发推': 'none',
        #推特个人信息变动推送开关
        'change_id': 'change_ID',
        'ID改变': 'change_ID',
        'ID修改': 'change_ID',
        'change_name': 'change_name',
        '名称改变': 'change_name',
        '名称修改': 'change_name',
        '名字改变': 'change_name',
        '名字修改': 'change_name',
        '昵称修改': 'change_name',
        'change_description': 'change_description',
        '描述改变': 'change_description',
        '描述修改': 'change_description',
        'change_headimgchange': 'change_headimgchange',
        '头像改变': 'change_headimgchange',
        '头像修改': 'change_headimgchange'
    }
    template_attr = ('retweet_template', 'quoted_template',
                     'reply_to_status_template', 'reply_to_user_template',
                     'none_template')
    cs = commandHeadtail(stripped_arg)
    cs = {0: cs[0], 1: cs[1], 2: cs[2].strip()}
    if cs[0] == '' or cs[2] == '':
        await session.send("缺少参数")
        return
    if cs[0] not in Pushunit_allowEdit:
        await session.send('属性值不存在!')
        return
    PushTo: int = 0
    if session.event['message_type'] == 'group':
        PushTo = int(session.event['group_id'])
    elif session.event['message_type'] == 'private':
        PushTo = int(session.event['user_id'])
    else:
        await session.send('不支持的消息类型!')
        return
    if cs[2] != '' and Pushunit_allowEdit[cs[0]] in template_attr:
        cs[2] = cs[2].replace("\\n", "\n")
        res = push_list.PushTo_setAttr(session.event['message_type'], PushTo,
                                       Pushunit_allowEdit[cs[0]], cs[2])
    elif cs[2] in ('true', '开', '打开', '开启', '1'):
        res = push_list.PushTo_setAttr(session.event['message_type'], PushTo,
                                       Pushunit_allowEdit[cs[0]], 1)
    elif cs[2] in ('false', '关', '关闭', '0'):
        res = push_list.PushTo_setAttr(session.event['message_type'], PushTo,
                                       Pushunit_allowEdit[cs[0]], 0)
    else:
        res = (False, '属性的值不合法!')
        await session.send(res[1])
        return
    push_list.savePushList()
    logger.info(CQsessionToStr(session))
    await session.send(res[1])