Example #1
0
def onStartupComplete(bot):
    # 启动完成时被调用
    # bot : QQBot 对象,提供 List/SendTo/GroupXXX/Stop/Restart 等接口,详见文档第五节
    global weibo_monitor

    global_config.MEMBER_WEIBO_GROUPS = ConfigReader.get_property(
        'qq_conf', 'member_weibo_groups').split(';')
    weibo_monitor = WeiboMonitor()
    weibo_monitor.login('15018433261', 'boa-85880907-BOA')
    name = ConfigReader.get_property('root', 'member_name')
    uid = ConfigReader.get_property('weibo', name)
    # uid = 1134206783
    weibo_monitor.getWBQueue(uid)
Example #2
0
def update_weibo_conf(bot):
    global weibo_monitor

    DEBUG('读取微博配置')
    global_config.MEMBER_WEIBO_GROUPS = ConfigReader.get_property(
        'qq_conf', 'member_weibo_groups').split(';')

    member_name = ConfigReader.get_property('root', 'member_name')
    if global_config.MEMBER_NAME == '' or global_config.MEMBER_NAME != member_name:
        DEBUG('微博监控变更')
        global_config.MEMBER_NAME = member_name
        uid = ConfigReader.get_property('weibo', member_name)
        if uid != '':
            weibo_monitor.getWBQueue(uid)
        else:
            INFO('没有微博UID')
Example #3
0
def update_weibo_conf():
    global weibo_monitor

    my_logger.debug('读取微博配置')
    global_config.MEMBER_WEIBO_GROUPS = ConfigReader.get_property(
        'qq_conf', 'member_weibo_groups').split(';')

    for task in global_config.POCKET48_LISTEN_TASKS:
        uid = task.member.weibo_uid
        my_logger.debug('weibo uid: %s', uid)
        if uid != 0:
            weibo_monitor.getWBQueue(task)
        else:
            my_logger.error('微博UID填写错误,请检查')
Example #4
0
def update_modian_conf(bot):
    global modian_handler
    INFO('读取摩点配置')
    ConfigReader.read_conf()
    modian_json = json.load(open("data/modian.json"))

    global_config.MODIAN_POSTSCRIPTS = modian_json['modian_postscripts']

    # 摩点集资PK链接数组初始化
    global_config.MODIAN_NEED_DISPLAY_PK = modian_json[
        'modian_need_display_pk']

    for modian_pk_j in modian_json['modian_pk_activities']:
        global_config.MODIAN_PK_ARRAY.append(modian_pk_j)

    # 需要适应同时开多个链接的情况
    global_config.MODIAN_ARRAY = []

    for modian_j in modian_json['monitor_activities']:
        if modian_j['modian_need_display_rank'] is False:
            modian = ModianEntity(modian_j['modian_link'],
                                  modian_j['modian_title'],
                                  modian_j['modian_pro_id'], False)
        elif modian_j['wds_need_display_rank'] is True:
            modian = ModianEntity(modian_j['modian_link'],
                                  modian_j['modian_title'],
                                  modian_j['modian_pro_id'], True)
        global_config.MODIAN_ARRAY.append(modian)

    modian_handler.modian_project_array = global_config.MODIAN_ARRAY

    modian_handler.init_order_queues()

    global_config.JIZI_NOTIFY_GROUPS = ConfigReader.get_property(
        'qq_conf', 'jizi_notify_groups').split(';')
    modian_groups = global_config.JIZI_NOTIFY_GROUPS
    modian_handler.modian_notify_groups = modian_groups

    DEBUG('JIZI_NOTIFY_GROUPS: %s, length: %d',
          ','.join(global_config.JIZI_NOTIFY_GROUPS),
          len(modian_handler.modian_notify_groups))
Example #5
0
def update_wds_conf(bot):
    global wds_handler

    DEBUG('读取微打赏配置')
    ConfigReader.read_conf()
    wds_json = json.load(open("data/wds.json"))

    global_config.WDS_POSTSCRIPTS = wds_json['wds_postscripts']

    # 微打赏集资PK链接数组初始化
    global_config.WDS_NEED_DISPLAY_PK = wds_json['wds_need_display_pk']

    for wds_pk_j in wds_json['wds_pk_activities']:
        wds = WDS(wds_pk_j['wds_pk_link'], wds_pk_j['wds_pk_title'], '', '', False)
        global_config.WDS_PK_ARRAY.append(wds)

    # 需要适应同时开多个链接的情况
    global_config.WDS_ARRAY = []

    for wds_j in wds_json['monitor_activities']:
        if wds_j['wds_need_display_rank'] is False:
            wds = WDS(wds_j['wds_link'], wds_j['wds_title'], wds_j['wds_moxi_id'], wds_j['wds_pro_id'],
                      False)
        elif wds_j['wds_need_display_rank'] is True:
            wds = WDS(wds_j['wds_link'], wds_j['wds_title'], wds_j['wds_moxi_id'], wds_j['wds_pro_id'],
                      True)
        global_config.WDS_ARRAY.append(wds)

    wds_handler.wds_array = global_config.WDS_ARRAY

    wds_handler.init_comment_queues()

    global_config.JIZI_NOTIFY_GROUPS = ConfigReader.get_property('qq_conf', 'jizi_notify_groups').split(';')
    wds_groups = QQHandler.list_group(global_config.JIZI_NOTIFY_GROUPS)
    wds_handler.wds_notify_groups = wds_groups

    DEBUG('JIZI_NOTIFY_GROUPS: %s, length: %d', ','.join(global_config.JIZI_NOTIFY_GROUPS),
          len(wds_handler.wds_notify_groups))
Example #6
0
def onQQMessage(bot, contact, member, content):
    # 当收到 QQ 消息时被调用
    # bot     : QQBot 对象,提供 List/SendTo/GroupXXX/Stop/Restart 等接口,详见文档第五节
    # contact : QContact 对象,消息的发送者
    # member  : QContact 对象,仅当本消息为 群或讨论组 消息时有效,代表实际发消息的成员
    # content : str 对象,消息内容
    # DEBUG('member: %s', str(getattr(member, 'uin')))
    # DEBUG('content: %s', content)
    # DEBUG('contact: %s', contact.ctype)
    global pocket48_handler

    if contact.ctype == 'group':
        if '@ME' in content:  # 在群中@机器人
            strs = content.split('[@ME]')[1].strip()
            if strs :
                id = contact.uin
                bot.SendTo(contact, pocket48_handler.get_tuling_ai(id, strs))
            else:
                bot.SendTo(contact, util.random_str(global_config.AT_AUTO_REPLY))
        elif content.startswith('-'):  # 以'-'开头才能触发自动回复
            if content == '-version':
                bot.SendTo(contact, 'QQbot-' + bot.conf.version)
            elif content == '-票务' or content == '-公演':
                pocket48_handler.get_current_ticket_info_msg(global_config.TICKET_INFO)
            elif content == '-屏蔽全部消息' or content == '-屏蔽所有消息':
                if len(global_config.ACTIVE_MEMBER_ROOM_ID_LIST) > 0:
                    global_config.DEACTIVE_MEMBER_ROOM_ID_LIST = ConfigReader.get_all_member_room_id_list()
                    global_config.ACTIVE_MEMBER_ROOM_ID_LIST = []
                    QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '已屏蔽全部房间消息')

                else:
                    QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '当前已屏蔽全部房间消息,请不要重复输入命令')
            elif content == '-开启全部消息' or content == '-开启全部消息':
                if len(global_config.DEACTIVE_MEMBER_ROOM_ID_LIST) > 0:
                    global_config.ACTIVE_MEMBER_ROOM_ID_LIST = ConfigReader.get_all_member_room_id_list()
                    global_config.DEACTIVE_MEMBER_ROOM_ID_LIST = []
                    pocket48_handler.init_msg_queues(global_config.ACTIVE_MEMBER_ROOM_ID_LIST)
                    QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '已开启全部房间消息')
                else:
                    QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '当前已开启全部房间消息,请不要重复输入命令')
            elif content == '-关闭':
                bot.SendTo(contact, 'QQ机器人已关闭')
                bot.Stop()
            elif '-屏蔽' in content and '消息' in content:
                if len(global_config.ACTIVE_MEMBER_ROOM_ID_LIST) > 0:
                    name = util.get_order_name(content)
                    # 命令是否包含成员名字
                    if util.is_name_in_member_list(name):
                        # 屏蔽逻辑
                        pocket48_handler.deactive_member_by_name(name)
                    else:
                        QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '屏蔽失败, 无法识别该成员,请确保命令输入正确')
                else:
                     QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '当前已屏蔽全部房间消息,无法再进行屏蔽')
            elif '-开启' in content and '消息' in content:
                if len(global_config.DEACTIVE_MEMBER_ROOM_ID_LIST) > 0:
                    name = util.get_order_name(content)
                    # 命令是否包含成员名字
                    if util.is_name_in_member_list(name):
                        # 开启逻辑
                        pocket48_handler.active_member_by_name(name)
                    else:
                        QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '开启失败, 无法识别该成员,请确保命令输入正确')
                else:
                    QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, '当前已开启全部房间消息,无法再进行开启')
            elif content == '-直播':
                r = pocket48_handler.get_member_live_msg()
                pocket48_handler.parse_member_live_now(r, global_config.LIVING_MEMBER_ID_LIST)
            elif content == '-小黑屋':
                msg = util.get_black_room_list()
                QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, msg)
            elif content == '-小白屋':
                msg = util.get_white_room_list()
                QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, msg)
            elif content == '-使用说明':
                msg = '''
机器人使用说明:
一、命令类型(输入一次即可, 没回复可能是机器人没开启 或者 机器人卡住了):
    (1)'-票务':  查看尚未公演的票务信息.
    (2)'-直播':  查看所有正在直播的直播间.
    (3)'-使用说明':  机器人使用说明.
    (4)'-屏蔽全部(所有)消息':  屏蔽全部成员房间消息.
    (5)'-开启全部(所有)消息':  开启全部成员房间消息.
    (6)'-屏蔽' + 成员名字 + '消息':  屏蔽某个成员房间消息.
    (7)'-开启' + 成员名字 + '消息':  开启某个成员房间消息.
    (8)'-小黑屋':  查看被屏蔽房间消息的成员.
    (9)'-小白屋':  查看已开启房间消息的成员
    其余命令均无法识别
二、聊天
    '@机器人' + 聊天内容:  与图灵机器人聊天 (每天上限1000次, 河内梗完善中...)'''
                QQHandler.send_to_groups(pocket48_handler.member_room_msg_groups, msg)
            else:  # 无法识别命令
                no_such_command = ConfigReader.get_property('profile', 'no_such_command')
                bot.SendTo(contact, no_such_command)
Example #7
0
def onStartupComplete(bot):
    # 启动完成时被调用
    # bot : QQBot 对象,提供 List/SendTo/GroupXXX/Stop/Restart 等接口,详见文档第五节
    DEBUG('%s.onStartupComplete', __name__)
    global pocket48_handler
    # 实例化PocketHandler
    pocket48_handler = Pocket48Handler([], [], [], [], [])
    # 获取票务
    global_config.TICKET_INFO = pocket48_handler.get_ticket_info()
    # 登录口袋48
    username = ConfigReader.get_property('user', 'username')
    password = ConfigReader.get_property('user', 'password')
    pocket48_handler.login(username, password)

    DEBUG('读取配置文件')

    ConfigReader.read_conf()
    global_config.ACTIVE_MEMBER_ROOM_ID_LIST = ConfigReader.get_all_member_room_id_list()
    global_config.LIVING_MEMBER_ID_LIST = ConfigReader.get_living_member_id_list()


    global_config.AUTO_REPLY_GROUPS = ConfigReader.get_property('qq_conf', 'auto_reply_groups').split(';')
    global_config.MEMBER_ROOM_MSG_GROUPS = ConfigReader.get_property('qq_conf', 'member_room_msg_groups').split(';')
    global_config.MEMBER_ROOM_COMMENT_GROUPS = ConfigReader.get_property('qq_conf', 'member_room_comment_groups').split(';')
    global_config.MEMBER_LIVE_GROUPS = ConfigReader.get_property('qq_conf', 'member_live_groups').split(';')
    global_config.MEMBER_ROOM_MSG_LITE_GROUPS = ConfigReader.get_property('qq_conf', 'member_room_comment_lite_groups').split(';')

    auto_reply_groups = QQHandler.list_group(global_config.AUTO_REPLY_GROUPS)
    member_room_msg_groups = QQHandler.list_group(global_config.MEMBER_ROOM_MSG_GROUPS)
    member_room_comment_msg_groups = QQHandler.list_group(global_config.MEMBER_ROOM_COMMENT_GROUPS)
    member_live_groups = QQHandler.list_group(global_config.MEMBER_LIVE_GROUPS)
    member_room_msg_lite_groups = QQHandler.list_group(global_config.MEMBER_ROOM_MSG_LITE_GROUPS)

    pocket48_handler.member_room_msg_groups = member_room_msg_groups
    pocket48_handler.member_room_comment_msg_groups = member_room_comment_msg_groups
    pocket48_handler.auto_reply_groups = auto_reply_groups
    pocket48_handler.member_live_groups = member_live_groups
    pocket48_handler.member_room_msg_lite_groups = member_room_msg_lite_groups

    global_config.JIZI_KEYWORDS = ConfigReader.get_property('profile', 'jizi_keywords').split(';')
    global_config.JIZI_LINK = ConfigReader.get_property('profile', 'jizi_link').split(';')

    global_config.WEIBO_KEYWORDS = ConfigReader.get_property('profile', 'weibo_keywords').split(';')
    global_config.GONGYAN_KEYWORDS = ConfigReader.get_property('profile', 'gongyan_keywords').split(';')
    global_config.LIVE_LINK=ConfigReader.get_property('profile', 'live_link').split(';')
    global_config.LIVE_SCHEDULE = ConfigReader.get_property('profile', 'live_schedule').split(';')

    global_config.WEIBO_LINK = ConfigReader.get_property('profile', 'weibo_link')
    global_config.SUPER_TAG = ConfigReader.get_property('profile', 'super_tag')

    global_config.MEMBER_ATTR = ConfigReader.get_property('profile', 'member_attr')
    global_config.I_LOVE = ConfigReader.get_property('profile', 'i_love').split(';')

    global_config.AT_AUTO_REPLY = ConfigReader.get_property('profile', 'at_auto_reply').split(';')
    global_config.ROOM_MSG_LITE_NOTIFY = ConfigReader.get_property('profile', 'room_msg_lite_notify').split(';')

    global_config.PERFORMANCE_NOTIFY = ConfigReader.get_property('profile', 'performance_notify')

    # 哔哩哔哩消息初始化
    bilibili_video_list = pocket48_handler.get_bilibili_video_list()
    pocket48_handler.init_bilibili_video_queues(bilibili_video_list)

    # 成员房间消息初始队列化
    pocket48_handler.init_msg_queues(global_config.ACTIVE_MEMBER_ROOM_ID_LIST)

    # 先更新配置
    update_conf(bot)
Example #8
0
from utils import global_config
from utils import util
import json
from utils.config_reader import ConfigReader

from utils.scheduler import scheduler
from log.my_logger import logger
from pocket48.pocket48_handler import Pocket48ListenTask, Member

# 读取口袋48的配置
global_config.MEMBER_JSON = json.load(open('data/pocket48/member.json', encoding='utf8'))
global_config.POCKET48_JSON = json.load(open('data/pocket48/pocket48.json'), encoding='utf8')
global_config.POCKET48_VERSION = global_config.POCKET48_JSON['version']
global_config.IMEI = global_config.POCKET48_JSON['IMEI']

global_config.AUTO_REPLY_GROUPS = ConfigReader.get_property('qq_conf', 'auto_reply_groups').split(';')
global_config.TEST_GROUPS = ConfigReader.get_property('qq_conf', 'test_groups').split(';')
global_config.PERFORMANCE_NOTIFY = ConfigReader.get_property('profile', 'performance_notify')
global_config.LIVE_LINK = ConfigReader.get_property('auto_reply', '公演直播')

using_pro = ConfigReader.get_property('root', 'using_coolq_pro')
if using_pro == 'yes':
    global_config.USING_COOLQ_PRO = True

logger.debug('读取成员信息')
members_list = global_config.POCKET48_JSON['monitor_members']
for member in members_list:
    member_pinyin = member['name']
    if member_pinyin in global_config.MEMBER_JSON:
        # 如果成员名在数据文件中,创建监听任务
        member_json = global_config.MEMBER_JSON[member_pinyin]
Example #9
0
def update_modian_conf():
    global modian_handler
    time0 = time.time()
    my_logger.info('读取摩点配置')
    ConfigReader.read_conf()
    # modian_json = json.load(open("data/modian.json", encoding='utf8'))
    # modian_json = json.load(open("data/weixin_group_account.json", encoding='utf8'))
    modian_json = json.load(open("data/taoba_account.json", encoding='utf8'))

    modian_handler.login(modian_json['taoba_account'],
                         modian_json['taoba_passwd'])

    global_config.MODIAN_POSTSCRIPTS = modian_json['modian_postscripts']

    # 摩点集资PK链接数组初始化
    global_config.MODIAN_NEED_DISPLAY_PK = modian_json[
        'modian_need_display_pk']

    for modian_pk_j in modian_json['modian_pk_activities']:
        global_config.MODIAN_PK_ARRAY.append(modian_pk_j)

    # 是否需要开启抽卡功能
    global_config.MODIAN_CARD_DRAW = modian_json['modian_need_card_draw']

    # global_config.MODIAN_300_ACTIVITY = modian_json['modian_300_activity']

    # 需要适应同时开多个链接的情况
    global_config.MODIAN_ARRAY = []

    for modian_j in modian_json['monitor_activities']:
        # if modian_j['modian_need_display_rank'] is False:
        # modian = ModianEntity(modian_j['modian_link'], modian_j['modian_title'], modian_j['modian_pro_id'], False,
        #                       modian_j['broadcast_groups'])
        # modian = GroupAccountEntity(modian_j['modian_link'], modian_j['modian_title'], modian_j['modian_pro_id'],
        #                             modian_j['broadcast_groups'], modian_j['qrcode'])
        modian = TaoBaEntity(modian_j['modian_link'], modian_j['modian_title'],
                             modian_j['modian_pro_id'],
                             modian_j['broadcast_groups'], modian_j['qrcode'])
        # elif modian_j['wds_need_display_rank'] is True:
        #     modian = ModianEntity(modian_j['modian_link'], modian_j['modian_title'], modian_j['modian_pro_id'], True,
        #                           modian_j['broadcast_groups'])
        global_config.MODIAN_ARRAY.append(modian)

    modian_handler.taoba_project_array = global_config.MODIAN_ARRAY

    # modian_handler.init_order_queues()
    modian_handler.card_draw_handler.read_config()

    global_config.JIZI_NOTIFY_GROUPS = ConfigReader.get_property(
        'qq_conf', 'jizi_notify_groups').split(';')
    modian_groups = global_config.JIZI_NOTIFY_GROUPS
    modian_handler.group_account_notify_groups = modian_groups

    my_logger.debug('JIZI_NOTIFY_GROUPS: %s, length: %d',
                    ','.join(global_config.JIZI_NOTIFY_GROUPS),
                    len(modian_handler.group_account_notify_groups))

    my_logger.debug('读取正在进行中的flag活动')
    global_config.MODIAN_FLAG_ACTIVITIES = {}
    flag_json = json.load(open('data/modian_flag.json',
                               encoding='utf8'))['activities']
    for modian in global_config.MODIAN_ARRAY:
        pro_id = modian.taoba_id
        global_config.MODIAN_FLAG_ACTIVITIES[pro_id] = []
    for activity in flag_json:
        pro_id = activity['pro_id']
        end_time = activity['end_time']
        if util.convert_timestr_to_timestamp(end_time) > time.time():
            flag = ModianFlagEntity(activity['flag_name'], activity['pro_id'],
                                    activity['target_flag_amount'],
                                    activity['end_time'], activity['remark'])
            global_config.MODIAN_FLAG_ACTIVITIES[int(pro_id)].append(flag)
    my_logger.debug('MODIAN_FLAG_ACTIVITIES: %s',
                    global_config.MODIAN_FLAG_ACTIVITIES)

    my_logger.debug('读取正在进行的人头flag活动')
    global_config.MODIAN_COUNT_FLAG_ACTIVITIES = {}
    count_flag_json = json.load(
        open('data/modian_count_flag.json', encoding='utf8'))['activities']
    for modian in global_config.MODIAN_ARRAY:
        pro_id = modian.taoba_id
        global_config.MODIAN_COUNT_FLAG_ACTIVITIES[pro_id] = []
    for activity in count_flag_json:
        pro_id = activity['pro_id']
        start_time = activity['start_time']
        end_time = activity['end_time']
        if util.convert_timestr_to_timestamp(
                start_time) >= util.convert_timestr_to_timestamp(end_time):
            my_logger.error('人头类flag,起始时间大于结束时间!')
            raise RuntimeError('起始时间大于结束时间')
        time0 = time.time()
        if util.convert_timestr_to_timestamp(
                end_time) > time0 > util.convert_timestr_to_timestamp(
                    start_time):
            flag = ModianCountFlagEntity(activity['flag_name'],
                                         activity['pro_id'],
                                         activity['target_flag_amount'],
                                         activity['start_time'],
                                         activity['end_time'],
                                         activity['remark'])
            global_config.MODIAN_COUNT_FLAG_ACTIVITIES[int(pro_id)].append(
                flag)
    my_logger.debug('MODIAN_COUNT_FLAG_ACTIVITIES: %s',
                    global_config.MODIAN_COUNT_FLAG_ACTIVITIES)

    # 接棒活动更新,读取json文件中的内容,更新到数据库中
    my_logger.debug('接棒活动更新,读取json文件中的内容,更新到数据库中')
    jiebang_json = json.load(open('data/modian_jiebang.json',
                                  encoding='utf8'))['activities']
    # conn = sqlite3.connect('data/modian.db', check_same_thread=False)
    for activity in jiebang_json:
        end_time = activity['end_time']
        my_logger.debug('活动结束时间: {}; 当前时间:{}'.format(
            util.convert_timestr_to_timestamp(end_time), time.time()))
        if util.convert_timestr_to_timestamp(end_time) < time.time():
            my_logger.debug('活动结束时间早于当前时间,跳过')
            continue
        name = activity['jiebang_name']
        try:
            # cursor = conn.cursor()
            # c = cursor.execute("""
            #     select * from jiebang WHERE name=?
            # """, (name, ))
            # rst = c.fetchall()
            rst = mysql_util.select_one(
                """
                select * from jiebang WHERE name=%s
            """, (name, ))
            my_logger.debug(rst)
            if rst is not None:
                my_logger.debug('DB中有相应的接棒活动')
            else:
                my_logger.debug('DB中没有对应的接棒活动,需要创建')
                mysql_util.query(
                    """
                                    INSERT INTO jiebang (name, pro_id, current_stick_num, start_time, 
                                    end_time, target_stick_num, min_stick_amount, need_detail) VALUES
                                    (%s, %s, %s, %s, %s, %s, %s, %s)
                                """,
                    (name, activity['pro_id'], 0, activity['start_time'],
                     activity['end_time'], activity['target_stick_num'],
                     activity['min_stick_amount'], activity['need_detail']))
                # conn.commit()
            # else:
            #     raise RuntimeError('接棒活动名称错误!')
        except Exception as e:
            my_logger.error('读取mysql出现错误')
            my_logger.exception(e)
        # finally:
        #     cursor.close()

    # 读取正在进行中的接棒活动
    my_logger.debug('读取正在进行中的接棒活动')
    global_config.MODIAN_JIEBANG_ACTIVITIES = {}
    for modian in global_config.MODIAN_ARRAY:
        pro_id = modian.taoba_id
        global_config.MODIAN_JIEBANG_ACTIVITIES[pro_id] = []
        try:
            # cursor = conn.cursor()
            rst = mysql_util.select_all(
                """
                SELECT name, pro_id, current_stick_num, last_record_time, 
                    start_time, end_time, target_stick_num, min_stick_amount, need_detail
                FROM jiebang where pro_id=%s 
                    and end_time >= NOW() and current_stick_num < target_stick_num
            """, (pro_id, ))
            if rst:
                for jiebang in rst:
                    my_logger.debug('jiebang name: {}'.format(
                        str(jiebang[0], encoding='utf-8')))
                    # 修正当前棒数
                    my_logger.info('修正接棒棒数')
                    real_stick_num = 0
                    rst0 = mysql_util.select_all(
                        """
                                    SELECT backer_money FROM `order`
                                        WHERE pro_id = %s and backer_money >= %s and pay_time >= %s and pay_time <= %s
                                """,
                        (pro_id, jiebang[7], jiebang[4], jiebang[5]))
                    my_logger.debug(
                        """
                                    SELECT backer_money FROM `order`
                                        WHERE pro_id = %s and backer_money >= %s and pay_time >= %s and pay_time <= %s
                                """ %
                        (pro_id, jiebang[7], jiebang[4], jiebang[5]))
                    my_logger.debug(rst0)
                    if rst0:
                        for order in rst0:
                            my_logger.debug('order: {}'.format(order[0]))
                            real_stick_num += int(order[0] // jiebang[7])

                    my_logger.info('记录棒数: {}, 实际棒数: {}'.format(
                        jiebang[2], real_stick_num))
                    mysql_util.query(
                        """
                        UPDATE jiebang SET current_stick_num = %s WHERE name = %s
                    """, (real_stick_num, jiebang[0]))

                    my_logger.debug(
                        'jiebang: %s, %s, %s, %s, %s, %s, %s, %s, %s',
                        jiebang[0], jiebang[1], jiebang[2], jiebang[3],
                        jiebang[4], jiebang[5], jiebang[6], jiebang[7],
                        jiebang[8])
                    jiebang_entity = ModianJiebangEntity(
                        str(jiebang[0], encoding='utf-8'), jiebang[1],
                        jiebang[2], jiebang[3], jiebang[4], jiebang[5],
                        jiebang[6], jiebang[7], jiebang[8])
                    jiebang_entity.current_stick_num = real_stick_num
                    my_logger.info('修正完成')
                    global_config.MODIAN_JIEBANG_ACTIVITIES[pro_id].append(
                        jiebang_entity)

        except Exception as e:
            my_logger.error('读取正在进行中的接棒活动出现错误!')
            my_logger.exception(e)
        # finally:
        #     cursor.close()
    my_logger.debug(global_config.MODIAN_JIEBANG_ACTIVITIES)
    # conn.close()

    my_logger.debug('读取摩点配置耗时: %s秒', time.time() - time0)
    modian_handler.init_order_queues()
Example #10
0
import sqlite3
import datetime
from datetime import date
import traceback

AUTO_REPLY = {}
items = ConfigReader.get_section('auto_reply')
logger.debug('items: %s', items)
for k, v in items:
    logger.debug('k: %s, v: %s', k, v)
    AUTO_REPLY[k] = v
    logger.debug('k in global_config.AUTO_REPLY: %s', k in AUTO_REPLY)
    logger.debug(AUTO_REPLY)

# groups = [483548995]
groups = ConfigReader.get_property('qq_conf', 'jizi_notify_groups').split(';')
test_groups = ConfigReader.get_property('qq_conf',
                                        'auto_reply_groups').split(';')
print(groups)
logger.debug('test groups: %s' % test_groups)
modian_json = json.load(open("data/modian.json", encoding='utf8'))

modian_array = []
for modian_j in modian_json['monitor_activities']:
    modian_array.append(modian_j)

# AI智能闲聊机器人
ai_app_key = ConfigReader.get_property('AIBot', 'appkey')
ai_app_id = ConfigReader.get_property('AIBot', 'appid')
ai_bot = QQAIBot(ai_app_key, ai_app_id)
Example #11
0
                        pass
                        # QQHandler.send_to_groups(member_weibo_groups, '[CQ:image,file={}]'.format(newWB['video_url']))
                    if 'picUrls' in newWB.keys():
                        # for pic in newWB['picUrls']:
                        # 发一张图就可以了
                        pass
                        # QQHandler.send_to_groups(member_weibo_groups, '[CQ:image,file={}]'.format(newWB['picUrls'][0]))
                    if 'retweeted_status' in newWB.keys():
                        text = '转发微博:\n@{}: {}'.format(
                            newWB['retweeted_status']['user'],
                            newWB['retweeted_status']['text'])
                        pass
                        # QQHandler.send_to_groups(member_weibo_groups, text)


weibo_monitor = WeiboMonitor()
update_weibo_conf()

if __name__ == '__main__':
    global_config.MEMBER_WEIBO_GROUPS = ConfigReader.get_property(
        'qq_conf', 'member_weibo_groups').split(';')
    # weibo_monitor.login('*', '*')
    # uid = ConfigReader.get_property('weibo', name)
    from pocket48.pocket48_handler import Pocket48ListenTask, Member
    uid = 1134206783
    task = Pocket48ListenTask(Member('SNH48', 0, 0, 2689280541, 'SNH48'))
    weibo_monitor.getWBQueue(task)
    while True:
        monitor_member_weibo()
        time.sleep(5)