示例#1
0
 def __init__(self, bot):
     if config.get('SYS', 'jd') == 'yes':
         self.se = requests.session()
         self.start_keep_cookie_thread()
         self.load_cookies()
         self.ort = Orther()
         self.tu = tuling()
         self.logger = my_utils.init_logger()
示例#2
0
 def __init__(self, bot):
     self.tu = tuling.tuling()
     self.mjd = mediaJd.MediaJd(bot)
     self.logger = my_utils.init_logger()
     self.al = alimama.Alimama(self.logger, bot)
     self.ort = Orther()
     self.pdd = pingdd.Pdd(bot)
     self.movie = movie.SharMovie()
示例#3
0
 def __init__(self, logger, bot):
     if config.get('SYS', 'tb') == 'yes':
         self.logger = logger
         self.ort = Orther()
         self.movie = SharMovie()
         self.bot2 = bot
         self.se = requests.session()
示例#4
0
from libs.alimama import Alimama
from libs.mysql import ConnectMysql
from bs4 import BeautifulSoup
from libs.groupMessage import FormData
from libs.movie import SharMovie
from libs import utils
from libs.tuling import tuling
from libs.wx_bot import *
from libs.orther import Orther

cm = ConnectMysql()
logger = utils.init_logger()
al = Alimama(logger)
mjd = MediaJd()
tu = tuling()
ort = Orther()


class TextMessage(object):
    def __init__(self):
        pass

    def getText(self, msg):
        wei_info = itchat.search_friends(userName=msg['FromUserName'])
        bot_info = itchat.search_friends(userName=msg['ToUserName'])

        patternURL = re.compile('^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+')

        pattern_bz = re.compile('^帮助$')
        pattern_profile = re.compile('^个人信息$')
        pattern_tixian = re.compile('^提现$')
示例#5
0
class MediaJd:
    def __init__(self, bot):
        if config.get('SYS', 'jd') == 'yes':
            self.se = requests.session()
            self.start_keep_cookie_thread()
            self.load_cookies()
            self.ort = Orther()
            self.tu = tuling()
            self.logger = my_utils.init_logger()

    # 启动一个线程,定时访问京东主页,防止cookie失效
    def start_keep_cookie_thread(self):
        t = Thread(target=self.visit_main_url, args=())
        t.setDaemon(True)
        t.start()

    def getJd(self, raw, bot, msg, good_url):
        if config.get('SYS', 'jd') == 'no':
            text = '''
一一一一系统信息一一一一

亲,暂不支持京东链接哦
                    '''
            return text

        cm = ConnectMysql()
        try:
            # 用户第一次查询,修改备注
            query_good = cm.ExecQuery("SELECT * FROM taojin_query_record WHERE puid='"+raw.sender.puid+"' AND bot_puid='"+bot.self.puid+"'")
            if query_good == ():
                se = re.compile('^(\d+)_(\d+)_\w_(\d)+$')
                if se.search(raw.sender.remark_name) == None:
                    remarkName = self.ort.generateRemarkName(bot)
                    split_arr2 = remarkName.split('_')
                    new_remark_name2 = '%s%s%s%s%s%s%s' % (split_arr2[0], '_', split_arr2[1], '_', 'B', '_', split_arr2[3])
                    bot.core.set_alias(userName=raw.sender.user_name, alias=new_remark_name2)
                    cm.ExecNonQuery("UPDATE taojin_user_info SET remarkname = '"+new_remark_name2+"' WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "'")
                else:
                    split_arr = raw.sender.remark_name.split('_')
                    new_remark_name = '%s%s%s%s%s%s%s' % (split_arr[0], '_', split_arr[1], '_', 'B', '_', split_arr[3])
                    bot.core.set_alias(userName=raw.sender.user_name, alias=new_remark_name)

                    cm.ExecNonQuery("UPDATE taojin_user_info SET remarkname = '"+new_remark_name+"' WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "'")

            print('开始查询分享商品的信息......'+msg['Text'])

            bot_puid = bot.self.puid

            sku_arr = good_url.split('https://item.m.jd.com/product/')

            if sku_arr == None:
                if config.get('SYS', 'tl') == 'yes':
                    msg_text = self.tu.tuling(msg)
                    return msg_text
                else:
                    return

            sku = sku_arr[1].split('.')
            res = self.get_good_link(sku[0])

            if res['data']['shotCouponUrl'] == '':
                text = '''
一一一一京东返利信息一一一一

【商品名】%s

【京东价】%s元
【返红包】%s元
 返利链接:%s

获取返红包步骤:
1,点击商品链接并进行下单
2,下完单后复制订单号发给我
                    ''' % (res['logTitle'], res['logUnitPrice'], res['rebate'], res['data']['shotUrl'])

                insert_sql = "INSERT INTO taojin_query_record(wx_bot, good_title, good_price, good_coupon, username, create_time, puid, bot_puid, skuid, type) VALUES('"+ bot.self.nick_name +"', '" + \
                             res['logTitle'] + "', '" + str(res['logUnitPrice']) + "', '0', '" + raw.sender.nick_name + "', '" + str(time.time()) + "', '"+ raw.sender.puid +"', '"+ bot_puid +"', '"+ res['skuid'] +"', '1')"
                cm.ExecNonQuery(insert_sql)
                return text
            else:
                text = '''
一一一一京东返利信息一一一一

【商品名】%s

【京东价】%s元
【优惠券】%s元
【券后价】%s元
【返红包】%s元
 领券链接:%s

获取返红包步骤:
1,复制本条消息打开淘宝领券
2,下完单后复制订单号发给我
                    ''' % (
                res['logTitle'], res['logUnitPrice'], res['youhuiquan_price'], res['coupon_price'], res['rebate'],
                res['data']['shotCouponUrl'])

                insert_sql = "INSERT INTO taojin_query_record(wx_bot, good_title, good_price, good_coupon, username, create_time, puid, bot_puid, skuid, type) VALUES('"+ bot.self.nick_name +"', '" + \
                             res['logTitle'] + "', '" + str(res['logUnitPrice']) + "', '" + res['coupon_price2'] + "', '" + raw.sender.nick_name + "', '" + str(time.time()) + "', '"+ raw.sender.puid +"', '"+ bot_puid +"', '"+ res['skuid'] +"', '1')"
                cm.ExecNonQuery(insert_sql)

                return text
        except Exception as e:
            trace = traceback.format_exc()
            self.logger.warning("error:{},trace:{}".format(str(e), trace))
            text = '''
一一一一 返利信息 一一一一

亲,当前商品暂无优惠券,建议您换一个商品试试呢,您也可以在下边的优惠券商城中查找哦

京东优惠券商城:
'''+config.get('URL', 'jdshop')+'''
淘宝优惠券商城:
'''+config.get('URL', 'tbshop')+'''
邀请好友得返利说明:
'''+config.get('URL', 'lnvit')+'''
                            '''
            return text

    def getGroupJd(self, bot, msg, good_url, raw):
        if config.get('SYS', 'jd') == 'no':
            text = '''
一一一一系统信息一一一一

亲,暂不支持京东链接
                    '''
            return text
        cm = ConnectMysql()
        try:
            wei_info = bot.core.search_chatrooms(userName=msg['FromUserName'])
            puid = raw.member.puid
            bot_puid = bot.self.puid
            sku_arr = good_url.split('https://item.m.jd.com/product/')
            if sku_arr == None:
                return

            sku = sku_arr[1].split('.')
            res = self.get_good_link(sku[0])
            if res['data']['shotCouponUrl'] == '':
                text = '''
一一一一京东返利信息一一一一

【商品名】%s

【京东价】%s元
【返红包】%s元
 返利链接:%s

获取返红包步骤:
1,点击商品链接并进行下单
2,点击头像添加机器人好友
3,下完单后复制订单号发给我
                            ''' % (res['logTitle'], res['logUnitPrice'], res['rebate'], res['data']['shotUrl'])

                insert_sql = "INSERT INTO taojin_query_record(wx_bot, good_title, good_price, good_coupon, username, create_time, puid, bot_puid, chatroom, skuid, type) VALUES('"+ bot.self.nick_name +"', '" + \
                             res['logTitle'] + "', '" + str(res['logUnitPrice']) + "', '0', '" + msg[
                                 'ActualNickName'] + "', '" + str(time.time()) + "', '"+ puid +"', '"+ bot_puid +"', '"+ wei_info['NickName'] +"', '"+ res['skuid'] +"', '1')"
                cm.ExecNonQuery(insert_sql)
                return text
            else:
                text = '''
一一一一京东返利信息一一一一

【商品名】%s

【京东价】%s元
【优惠券】%s元
【券后价】%s元
【返红包】%s元
 领券链接:%s

获取返红包步骤:
1,复制本条消息打开淘宝领券
2,点击头像添加机器人好友
3,下完单后复制订单号发给我
                                    ''' % (
                    res['logTitle'], res['logUnitPrice'], res['youhuiquan_price'], res['coupon_price'], res['rebate'],
                    res['data']['shotCouponUrl'])

                insert_sql = "INSERT INTO taojin_query_record(wx_bot, good_title, good_price, good_coupon, username, create_time, puid, bot_puid, chatroom, skuid, type) VALUES('"+ bot.self.nick_name +"', '" + \
                             res['logTitle'] + "', '" + str(res['logUnitPrice']) + "', '" + res['coupon_price2'] + "', '" + \
                             msg['ActualNickName'] + "', '" + str(time.time()) + "', '"+ puid +"', '"+ bot_puid +"', '"+ wei_info['NickName'] +"', '"+ res['skuid'] +"', '1')"
                cm.ExecNonQuery(insert_sql)
                return text
        except Exception as e:
            text = '''
一一一一 返利信息 一一一一

亲,当前商品暂无优惠券,建议您换一个商品试试呢,您也可以在下边的优惠券商城中查找哦

京东优惠券商城:
'''+config.get('URL', 'jdshop')+'''
淘宝优惠券商城:
'''+config.get('URL', 'tbshop')+'''
邀请好友得返利说明:
'''+config.get('URL', 'lnvit')+'''
                            '''
            return text

    def visit_main_url(self):
        self.load_cookies()
        url = "https://media.jd.com/gotoadv/goods?searchId=2011016742%23%23%23st1%23%23%23kt1%23%23%23598e10defb7f41debe6af038e875b61c&pageIndex=&pageSize=50&property=&sort=&goodsView=&adownerType=&pcRate=&wlRate=&category1=&category=&category3=&condition=0&fromPrice=&toPrice=&dataFlag=0&keyword=10960504678&input_keyword=10960504678&price=PC"
        while True:
            time.sleep(60 * 3)
            try:
                # 搜索商品
                res = self.se.get(url)
                # 使用BeautifulSoup解析HTML,并提取属性数据
                soup = BeautifulSoup(res.text, 'lxml')
                a = soup.select('.extension-btn')
                if not len(a):
                    print('京东登录失效 正在重新登录京东')
                    self.login()
            except Exception as e:
                self.login()
                trace = traceback.format_exc()
                print("error:{},trace:{}  京东登录失效 正在重新登录京东".format(str(e), trace))

    def check_login(self):

        self.load_cookies()

        url = 'https://media.jd.com/gotoadv/goods?pageSize=50'

        res = self.se.get(url)

        # 使用BeautifulSoup解析HTML,并提取登录属性,判断登录是否失效
        soup = BeautifulSoup(res.text, 'lxml')

        login = soup.select('.tips')

        # 判断登录状态是否失效
        if len(login) > 0:
            return 'Login Failed'
        else:
            return 'Login Success'

    def do_login(self):
        if (sysstr == "Linux") or (sysstr == "Darwin"):
            firefoxOptions = webdriver.FirefoxOptions()

            firefoxOptions.set_headless()

            # 开启driver
            wd = webdriver.Firefox(firefox_options=firefoxOptions)
        else:
            wd = webdriver.Firefox()
        wd.get('https://passport.jd.com/common/loginPage?from=media&ReturnUrl=https%3A%2F%2Fmedia.jd.com%2FloginJump')
        # 输入账号密码
        wd.find_element_by_id('loginname').send_keys(config.get('JD', 'JD_USERNAME'))
        # 休息3秒
        time.sleep(3)
        # 输入密码
        wd.find_element_by_id('nloginpwd').send_keys(config.get('JD', 'JD_PASSWORD'))
        # 点击登录按钮
        time.sleep(10)
        wd.find_element_by_id('paipaiLoginSubmit').click()
        # 获取cookie并写入文件
        cookies = wd.get_cookies()
        # 写入Cookies文件
        with open(cookie_fname, 'w') as f:
            f.write(json.dumps(cookies))
        time.sleep(5)
        wd.quit()


        return 'Login Success'

    def login(self):
        clr = self.check_login()
        if 'Login Success' in clr:
            print('京东已登录!不需要再次登录!')
            return 'Login Success'
        else:
            self.do_login()

    def load_cookies(self):
        if os.path.isfile(cookie_fname):
            with open(cookie_fname, 'r') as f:
                c_str = f.read().strip()
                self.set_cookies(c_str)

    def set_cookies(self, c_str):
        try:
            cookies = json.loads(c_str)
        except:
            return
        for c in cookies:
            self.se.cookies.set(c['name'], c['value'])

    def get_good_link(self, good_name):
        self.load_cookies()
        try:
            uu = "https://media.jd.com/gotoadv/goods?searchId=2011016742%23%23%23st1%23%23%23kt1%23%23%23598e10defb7f41debe6af038e875b61c&pageIndex=&pageSize=50&property=&sort=&goodsView=&adownerType=&pcRate=&wlRate=&category1=&category=&category3=&condition=0&fromPrice=&toPrice=&dataFlag=0&keyword=" + good_name + "&input_keyword=" + good_name + "&price=PC"
            # 搜索商品
            res = self.se.get(uu)
            # 使用BeautifulSoup解析HTML,并提取属性数据
            soup = BeautifulSoup(res.text, 'lxml')
            a = soup.select('.extension-btn')
            coupon = soup.find(attrs={'style':'color: #ff5400;'})
            coupon_price = 0;
            if coupon != None:
                coupon_text = coupon.string
                coupon_price = coupon_text.split('减')[1]

            request_id = soup.select('#requestId')

            str_onclick = a[0].get('onclick')

            string = str_onclick[13:-8]

            arr = string.split(',')

            dict_str = {}
            for item in arr:
                str = item.split('\':')
                str_b = str[0].split('\r\n')
                str_1 = str_b[1].strip()
                str_2 = str_1.split('\'')
                str_3 = str[1].split('\'')

                if len(str_3) >= 2:
                    dict_str[str_2[1]] = str_3[1]
                else:
                    dict_str[str_2[1]] = str_3[0]

            # 拼装FormData
            dict_str['adtType'] = 31
            dict_str['siteName'] = -1
            dict_str['unionWebId'] = -1
            dict_str['protocol'] = 1
            dict_str['codeType'] = 2
            dict_str['type'] = 1
            dict_str['positionId'] = 1194027498
            dict_str['positionName'] = '京推推推广位'
            dict_str['sizeId'] = -1
            dict_str['logSizeName'] = -1
            dict_str['unionAppId'] = -1
            dict_str['unionMediaId'] = -1
            dict_str['materialType'] = 1
            dict_str['orienPlanId'] = -1
            dict_str['landingPageType'] = -1
            dict_str['adOwner'] = 'z_0'
            dict_str['saler'] = -1
            dict_str['isApp'] = -1
            dict_str['actId'] = dict_str['materialId']
            dict_str['wareUrl'] = dict_str['pcDetails']
            dict_str['category'] = dict_str['logCategory']
            dict_str['requestId'] = request_id[0].get('value')

            # 删除多余的属性
            dict_str.pop('logCategory')
            dict_str.pop('pcDetails')
            dict_str.pop('mDetails')

            # 获取领券链接和下单链接
            good_link = self.se.post('https://media.jd.com/gotoadv/getCustomCodeURL', data=dict_str)

            good_text = json.loads(good_link.text)
            good_text['logTitle'] = dict_str['logTitle']
            good_text['logUnitPrice'] = dict_str['logUnitPrice']
            good_text['imgUrl'] = dict_str['imgUrl']
            good_text['skuid'] = dict_str['materialId']
            rebate = float(dict_str['pcComm']) / 100
            if coupon != None:
                good_text['coupon_price'] = round(float(good_text['logUnitPrice']) - int(coupon_price), 2)
                good_text['youhuiquan_price'] = coupon_price
                good_text['rebate'] = round(float(good_text['coupon_price']) * rebate * float(config.get('BN', 'bn3j')), 2)
            else:
                good_text['rebate'] = round(float(good_text['logUnitPrice']) * rebate * float(config.get('BN', 'bn3j')), 2)

            good_text['coupon_price2'] = coupon_price
            return good_text
        except Exception as e:
            trace = traceback.format_exc()
            self.logger.warning("error:{},trace:{}".format(str(e), trace))

    def get_good_info(self, bot):
        cm = ConnectMysql()
        self.load_cookies()
        page = 1
        sku_num = 0
        while sku_num < 20:
            url = "https://media.jd.com/gotoadv/goods?searchId=2011005331%23%23%23st3%23%23%23kt0%23%23%2378dc30b6-fa14-4c67-900c-235b129ab4bb&pageIndex="+str(page)+"&pageSize=50&property=&sort=&goodsView=&adownerType=&pcRate=&wlRate=&category1=&category=&category3=&condition=1&fromPrice=&toPrice=&dataFlag=0&keyword=&input_keyword=&hasCoupon=1&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC&price=PC"
            page += 1
            self.logger.debug(page)
            res = self.se.get(url)
            soup = BeautifulSoup(res.text, 'lxml')
            skuList = []
            for li in soup.find_all('li', skuid = re.compile('^[0-9]+$')):
                sku = li.get('skuid')

                exists_sql = "SELECT * FROM taojin_good_info WHERE skuid='"+str(sku)+"' AND bot_puid='"+ bot.self.puid +"';"
                is_exists = cm.ExecQuery(exists_sql)
                if len(is_exists) != 0:
                    print('0....')
                    continue

                sku_num += 1
                skuList.append(sku)

            if skuList == []:
                print('[]....')
                continue

            for item in skuList:
                link_info = self.get_good_link(str(item))
                # item_image = link_info['data']['qRcode']
                item_image = link_info['imgUrl']
                # 请求图片
                res_img = requests.get(item_image)
                img_name = item_image.split('/')
                # 拼接图片名
                file_name = "images/" + img_name[-1]
                fp = open(file_name, 'wb')
                # 写入图片
                fp.write(res_img.content)
                fp.close()
                if link_info['data']['shotCouponUrl'] == '':
                    continue
                else:
                    sql = "INSERT INTO taojin_good_info(wx_bot, skuid, title, image, price, rebate, yhq_price, coupon_price, shoturl, shotcouponurl, status, create_time, bot_puid) VALUES('"+ bot.self.nick_name +"', '" + str(
                        item) + "', '" + str(link_info['logTitle']) + "', '" + str(item_image) + "', '" + str(
                        link_info['logUnitPrice']) + "', '" + str(link_info['rebate']) + "', '" + str(
                        link_info['youhuiquan_price']) + "', '" + str(link_info['coupon_price']) + "', '" + str(
                        link_info['data']['shotUrl']) + "', '" + str(
                        link_info['data']['shotCouponUrl']) + "', '1', '" + str(time.time()) + "', '"+ bot.self.puid +"')"

                cm.ExecNonQuery(sql)

        print("insert success!")

    def get_jd_order(self, bot, msg, orderId, userInfo, puid, raw):
        # try:
        order_id = int(orderId)
        timestr = str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
        cm = ConnectMysql()

        # 查询订单是否已经提现过了
        check_order_sql = "SELECT * FROM taojin_order WHERE order_id='" + str(order_id) + "' AND bot_puid='"+ bot.self.puid +"' AND puid='"+puid+"';"
        check_order_res = cm.ExecQuery(check_order_sql)

        # 判断该订单是否已经提现
        if len(check_order_res) >= 1:
            cm.Close()
            sendtext = '''
一一一一 订单消息 一一一一

订单【%s】提交成功,请勿重复提交
                        ''' % (order_id)
            return sendtext

        cm.ExecNonQuery("INSERT INTO taojin_order(wx_bot, username, order_id, completion_time, order_source, puid, bot_puid, status) VALUES('"+ str(bot.self.nick_name) +"', '" + str(userInfo['NickName']) + "', '" + str(order_id) + "', '" + str(timestr) + "', '2', '"+puid+"', '"+ bot.self.puid +"', '1')")

        send_text ='''
一一一一 订单消息 一一一一

订单【%s】提交成功,请耐心等待订单结算
结算成功后机器人将自动返利到您个人账户
        ''' % (order_id)
        return send_text
示例#6
0
class TextMessage:
    def __init__(self, bot):
        self.tu = tuling.tuling()
        self.mjd = mediaJd.MediaJd(bot)
        self.logger = my_utils.init_logger()
        self.al = alimama.Alimama(self.logger, bot)
        self.ort = Orther()
        self.pdd = pingdd.Pdd(bot)
        self.movie = movie.SharMovie()

    def is_valid_date(self, str):
        try:
            time.strptime(str, "%Y-%m-%d")
            return True
        except:
            return False

    def getText(self, raw, bot, msg):
        wei_info = bot.core.search_friends(userName=msg['FromUserName'])
        patternURL = re.compile('^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+')

        pattern_bz = re.compile('^帮助$')
        pattern_profile = re.compile('^个人信息$')
        pattern_tixian = re.compile('^提现$')
        pattern_tuig = re.compile('^推广$')
        pattern_proxy = re.compile('^代理$')
        appect_friend = re.compile('^我通过了你的朋友验证请求,现在我们可以开始聊天了$')
        # 判断是否是URL链接
        if patternURL.search(msg['Text']) == None:

            pattern_s = re.compile('^搜')
            pattern_z = re.compile('^找')
            pattern_m = re.compile('^买')
            if (pattern_s.search(msg['Text']) != None) | (pattern_z.search(
                    msg['Text']) != None) | (pattern_m.search(msg['Text']) !=
                                             None):

                res = self.ort.ishaveuserinfo(bot, msg, raw)

                if res['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                jdurl = quote(config.get('URL', 'jdshopingurl') +
                              msg['Text'][1:],
                              safe='/:?=&')
                tburl = quote(config.get('URL', 'tbshopingurl') +
                              msg['Text'][1:],
                              safe='/:?=&')
                res1 = self.movie.getShortUrl(jdurl)
                res2 = self.movie.getShortUrl(tburl)
                print('WEEWEWEW', msg)
                text = '''
一一一一系统消息一一一一
亲,以下是【%s】优惠券集合

京东:%s
淘宝:%s
                ''' % (msg['Text'][1:], res1, res2)
                return text
            elif appect_friend.search(msg['Text']) != None:
                # 获取生成的备注
                ramerkName = self.ort.generateRemarkName(bot)
                self.logger.debug(ramerkName)
                # 修改备注
                bot.core.set_alias(userName=msg['FromUserName'],
                                   alias=ramerkName)
                # 被邀请人puid
                user_wxid = self.ort.getPuid(bot, msg['FromUserName'])
                self.ort.create_user_info(raw,
                                          bot,
                                          msg,
                                          lnivt_code=0,
                                          tool=True,
                                          wxid=user_wxid)
                text = '''
Hi~我是24h在线的淘小券机器人

    分享【京东商品】
    分享【淘口令】
    分享【拼多多商品】
    回复【互助】查看机器人指令

    精准查询全网内部优惠券哦,您也可以访问下边优惠券商城自主查询呢!
京东优惠券商城:
''' + config.get('URL', 'jdshop') + '''
淘宝优惠券商城:
''' + config.get('URL', 'tbshop') + '''
邀请好友得返利说明:
''' + config.get('URL', 'lnvit') + '''
                        '''
                return text
            elif ('你已添加了' in msg['Text']) and ('现在可以开始聊天了' in msg['Text']):
                arrstr = msg['Text'].split(',')
                str = arrstr[0][5:]
                self.logger.debug(str)
                user = bot.friends().search(str)[0]
                self.logger.debug(str, user)
                # 获取生成的备注
                ramerkName = self.ort.generateRemarkName(bot)
                self.logger.debug(ramerkName)
                # 修改备注
                bot.core.set_alias(nickName=user.user_name, alias=ramerkName)
                # 被邀请人puid
                user_wxid = user.puid
                self.ort.create_user_info(raw,
                                          bot,
                                          msg,
                                          lnivt_code=0,
                                          tool=True,
                                          wxid=user_wxid)
                text = '''
Hi~我是24h在线的淘小券机器人

    分享【京东商品】
    分享【淘口令】
    分享【拼多多商品】
    回复【互助】查看机器人指令
    
    精准查询全网内部优惠券哦,您也可以访问下边优惠券商城自主查询呢!
京东优惠券商城:
''' + config.get('URL', 'jdshop') + '''
淘宝优惠券商城:
''' + config.get('URL', 'tbshop') + '''
邀请好友得返利说明:
''' + config.get('URL', 'lnvit') + '''
                        '''
                return text
            elif pattern_bz.search(msg['Text']) != None:
                res = self.ort.ishaveuserinfo(bot, msg, raw)

                if res['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                # 帮助操作
                text = '''

Hi~我是24h在线的淘小券机器人,用淘小券,免费领取任意淘宝,天猫,京东,拼多多商品优惠券,好用的话记得分享给好友哦

回复【帮助】可查询指信息
回复【提现】申请账户余额提现
回复【推广】可申请机器人代理
回复【个人信息】可看个当前账户信息

回复【买+商品名称】
回复【找+商品名称】
回复【搜+商品名称】查看商品优惠券合集

分享【京东商品】
分享【淘宝淘口令】
分享【拼多多商品】
精准查询商品优惠券和返利信息!
分享【VIP视频链接】免费查看高清VIP视频!

优惠券使用教程:
http://t.cn/RnAKqWW
跑堂优惠券常见问题:
http://t.cn/RnAK1w0
免费看电影方法:
http://t.cn/RnAKMul
京东优惠券商城:
http://jdyhq.ptjob.net
淘宝优惠券商城:
http://xiaoquan.ptjob.net
邀请好友得返利说明:
http://t.cn/RnAKafe
            
                        '''
                return text
            elif pattern_tixian.search(msg['Text']) != None:

                cm = ConnectMysql()
                res = self.ort.ishaveuserinfo(bot, msg, raw)

                if res['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                select_user_sql = "SELECT * FROM taojin_user_info WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "';"
                select_user_res = cm.ExecQuery(select_user_sql)
                timestr = round(time.time())
                timestr2 = repr(timestr)
                # 设置提现门槛
                if float(select_user_res[0][9]) < int(
                        config.get('SYS', 'tixianprice')):
                    text2 = '''
一一一一 提现信息 一一一一

提现申请失败
当前账户余额为%s
最小提现金额为%s元!
                                                        ''' % (
                        select_user_res[0][9], config.get(
                            'SYS', 'tixianprice'))
                    return text2

                adminuser = bot.friends().search(
                    config.get('ADMIN', 'ADMIN_USER'))[0]
                if float(select_user_res[0][9]) > 0:
                    # 修改余额
                    update_sql = "UPDATE taojin_user_info SET withdrawals_amount='0', update_time='" + timestr2 + "' WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "';"
                    total_amount = float(select_user_res[0][6]) + float(
                        select_user_res[0][9])
                    update_total_sql = "UPDATE taojin_user_info SET total_rebate_amount='" + repr(
                        total_amount
                    ) + "',update_time='" + timestr2 + "' WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "';"
                    # 插入提现日志
                    insert_current_log_sql = "INSERT INTO taojin_current_log(wx_bot, username, amount, create_time, puid, bot_puid) VALUES('" + bot.self.nick_name + "', '" + wei_info[
                        'NickName'] + "', '" + repr(
                            select_user_res[0][9]
                        ) + "', '" + timestr2 + "', '" + raw.sender.puid + "', '" + bot.self.puid + "')"
                    to_admin_text = '''
一一一一 提现通知 一一一一

机器人:%s
提现人:%s
提现金额:%s元
提现时间:%s
                                        ''' % (
                        bot.self.nick_name, wei_info['NickName'],
                        select_user_res[0][9],
                        time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))

                    cm.ExecNonQuery(update_sql)
                    cm.ExecNonQuery(update_total_sql)
                    cm.ExecNonQuery(insert_current_log_sql)

                    to_user_text = '''
一一一一 提现信息 一一一一

恭喜你成功提现【%s】元
提现金额将以微信红包发放,请耐心等待
                                    ''' % (select_user_res[0][9])
                    adminuser.send(to_admin_text)
                    return to_user_text
                else:
                    text2 = '''
一一一一 提现信息 一一一一

提现申请失败,账户余额为0!
                                    '''
                    return text2
            elif pattern_profile.search(msg['Text']) != None:
                cm = ConnectMysql()
                res = self.ort.ishaveuserinfo(bot, msg, raw)
                if res['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                user_sql = "SELECT * FROM taojin_user_info WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "';"

                user_info = cm.ExecQuery(user_sql)

                current = "SELECT sum(amount) FROM taojin_current_log WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "';"

                current_info = cm.ExecQuery(current)

                # 如果总提现金额不存在,赋值为0
                if current_info[0][0] == None:
                    current_info = 0
                else:
                    current_info = current_info[0][0]
                text = '''
一一一一 个人信息 一一一一

总返利金额:%s元
京东返利金额:%s元
淘宝返利金额:%s元
拼多多返利金额:%s元
可提现余额:%s元
累计提现金额:%s元

累计订单量:%s
京东订单量:%s
淘宝订单量:%s
拼多多订单量:%s
总好友返利:%s
总好友个数:%s
                                    ''' % (
                    user_info[0][6], user_info[0][7], user_info[0][8],
                    user_info[0][25], user_info[0][9], current_info,
                    user_info[0][11], user_info[0][12], user_info[0][13],
                    user_info[0][26], user_info[0][19], user_info[0][20])
                cm.Close()
                return text
            elif pattern_tuig.search(msg['Text']) != None:
                cm = ConnectMysql()
                res = self.ort.ishaveuserinfo(bot, msg, raw)

                if res['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                user_sql = "SELECT * FROM taojin_user_info WHERE puid='" + raw.sender.puid + "' AND bot_puid='" + bot.self.puid + "';"

                cm.ExecQuery(user_sql)

                text = '''
一一一一 推广信息 一一一一

将机器人名片分享到群或者好友
好友添加机器人为好友
您和好友都将获取''' + config.get('BN', 'bn2') + '''元现金奖励
且您将永久享受好友返利10%提成
邀请好友得返利说明:
''' + config.get('URL', 'lnvit') + '''
                                '''
                return text
            elif pattern_proxy.search(msg['Text']) != None:
                res = self.ort.ishaveuserinfo(bot, msg, raw)

                if res['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)
                text = '''
一一一一系统消息一一一一

点击链接:''' + config.get('URL', 'proxy') + '''
添加好友备注:优惠券代理

客服人员将尽快和您取得联系,请耐心等待!
                        '''
                return text
            elif (msg['Text'].isdigit()) and (len(msg['Text']) == 11):

                res2 = self.ort.ishaveuserinfo(bot, msg, raw)

                if res2['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                res = self.mjd.get_jd_order(bot, msg, msg['Text'], wei_info,
                                            raw.sender.puid, raw)

                return res
            elif (msg['Text'].isdigit()) and (len(msg['Text']) == 18):
                res2 = self.ort.ishaveuserinfo(bot, msg, raw)
                if res2['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                res = self.al.order(msg['Text'], raw)

                return res
            elif ('-' in msg['Text']) and (len(msg['Text'].split('-')[1])
                                           == 15) and (len(msg['Text']) == 22):
                res2 = self.ort.ishaveuserinfo(bot, msg, raw)
                if res2['res'] == 'not_info':
                    self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                res = self.pdd.order_pdd(bot, msg, 123456, wei_info,
                                         raw.sender.puid, raw)

                return res
            else:
                if config.get('SYS', 'tl') == 'yes':
                    msg_text = self.tu.tuling(msg)
                    self.logger.debug(msg_text)
                    return msg_text
                else:
                    return
        else:
            res2 = self.ort.ishaveuserinfo(bot, msg, raw)

            if res2['res'] == 'not_info':
                self.ort.create_user_info(raw, bot, msg, 0, tool=False)

                self.mjd.getJd(raw, bot, msg, msg['Text'])

    def getGroupText(self, bot, msg):
        patternURL = re.compile('^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+')

        pattern_bz = re.compile('^帮助$')
        pattern_tuig = re.compile('^推广$')
        pattern_proxy = re.compile('^代理$')

        # 判断是否是URL链接
        if patternURL.search(msg['Text']) == None:

            pattern_s = re.compile('^搜')
            pattern_z = re.compile('^找')
            pattern_m = re.compile('^买')
            if (pattern_s.search(msg['Text']) != None) | (pattern_z.search(
                    msg['Text']) != None) | (pattern_m.search(msg['Text']) !=
                                             None):

                jdurl = quote("http://jdyhq.ptjob.net/?r=search?kw=" +
                              msg['Text'][1:],
                              safe='/:?=&')

                tburl = quote('http://xiaoquan.ptjob.net/index.php?kw=' +
                              msg['Text'][1:],
                              safe='/:?=&')
                res1 = self.movie.getShortUrl(jdurl)
                res2 = self.movie.getShortUrl(tburl)
                text = '''
一一一一系统消息一一一一

亲,以下是【%s】优惠券集合

京东:%s
淘宝:%s
                                ''' % (msg['Text'][1:], res1, res2)
                return text
            elif pattern_bz.search(msg['Text']) != None:
                # 帮助操作
                text = '''
一一一一 系统信息 一一一一

回复【帮助】可查询指信息
回复【提现】申请账户余额提现
回复【推广】可申请机器人代理
回复【个人信息】可看个当前账户信息

回复【买+商品名称】
回复【找+商品名称】
回复【搜+商品名称】查看商品优惠券合集

分享【京东商品链接】或者【淘口令】
精准查询商品优惠券和返利信息!
分享【VIP视频链接】免费查看高清VIP视频!

优惠券使用教程:
''' + config.get('URL', 'course') + '''
跑堂优惠券常见问题:
''' + config.get('URL', 'faq') + '''
免费看电影方法:
''' + config.get('URL', 'movie') + '''
京东优惠券商城:
''' + config.get('URL', 'jdshop') + '''
淘宝优惠券商城:
''' + config.get('URL', 'tbshop') + '''
邀请好友得返利说明:
''' + config.get('URL', 'lnvit') + '''
                        '''
                return text
            elif pattern_tuig.search(msg['Text']) != None:
                text = '''
一一一一 推广信息 一一一一

将机器人名片分享到群或者好友
好友添加机器人为好友
您和好友都将获取''' + config.get('BN', 'bn2') + '''元现金奖励
且您将永久享受好友返利10%提成
邀请好友得返利说明:
''' + config.get('URL', 'lnvit') + '''
                                '''
                return text
            elif pattern_proxy.search(msg['Text']) != None:
                text = '''
一一一一系统消息一一一一

点击链接:''' + config.get('URL', 'proxy') + '''
添加好友备注:跑堂优惠券代理

客服人员将尽快和您取得联系,请耐心等待!
                        '''
                return text
            else:
                return
        else:
            self.mjd.getGroupJd(bot, msg, msg['Text'])