Beispiel #1
0
 def test_setup_tracer(self):
     module = os.path.join(os.getcwd(), r'static_files\MavenProj')
     repo = Repo.Repo(module)
     expected_agent_path = os.path.join(repo.repo_dir, 'agent.jar')
     expected_paths_path = os.path.join(repo.repo_dir, 'paths.txt')
     repo.setup_tracer()
     self.assertTrue(os.path.isfile(expected_agent_path))
     self.assertTrue(os.path.isfile(expected_paths_path))
     with open(expected_paths_path, 'rb') as paths:
         lines = paths.readlines()
         self.assertEqual(
             lines[0].replace('\n', '').replace('\r', ''),
             os.path.join(os.environ['USERPROFILE'], r'.m2\repository'))
         self.assertEqual(lines[1], repo.repo_dir)
     with open(os.path.join(repo.repo_dir, 'pom.xml'), 'rb') as pom:
         lines = pom.readlines()
         self.assertTrue(
             '<argLine>-javaagent:{}={}</argLine>'.format(
                 expected_agent_path, expected_paths_path),
             os.path.join(os.environ['USERPROFILE'], r'.m2\repository'))
Beispiel #2
0
class WXAddUrgentContact:
    def __init__(self):
        self.repo = Repo()

    def action(self, d, z, args):
        z.heartbeat()
        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来
        z.sleep(9)
        d(text='我').click()
        d(text='设置').click()
        d(textContains='帐号与安全').click()
        d(text='应急联系人').click()
        d(className='android.widget.GridView').child(
            className='android.widget.ImageView').click()
        d(text='搜索').click()
        z.heartbeat()
        add_count = int(args['add_count'])
        cate_id = args["repo_material_id"]  # ------------------
        Material = self.repo.GetMaterial(cate_id, 0, add_count)
        for i in range(0, add_count, +1):
            if len(Material) == 0:
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                    % cate_id).communicate()
                z.sleep(10)
                return
            WXName = Material[i]['content']  # 从素材库取出的要发的材料
            z.input(WXName)
            z.heartbeat()
            d(className='android.widget.CheckBox').click()
        d(textContains='确定').click()
        d(text='完成').click()

        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
Beispiel #3
0
class WXPublicNum:
    def __init__(self):
        self.repo = Repo()

    def action(self, d, z, args):
        z.heartbeat()
        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来
        z.sleep(7)
        endIndex = int(args['EndIndex'])
        d(description='搜索').click()
        z.heartbeat()
        endCondition = 0
        while endCondition < endIndex:
            cate_id = args["repo_material_id"]  # ------------------
            Material = self.repo.GetMaterial(cate_id, 0, 1)
            if len(Material) == 0:
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                    % cate_id).communicate()
                z.sleep(10)
                return
            z.heartbeat()
            link = Material[0]['content']  # 从素材库取出的要发的材料
            z.input(link)
            d(className='android.widget.ListView').child(
                className='android.widget.LinearLayout',
                index=0).child(className='android.widget.RelativeLayout',
                               index=0).click()  #点击搜索
            if d(textContains='没有更多的').exists:
                endCondition = endCondition + 1
                d(description='清除').click()
                continue
        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
Beispiel #4
0
class WXBindMail:
    def __init__(self):
        self.repo = Repo()

    def action(self, d, z, args):
        z.heartbeat()
        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来
        z.sleep(7)
        d(text='我').click()
        d(text='设置').click()
        d(textContains='帐号与安全').click()
        d(text='邮件地址').click()
        z.heartbeat()
        if d(textContains='重新发送验证').exists:
            return
        if d(textContains='解绑').exists:
            return
        cate_id = int(args["repo_cate_id"])  # 得到取号码的仓库号

        Mail = self.repo.GetNumber(cate_id, 0, 1)  # 取出add_count条两小时内没有用过的号码
        if len(Mail) == 0:
            d.server.adb.cmd(
                "shell",
                "am broadcast -a com.zunyun.zime.toast --es msg \"第%s号号码仓库为空,等待中……\""
                % cate_id).communicate()
            z.sleep(10)
            return
        BindMail = Mail[0]['number']
        d(className='android.widget.EditText').set_text(BindMail)
        d(text='确定').click()
        z.heartbeat()

        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
Beispiel #5
0
 def test_change_surefire_ver_3(self):
     module = os.path.join(os.getcwd(), r'static_files\tika')
     repo = Repo.Repo(module)
     curr_wd = os.getcwd()
     os.chdir(module)
     os.system('git checkout d363b828bc6e714aa5f4ffedfbd1d09e1880f9ee -f')
     mvn_help_cmd = 'mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-surefire-plugin'
     excpected_version = '2.22.0'
     poms = repo.get_all_pom_paths(module)
     repo.change_surefire_ver(excpected_version, module)
     self.assertTrue(len(poms) > 0)
     for pom in poms:
         print('#### checking ' + pom + ' ######')
         if (os.path.normcase(
                 os.path.join(
                     os.getcwd(),
                     r'tika-dotnet\pom.xml')) == os.path.normcase(pom)):
             print('#### passing ' + pom + ' ######')
             continue
         module_path = os.path.abspath(os.path.join(pom, os.pardir))
         with os.popen(mvn_help_cmd + ' -f ' + module_path) as proc:
             tmp_file_path = 'tmp_file.txt'
             with open(tmp_file_path, "w+") as tmp_file:
                 duplicate_stdout(proc, tmp_file)
             with open(tmp_file_path, "r") as tmp_file:
                 duplicate_stdout(proc, tmp_file)
                 build_report = tmp_file.readlines()
             version_line_sing = list(
                 filter(lambda l: l.startswith('Version: '), build_report))
             assert len(version_line_sing) == 1
             version_line = version_line_sing[0]
             self.assertEqual(
                 version_line.lstrip('Version: ').rstrip('\n'),
                 excpected_version)
     os.system('git checkout HEAD -f')
     os.chdir(curr_wd)
Beispiel #6
0
class WXAssignSearchHello:

    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath(__file__)

    def action(self, d,z, args):
        z.toast( "正在ping网络是否通畅" )
        while True:
            ping = d.server.adb.cmd( "shell", "ping -c 3 baidu.com" ).communicate( )
            print(ping)
            if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                break
            z.sleep( 2 )

        z.toast( "开始执行:微信指定好友互聊" )
        run_time_min = int( args['run_time_min'] )
        run_time_max = int( args['run_time_max'] )
        run_time = float( random.randint( run_time_min, run_time_max ) ) * 60
        run_interval = z.getModuleRunInterval( self.mid )
        if run_interval is not None and run_interval < run_time:
            z.toast( u'模块在锁定时间内,无法运行' )
            z.sleep( 2 )
            return

        start_time = args['start_time']
        stop_time = args['stop_time']
        try:
            if self.repo.timeCompare(start_time, stop_time):
                z.toast('处于' + start_time + '~' + stop_time + '时间段内,模块不运行')
                z.sleep(2)
                return
        except:
            logging.exception( "exception" )
            z.toast( "输入时间格式有误" )
            return
Beispiel #7
0
class QQSafetyCenter:
    def __init__(self):
        self.repo = Repo()
        self.type = 'token'

    def GetUnique(self):
        nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        # 生成当前时间
        randomNum = random.randint(0, 1000)
        # 生成的随机整数n,其中0<=n<=100
        if randomNum <= 10:
            randomNum = str(00) + str(randomNum)
        uniqueNum = str(nowTime) + str(randomNum)
        return uniqueNum

    def Login(self, d, z, args):
        z.heartbeat()
        d.server.adb.cmd("shell",
                         "pm clear com.tencent.token").communicate()  # 清除缓存
        d.server.adb.cmd("shell",
                         "am start -n com.tencent.token/.ui.LogoActivity"
                         ).communicate()  # 拉起来
        z.sleep(6)

        z.heartbeat()
        if d(text='登录QQ,开启安全之旅 >').exists:
            d(resourceId='com.tencent.token:id/account_bind_eval_level').click(
            )
            z.sleep(0.5)

        if d(text='QQ登录').exists:
            d(text='QQ登录').click()
            z.sleep(8)

        z.heartbeat()
        cate_id = args["repo_cate_id"]
        time_limit = args['time_limit']
        numbers = self.repo.GetAccount(cate_id, time_limit, 1)
        while len(numbers) == 0:
            z.heartbeat()
            d.server.adb.cmd(
                "shell",
                "am broadcast -a com.zunyun.zime.toast --es msg \"QQ帐号库%s号仓库无%s分钟未用\""
                % (cate_id, time_limit)).communicate()
            z.sleep(2)
            return "none"

        sendSMS_URL = args["sms_url"]
        QQNumber = numbers[0]['number']  # 即将登陆的QQ号
        QQPassword = numbers[0]['password']
        z.sleep(1)

        d.click(120, 360)  # 点击输入帐号文本框
        z.input(QQNumber)
        z.sleep(1)

        d.click(120, 480)  # 点击输入密码文本框
        z.input(QQPassword)
        z.sleep(1)

        d.click(363, 593)  # 点击登陆按钮
        z.sleep(6)

        z.heartbeat()
        if d(description='请向右拖动滑块完成拼图').exists:
            z.toast("遇到安全验证,重新开始")
            return "again"

        while d(text='身份验证').exists:
            d(text='下一步').click()
            z.sleep(3)

            z.heartbeat()
            if d(text='请填写您收到的短信验证码:').exists:
                z.sleep(65)

                z.heartbeat()
                if d(text='请填写您收到的短信验证码:').exists:
                    return "again"

            if d(text='开启安全之旅').exists:
                d(text='开启安全之旅').click()
                z.sleep(3)

            if d(text='重试').exists:
                d(text='重试').click()
                return "again"

            if d(text='您的帐号安全有待加强').exists:
                return QQNumber

    def action(self, d, z, args):
        z.toast(u"开始:ping网络是否通畅")
        i = 0
        while i < 200:
            i += 1
            ping = d.server.adb.cmd("shell",
                                    "ping -c 3 baidu.com").communicate()
            print(ping)
            if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                z.toast(u"网络通畅。开始执行:QQ安全中心登陆备份模块")
                break
            z.sleep(2)

        if i > 200:
            z.toast(u"网络不通,请检查网络状态")
            return

        while True:
            z.heartbeat()
            z.generate_serial("com.tencent.token")  # 随机生成手机特征码
            z.toast(u"随机生成手机特征码")

            serial = d.server.adb.device_serial()
            self.slot = Slot(serial, self.type)
            self.slot.backupToDisk("132132132")  # 设备信息,卡槽号,QQ号
            print "ok"
            break
Beispiel #8
0
 def __init__(self):
     self.type = 'mobileqq'
     self.repo = Repo()
     self.slot = Slot('', self.type)
     self.logger = util.logger
Beispiel #9
0
 def __init__(self):
     self.repo = Repo()
     self.mid = os.path.realpath(__file__)
Beispiel #10
0
 def __init__(self):
     self.repo = Repo()
Beispiel #11
0
class AQYLogin:
    def __init__(self):
        self.repo = Repo()

    def action(self, d, z, args):
        cateId = args['number_id']

        d.server.adb.cmd("shell",
                         "pm clear com.qiyi.video").communicate()  # 清除缓存
        d.server.adb.cmd(
            "shell",
            "am start -n com.qiyi.video/org.qiyi.android.video.MainActivity"
        ).communicate()  # main拉起

        wait = 1
        while wait == 1:  # 判断仓库是否有东西
            try:
                numbers = self.repo.GetAccount(cateId, 120, 1)
                qqNumber = numbers[0]['number']  # 即将登陆的QQ号
                wait = 0
            except Exception:
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"仓库为空,没有取到号码\""
                )
                time.sleep(5)
        qqPassword = numbers[0]['password']

        while 1:
            time.sleep(1)
            if d(text='我的', className='android.widget.RadioButton').exists:
                break

        d(text='我的', className='android.widget.RadioButton').click()
        d(text='我的', className='android.widget.RadioButton').click()
        d(text='登录', className='android.widget.TextView').click()

        d(text='其他方式登录', className='android.widget.TextView').click()
        d(textContains='QQ', className='android.widget.TextView').click()

        while 1:
            time.sleep(1)
            if d(index=1, className='android.webkit.WebView').exists:
                break

        str = d.info  # 获取屏幕大小等信息
        height = str["displayHeight"]
        width = str["displayWidth"]
        d.click(width / 2, height * 121 / 444)
        z.input(qqNumber)
        d.click(270, height * 151 / 444)
        z.input(qqPassword)
        d.click(270, height * 401 / 888)

        time.sleep(4)
        if not d(text='绑定手机', className='android.widget.TextView').exists:
            self.heatCode(d, z)

        d.press("back")
        d.press("back")
        d(index=0, className='android.widget.RelativeLayout').child(
            index=1, className='android.widget.ImageView').click()
        d(text='通讯录', className='android.widget.TextView').click()

        while 1:
            time.sleep(1)
            if d(text='聊天', className='android.widget.TextView').exists:
                break

        self.scrollCell(d, z, args)

        if (args["time_delay"]):
            time.sleep(int(args["time_delay"]))

    def scrollCell(self, d, z, args):
        materialId = args["material_id"]

        info = d(index=3, className='android.widget.ListView').info
        bHeight = info["visibleBounds"]["bottom"] - info["visibleBounds"]["top"]
        bBottom = info["visibleBounds"]["bottom"]
        bWidth = info["visibleBounds"]["right"] - info["visibleBounds"]["left"]
        count = d(index=3,
                  className='android.widget.ListView').info['childCount']
        numberArr = []
        judge = True

        while judge == True:
            if judge == False:
                break
            for i in range(0, count):

                obj = d(index=3, className='android.widget.ListView').child(
                    index=i, className='android.widget.RelativeLayout')
                if obj.exists:
                    obj1 = obj.child(index=0,
                                     className='android.widget.TextView')
                    if obj1.exists:
                        text = obj1.info["text"]
                        if text in numberArr:
                            ok = 'ok'
                        else:
                            if text.isdigit():
                                numberArr.append(text)

                                if obj.child(
                                        text='聊天',
                                        className='android.widget.TextView'
                                ).exists:
                                    while 1:
                                        material = self.repo.GetMaterial(
                                            materialId, 0, 1)
                                        if len(material) == 0:
                                            d.server.adb.cmd(
                                                "shell",
                                                "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                                                % materialId).communicate()
                                            time.sleep(5)
                                        else:
                                            break
                                    message = material[0][
                                        'content']  # 取出验证消息的内容

                                    obj.child(
                                        text='聊天',
                                        className='android.widget.TextView'
                                    ).click()
                                    d(index=0,
                                      className='android.widget.EditText'
                                      ).click()
                                    z.input(message)
                                    d(text='发送',
                                      className='android.widget.TextView'
                                      ).click()
                                    d(text='返回',
                                      className='android.widget.TextView'
                                      ).click()
                                    print text

                    if count == i + 1:
                        time.sleep(1)
                        d.swipe(bWidth / 2, bHeight, bWidth / 2, 0)
                        nstr = d(index=3,
                                 className='android.widget.ListView').child(
                                     index=i,
                                     className='android.widget.RelativeLayout'
                                 ).child(index=0,
                                         className='android.widget.TextView')
                        if nstr.exists:
                            nstr = nstr.info["text"]
                            if nstr == numberArr[-1]:
                                judge = 'False'
                                break

                else:
                    if i == 0:
                        continue
                    else:
                        judge = 'False'
                        break

    def GetUnique(self):
        nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        # 生成当前时间
        randomNum = random.randint(0, 1000)
        # 生成的随机整数n,其中0<=n<=100
        if randomNum <= 10:
            randomNum = str(00) + str(randomNum)
        uniqueNum = str(nowTime) + str(randomNum)
        return uniqueNum

    def heatCode(self, d, z):
        base_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.path.pardir, "tmp"))
        if not os.path.isdir(base_dir):
            os.mkdir(base_dir)
        sourcePng = os.path.join(base_dir, "%s_s.png" % (self.GetUnique()))
        codePng = os.path.join(base_dir, "%s_c.png" % (self.GetUnique()))

        if 1:  # 需要验证码的情况
            co = RClient()
            im_id = ""
            for i in range(0, 30, +1):  # 打码循环
                if i > 0:
                    co.rk_report_error(im_id)
                str = d.info  # 获取屏幕大小等信息
                height = str["displayHeight"]
                width = str["displayWidth"]
                left = width * 31 / 540  # 验证码的位置信息
                top = height * 249 / 888
                right = width * 271 / 540
                bottom = height * 348 / 888

                d.screenshot(sourcePng)  # 截取整个输入验证码时的屏幕

                img = Image.open(sourcePng)
                box = (left, top, right, bottom)  # left top right bottom
                region = img.crop(box)  # 截取验证码的图片

                img = Image.new('RGBA', (right - left, bottom - top))
                img.paste(region, (0, 0))

                img.save(codePng)
                im = open(codePng, 'rb').read()

                codeResult = co.rk_create(im, 3040)
                code = codeResult["Result"]
                im_id = codeResult["Id"]
                os.remove(sourcePng)
                os.remove(codePng)

                d.click(width * 391 / 540, height * 298 / 888)
                z.input(code)
                time.sleep(1)
                d.click(width / 2, height * 456.5 / 888)
                time.sleep(4)
                if d(text='绑定手机', className='android.widget.TextView').exists:
                    break
Beispiel #12
0
class MMCQQCardParise2:
    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath( __file__ )

    def GetUnique(self):
        nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S");  # 生成当前时间
        randomNum = random.randint(0, 1000);  # 生成的随机整数n,其中0<=n<=100
        if randomNum <= 10:
            randomNum = str(00) + str(randomNum);
        uniqueNum = str(nowTime) + str(randomNum);
        return uniqueNum


    def action(self, d, z,args):
        startTime = args["startTime"]
        endTime = args["endTime"]
        try:
            if self.repo.timeCompare( startTime, endTime ):
                z.toast( "该时间段不允许运行" )
                return
        except:
            z.toast( "输入的时间格式错误,请检查后再试" )
            return
        set_timeStart = int( args['set_timeStart'] )  # 得到设定的时间
        set_timeEnd = int( args["set_timeEnd"] )
        run_time = float( random.randint( set_timeStart, set_timeEnd ) )
        run_interval = z.getModuleRunInterval( self.mid )
        if run_interval is not None and run_interval < run_time:
            z.toast( u'锁定时间还差:%d分钟' % int( run_time - run_interval ) )
            z.sleep( 2 )
            return
        z.toast( "准备执行MMS版QQ名片名片点赞模块无锁" )
        z.sleep( 1 )
        z.toast( "正在ping网络是否通畅" )
        z.heartbeat( )
        i = 0
        while i < 200:
            i += 1
            ping = d.server.adb.cmd( "shell", "ping -c 3 baidu.com" ).communicate( )
            print( ping )
            if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                z.toast( "网络通畅。开始执行:MMS版QQ名片名片点赞模块无锁" )
                break
            z.sleep( 2 )
        if i > 200:
            z.toast( "网络不通,请检查网络状态" )
            if (args["time_delay"]):
                z.sleep( int( args["time_delay"] ) )
            return
        # self.scode = smsCode( d.server.adb.device_serial( ) )
        z.heartbeat( )
        d.server.adb.cmd( "shell", "am force-stop com.tencent.mobileqq" ).communicate( )  # 强制停止
        d.server.adb.cmd( "shell",
                          "am start -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity" ).communicate( )  # 拉起来
        z.sleep( 10 )
        z.heartbeat( )
        if d( text="消息", resourceId="com.tencent.mobileqq:id/ivTitleName", className="android.widget.TextView" ).exists:
            z.toast( "登录状态正常" )
        elif d( text='绑定手机号码' ).exists:
            while d( text='关闭' ).exists:
                d( text='关闭' ).click( )
                z.sleep( 0.5 )
            z.sleep( 1 )
        elif d( text='主题装扮' ).exists:
            while d( text='关闭' ).exists:
                d( text='关闭' ).click( )
                z.sleep( 0.5 )
        elif d( text='马上绑定' ).exists:
            while d( text='关闭' ).exists:
                d( text='关闭' ).click( )
                z.sleep( 0.5 )
        else:
            z.toast( "登录状态异常,停止模块" )
            now = datetime.datetime.now( )
            nowtime = now.strftime( '%Y-%m-%d %H:%M:%S' )  # 将日期转化为字符串 datetime => string
            z.setModuleLastRun( self.mid )
            z.toast( '模块结束,保存的时间是%s' % nowtime )
            return
        count = int( args['count'] )  # 要添加多少人
        i = 0
        switch = args["switch"]
        # time_limit1 = int( args["time_limit1"] )
        repo_number_cate_id = int( args["repo_number_cate_id"] )  # 得到取号码的仓库号
        click_count = int( args["click_count"] )
        flag = True
        while i < count :  # 总人数
            numbers = self.repo.GetNumber( repo_number_cate_id, 0, 1 )

            if len( numbers ) == 0:
                d.server.adb.cmd( "shell",
                                  "am broadcast -a com.zunyun.zime.toast --es msg \"QQ号码库%s号仓库为空,等待中\"" % repo_number_cate_id ).communicate( )
                z.sleep( 5 )
                now = datetime.datetime.now( )
                nowtime = now.strftime( '%Y-%m-%d %H:%M:%S' )  # 将日期转化为字符串 datetime => string
                z.setModuleLastRun( self.mid )
                z.toast( '模块结束,保存的时间是%s' % nowtime )
                return
            z.heartbeat( )
            QQnumber = numbers[0]['number']  # 即将点赞的QQ号
            print(QQnumber)
            z.sleep( 1 )

            z.cmd( "shell",
                   'am start -a android.intent.action.VIEW -d "mqqapi://card/show_pslcard?src_type=internal\&version=1\&uin=%s\&card_type=person\&source=qrcode"' % QQnumber )  # qq名片页面
            z.sleep( random.randint(5,7))
            if d( text='QQ', resourceId="android:id/text1" ).exists:
                z.heartbeat( )
                d( text='QQ', resourceId="android:id/text1" ).click( )
                z.sleep( 2 )
                z.heartbeat( )
                while d( text='仅此一次' ).exists:
                    z.heartbeat( )
                    d( text='仅此一次' ).click( )
            z.sleep( 1 )
            objtext = ''
            objtext1 = ""
            obj = d( descriptionContains="当前有" ).child( index=0,
                                                        className='android.widget.LinearLayout' ).child(
                index=1, className="android.widget.TextView" )
            if obj.exists:
                objtext1 = obj.info["text"].encode( "utf-8" )
                objtext = objtext1
            else:
                if switch =="跳过":
                    z.toast("这个获取不到点赞数,跳过")
                    continue
                obj = d( descriptionContains="当前有" )
                flag = False
            if click_count>=10:
                click_count = 10
            if obj.exists:
                # objtext = obj.info["text"].encode("utf-8")
                for j in range( 0, random.randint(1,5) ):
                    if d( descriptionContains="当前有" ).exists:
                        d( descriptionContains="当前有" ).click( )
                        z.sleep( 1 )
                        # d.dump( compressed=False )
                        if objtext != "":
                            objtext2 = d( descriptionContains="当前有" ).child( index=0,
                                                                             className='android.widget.LinearLayout' ).child(
                                index=1, className="android.widget.TextView" ).info["text"].encode( "utf-8" )
                            if objtext == objtext2:
                                z.toast( "今天无法继续赞了,停止模块" )
                                now = datetime.datetime.now( )
                                nowtime = now.strftime( '%Y-%m-%d %H:%M:%S' )  # 将日期转化为字符串 datetime => string
                                z.setModuleLastRun( self.mid )
                                z.toast( '模块结束,保存的时间是%s' % nowtime )
                                return
                            objtext = objtext2
                        else:
                            z.toast( "这个获取不到点赞数,跳过" )
                            continue
            else:
                z.toast( "对方拒绝赞" )
                continue

            if flag:
                z.cmd( "shell",'am start -a android.intent.action.VIEW -d "mqqapi://card/show_pslcard?src_type=internal\&version=1\&uin=%s\&card_type=person\&source=qrcode"' % QQnumber )  # qq名片页面
                z.sleep( random.randint( 5, 7 ) )
                if d( text='QQ', resourceId="android:id/text1" ).exists:
                    z.heartbeat( )
                    d( text='QQ', resourceId="android:id/text1" ).click( )
                    z.sleep( 2 )
                    z.heartbeat( )
                    while d( text='仅此一次' ).exists:
                        z.heartbeat( )
                        d( text='仅此一次' ).click( )
                z.sleep( 1 )
                if objtext1 == "":
                    z.toast( "这个获取不到点赞数,跳过" )
                    continue
                obj = d( descriptionContains="当前有" ).child( index=0,className='android.widget.LinearLayout' ).child(
                    index=1, className="android.widget.TextView" )
                if obj.exists:
                    objtext3 = obj.info["text"].encode( "utf-8" )
                    if int(objtext3)>int(objtext1):
                        z.toast("可以点赞")
                        i = i + 1
                    else:
                        z.toast("点赞无用")
                        break
                else:
                    z.toast( "这个获取不到点赞数,跳过" )
                    continue

        now = datetime.datetime.now( )
        nowtime = now.strftime( '%Y-%m-%d %H:%M:%S' )  # 将日期转化为字符串 datetime => string
        z.setModuleLastRun( self.mid )
        z.toast( '模块结束,保存的时间是%s' % nowtime )
        return
Beispiel #13
0
class WXDeleteChat:
    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath(__file__)

    def action(self, d, z, args):
        z.toast("正在ping网络是否通畅")
        while True:
            ping = d.server.adb.cmd("shell",
                                    "ping -c 3 baidu.com").communicate()
            print(ping)
            if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                break
            z.sleep(2)

        z.toast("开始执行:微信删除好友聊天")
        run_time_min = int(args['run_time_min'])
        run_time_max = int(args['run_time_max'])
        run_time = float(random.randint(run_time_min, run_time_max)) * 60
        run_interval = z.getModuleRunInterval(self.mid)
        if run_interval is not None and run_interval < run_time:
            z.toast(u'模块在锁定时间内,无法运行')
            z.sleep(2)
            return

        start_time = args['start_time']
        stop_time = args['stop_time']
        try:
            if self.repo.timeCompare(start_time, stop_time):
                z.toast('处于' + start_time + '~' + stop_time + '时间段内,模块不运行')
                z.sleep(2)
                return
        except:
            logging.exception("exception")
            z.toast("输入时间格式有误")
            return

        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来
        z.sleep(20)
        z.heartbeat()

        while True:
            if d(text='发现').exists and d(text='我').exists and d(
                    text='通讯录').exists:
                d(text='微信').click()
                break
            else:
                d(descriptionContains='返回',
                  className='android.widget.ImageView').click()
        z.sleep(2)
        i = 0
        while True:
            nearObj = d(className='android.widget.LinearLayout',
                        resourceId='com.tencent.mm:id/an5',
                        index=i)
            if nearObj.exists:
                nearObj.click()
                z.sleep(1.5)

                if d(textContains='(',
                     resourceId='com.tencent.mm:id/h2').exists:
                    d(descriptionContains='返回').click()

                elif d(className='android.widget.EditText').exists:
                    d(className='android.widget.EditText').click()
                    cate_id = args["repo_material_id"]
                    Material = self.repo.GetMaterial(cate_id, 0, 1)
                    if len(Material) == 0:
                        d.server.adb.cmd(
                            "shell",
                            "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,等待中……\""
                            % cate_id).communicate()
                        z.sleep(10)
                        return
                    message = Material[0]['content']  # 取出发送消息的内容
                    z.input(message)
                    z.sleep(1)
                    d(text='发送').click()
                    d(descriptionContains='返回').click()

                else:
                    d(descriptionContains='返回').click()

                z.sleep(1)
                nearObj = nearObj.child(
                    className='android.widget.RelativeLayout',
                    index=0).child(resourceId='com.tencent.mm:id/jw')
                nearObj.long_click()
                z.sleep(1)
                if d(text='删除该聊天').exists:
                    d(text='删除该聊天').click()
                z.sleep(2)
                if d(text='删除').exists:
                    d(text='删除').click()

                i = 0
            else:
                if i == 50:
                    break
                i += 1

        now = datetime.datetime.now()
        nowtime = now.strftime(
            '%Y-%m-%d %H:%M:%S')  # 将日期转化为字符串 datetime => string
        z.setModuleLastRun(self.mid)
        z.toast('模块结束,保存的时间是%s' % nowtime)
Beispiel #14
0
 def __init__(self):
     self.repo = Repo()
     self.xuma = XunMa()
Beispiel #15
0
class WeiXinNearByNotify:
    def __init__(self):
        self.repo = Repo()

    def action(self, d, z, args):
        z.heartbeat()
        str = d.info  # 获取屏幕大小等信息
        height = str["displayHeight"]
        width = str["displayWidth"]

        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来
        z.sleep(9)
        # if d(text='发现',index=1).exists:
        #     d(text='发现', index=1).click()
        # else:
        #     d(text='发现', index=0).click()
        # d(text='附近的人').click()
        # z.sleep(2)
        z.wx_action('opennearui')
        while d(textContains='正在查找').exists:
            z.sleep(3)
        z.heartbeat()
        if d(text='开始查看').exists:
            d(text='开始查看').click()
            if d(text='提示').exists:
                d(text='下次不提示').click()
                time.sleep(0.5)
                d(text='确定').click()
        if d(textContains='查看附近的人').exists:
            d(textContains='查看附近的人').click()
        z.sleep(3)
        z.heartbeat()
        d(description='更多').click()
        GenderFrom = args['gender']  # -------------------------------
        if GenderFrom != '不限':
            d(textContains=GenderFrom).click()
            while d(textContains='正在查找').exists:
                z.sleep(2)
        else:
            d(textContains='全部').click()
            while d(textContains='正在查找').exists:
                z.sleep(2)
        z.heartbeat()
        set1 = set()
        change = 0
        i = 1
        t = 1
        EndIndex = int(args['EndIndex'])  #------------------
        while t < EndIndex + 1:
            cate_id = args["repo_material_id"]  #------------------
            Material = self.repo.GetMaterial(cate_id, 0, 1)
            if len(Material) == 0:
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                    % cate_id).communicate()
                z.sleep(10)
                return
            message = Material[0]['content']  # 从素材库取出的要发的材料

            z.sleep(1)
            obj = d(className='android.widget.ListView').child(
                className='android.widget.LinearLayout',
                index=i).child(index=1).child(
                    className='android.widget.LinearLayout',
                    index=0).child(className='android.widget.TextView',
                                   index=0)  #得到微信名
            if obj.exists:
                z.heartbeat()
                change = 1
                obj = obj.info
                name = obj['text']
                if name in set1:  #判断是否已经给该人发过消息
                    i = i + 1
                    continue
                else:
                    set1.add(name)
                    print(name)
                d(className='android.widget.ListView',
                  index=0).child(className='android.widget.LinearLayout',
                                 index=i).child(
                                     className='android.widget.LinearLayout',
                                     index=1).click()  #点击第i个人

                z.sleep(1)
                if d(text='打招呼').exists:
                    d(text='打招呼').click()
                else:
                    d(description='返回').click()
                    i = i + 1
                    continue
                z.heartbeat()
                d(className='android.widget.EditText').click()
                z.input(message)  #----------------------------------------
                d(text='发送').click()
                z.sleep(1)
                # d(description='返回').click()
                d(description='返回').click()
                i = i + 1
                t = t + 1
                continue

            else:
                if change == 0:  #一次还没有点击到人
                    i = i + 1
                    continue
                else:
                    d.swipe(width / 2, height * 6 / 7, width / 2, height / 7)
                    z.sleep(2)
                    obj = d(className='android.widget.LinearLayout',
                            index=i - 1).child(index=1).child(
                                className='android.widget.TextView', index=0)
                    obj = obj.info
                    name1 = obj['text']  #判断是否已经到底
                    if name1 in set1:
                        return

                    i = 1
                    continue
        d(description='更多').click()
        d(text='清除位置并退出').click()
        d(text='确定').click()
        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
Beispiel #16
0
class TIMAddfriendsByNumber:
    def __init__(self):
        self.repo = Repo()

    def GetUnique(self):
        nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        # 生成当前时间
        randomNum = random.randint(0, 1000)
        # 生成的随机整数n,其中0<=n<=100
        if randomNum <= 10:
            randomNum = str(00) + str(randomNum)
        uniqueNum = str(nowTime) + str(randomNum)
        return uniqueNum

    def Gender(self, d, z):
        base_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.path.pardir, "tmp"))
        if not os.path.isdir(base_dir):
            os.mkdir(base_dir)
        sourcePng = os.path.join(base_dir, "%s_s.png" % (self.GetUnique()))
        obj = d(resourceId='com.tencent.tim:id/name',
                className='android.widget.ImageView')
        if obj.exists:
            z.heartbeat()
            obj = obj.info
            obj = obj['bounds']  # 验证码处的信息
            left = obj["left"]  # 验证码的位置信息
            top = obj['top']
            right = obj['right']
            bottom = obj['bottom']

            d.screenshot(sourcePng)  # 截取整个输入验证码时的屏幕

            img = Image.open(sourcePng)
            box = (left, top, right, bottom)  # left top right bottom
            region = img.crop(box)  # 截取验证码的图片
            # show(region)    #展示资料卡上的信息
            image = region.convert('RGBA')
            # 生成缩略图,减少计算量,减小cpu压力
            image.thumbnail((200, 200))
            max_score = None
            dominant_color = None
            for count, (r, g, b,
                        a) in image.getcolors(image.size[0] * image.size[1]):
                # 跳过纯黑色
                if a == 0:
                    continue
                saturation = colorsys.rgb_to_hsv(r / 255.0, g / 255.0,
                                                 b / 255.0)[1]
                y = min(
                    abs(r * 2104 + g * 4130 + b * 802 + 4096 + 131072) >> 13,
                    235)
                y = (y - 16.0) / (235 - 16)
                # 忽略高亮色
                if y > 0.9:
                    continue
                z.heartbeat()
                score = (saturation + 0.1) * count
                if score > max_score:
                    max_score = score
                    dominant_color = (r, g, b)
            # print("---------------------------------------------------------------------------")
            # print(dominant_color)
            z.heartbeat()
            if None == dominant_color:
                return '不限'
            red = dominant_color[0]
            blue = dominant_color[2]

            if red > blue:
                # print('女')
                return '女'
            else:
                # print('男')
                return '男'
        else:  # 没有基本资料的情况
            return '不限'

    def action(self, d, z, args):
        z.toast("准备执行TIM搜索加好友模块")
        z.sleep(1)
        # z.toast( "正在ping网络是否通畅" )
        # z.heartbeat( )
        # i = 0
        # while i < 200:
        #     i += 1
        #     ping = d.server.adb.cmd( "shell", "ping -c 3 baidu.com" ).communicate( )
        #     print( ping )
        #     if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
        #         z.toast( "网络通畅。开始执行:TIM加好友(搜索查找)" )
        #         break
        #     z.sleep( 2 )
        # if i > 200:
        #     z.toast( "网络不通,请检查网络状态" )
        #     if (args["time_delay"]):
        #         z.sleep( int( args["time_delay"] ) )
        #     return
        self.scode = smsCode(d.server.adb.device_serial())
        z.heartbeat()
        d.server.adb.cmd("shell",
                         "am force-stop com.tencent.tim").communicate()  # 强制停止
        d.server.adb.cmd(
            "shell",
            "am start -n com.tencent.tim/com.tencent.mobileqq.activity.SplashActivity"
        ).communicate()  # 拉起来
        z.sleep(8)
        z.heartbeat()

        if d(text="消息",
             resourceId="com.tencent.tim:id/ivTitleName").exists and not d(
                 text="马上绑定", className="android.widget.Button").exists:
            z.toast("登录状态正常,继续执行")
        else:
            if d(text="关闭",
                 resourceId="com.tencent.tim:id/ivTitleBtnLeftButton").exists:
                d(text="关闭",
                  resourceId="com.tencent.tim:id/ivTitleBtnLeftButton").click(
                  )
                z.sleep(1)
            elif d(text="消息",
                   className="android.widget.TextView").exists and d(
                       text="马上绑定", className="android.widget.Button").exists:
                d(text="消息", className="android.widget.TextView").click()
                z.sleep(1)
            elif d(text="返回").exists:
                d(text="返回").click()
                z.sleep(1)

            else:
                z.toast("登录状态异常,跳过此模块")
                return

        repo_material_cate_id = args["repo_material_cate_id"]  # 得到验证语的仓库号
        Material = self.repo.GetMaterial(repo_material_cate_id, 0, 1)
        switch_card = args["switch_card"]
        gender1 = args['gender']
        wait = 1  # 判断素材仓库里是否由素材
        while wait == 1:
            try:
                material = Material[0]['content']  # 取出验证消息的内容
                wait = 0
            except Exception:
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"仓库为空,没有取到验证消息\""
                )
        add_count = int(args['add_count'])  # 要添加多少人
        repo_number_cate_id = int(args["repo_number_cate_id"])  # 得到取号码的仓库号
        wait = 1
        while wait == 1:
            numbers = self.repo.GetNumber(repo_number_cate_id, 120,
                                          add_count)  # 取出add_count条两小时内没有用过的号码
            if "Error" in numbers:  #
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"仓库为空,没有取到号码\""
                )
                continue
            wait = 0
        # list = numbers # 将取出的号码保存到一个新的集合
        # num = list[0]['number']
        QQnumber = numbers[0]['number']
        z.sleep(1)
        z.heartbeat()
        d(resourceId='com.tencent.tim:id/name', description='快捷入口').click()
        z.heartbeat()
        z.sleep(1)
        if d(text='加好友', resourceId='com.tencent.tim:id/name').exists:
            d(text='加好友', resourceId='com.tencent.tim:id/name').click()
            z.heartbeat()
        else:
            z.heartbeat()
            d(resourceId='com.tencent.tim:id/name', description='快捷入口').click()
            z.heartbeat()
            d(text='加好友', resourceId='com.tencent.tim:id/name').click()
        z.sleep(1)
        z.heartbeat()
        if d(text='QQ号/手机号/群', resourceId='com.tencent.tim:id/name').exists:
            d(text='QQ号/手机号/群', resourceId='com.tencent.tim:id/name').click()
        # d(text='QQ号/手机号/群', resourceId='com.tencent.tim:id/et_search_keyword').click()
        z.heartbeat()
        # d(text='QQ号/手机号/群', resourceId='com.tencent.tim:id/et_search_keyword').set_text(QQnumber)  # 第一次添加的帐号 list[0]
        z.input(QQnumber)
        z.heartbeat()
        # d( text='搜索', resourceId='com.tencent.tim:id/btn_cancel_search' ).click( )
        if d(text="找人:", className="android.widget.TextView").exists:
            d(text="找人:", className="android.widget.TextView").click()
            z.sleep(3)
        count = 0
        while count < add_count:
            # numbers = list[0]
            repo_material_cate_id = args["repo_material_cate_id"]  # 得到验证语的仓库号
            Material = self.repo.GetMaterial(repo_material_cate_id, 0, 1)
            material = Material[0]['content']  # 得到验证语
            numbers = self.repo.GetNumber(repo_number_cate_id, 120,
                                          1)  # 取出两小时内没有用过的号码
            # list = numbers
            QQnumber = numbers[0]['number']
            z.heartbeat()
            time.sleep(1)
            if d(text='没有找到相关结果',
                 className='android.widget.TextView').exists:  #没有这个人的情况
                z.heartbeat()
                d(resourceId='com.tencent.tim:id/ib_clear_text',
                  description='清空').click()
                obj = d(text='QQ号/手机号/群',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(QQnumber)  # 下次要添加的号码
                obj = d(text='网络查找人',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(QQnumber)  # 下次要添加的号码
                if d(text="找人:", className="android.widget.TextView").exists:
                    d(text="找人:", className="android.widget.TextView").click()
                    z.sleep(3)
                time.sleep(1)
                continue
            time.sleep(2)
            if d(text="申请加群").exists:
                d(resourceId="com.tencent.tim:id/ivTitleBtnLeft",
                  description="返回按钮").click()
                d(resourceId='com.tencent.tim:id/ib_clear_text',
                  description='清空').click()
                obj = d(text='QQ号/手机号/群',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(QQnumber)  # 下次要添加的号码
                obj = d(text='网络查找人',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(QQnumber)  # 下次要添加的号码
                # d( text='搜索', resourceId='com.tencent.tim:id/btn_cancel_search' ).click( )
                if d(text="找人:", className="android.widget.TextView").exists:
                    d(text="找人:", className="android.widget.TextView").click()
                    z.sleep(3)
                time.sleep(1)
                continue
            z.sleep(2)
            if d(className='android.widget.AbsListView').child(
                    index=1,
                    resourceId='com.tencent.tim:id/name').exists:  #在同一查条件有多个人
                z.heartbeat()
                z.sleep(2)
                d(className='android.widget.AbsListView').child(
                    index=1, resourceId='com.tencent.tim:id/name').click()
                z.sleep(2)
            z.sleep(1)
            z.heartbeat()
            if gender1 != '不限':
                gender2 = self.Gender(d, z)
                z.heartbeat()
                if gender1 == gender2:  # gender1是外界设定的,gender2是读取到的
                    z.sleep(1)
                else:
                    d(text='返回',
                      resourceId='com.tencent.tim:id/ivTitleBtnLeft').click()
                    z.sleep(2)
                    d(resourceId='com.tencent.tim:id/ib_clear_text',
                      description='清空').click()
                    obj = d(text='QQ号/手机号/群',
                            resourceId='com.tencent.tim:id/et_search_keyword')
                    if obj.exists:
                        z.heartbeat()
                        z.sleep(2)
                        obj.set_text(
                            QQnumber)  # 要改为从库里取-------------------------------
                    obj = d(text='网络查找人',
                            resourceId='com.tencent.tim:id/et_search_keyword')
                    if obj.exists:
                        z.sleep(2)
                        obj.set_text(QQnumber)
                    if d(text="找人:",
                         className="android.widget.TextView").exists:
                        d(text="找人:",
                          className="android.widget.TextView").click()
                        z.sleep(3)
                    continue
            z.heartbeat()
            d(text='加好友', resourceId='com.tencent.tim:id/name').click()
            time.sleep(1)
            if d(text='加好友',
                 resourceId='com.tencent.tim:id/name').exists:  #拒绝被添加为好友的情况
                time.sleep(1)
                z.heartbeat()
                d(text='返回',
                  resourceId='com.tencent.tim:id/ivTitleBtnLeft').click()
                z.sleep(2)
                d(resourceId='com.tencent.tim:id/ib_clear_text',
                  description='清空').click()
                z.sleep(2)
                obj = d(text='QQ号/手机号/群',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(
                        QQnumber)  # 要改为从库里取------------------------------
                obj = d(text='网络查找人',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(QQnumber)
                time.sleep(1)
                if d(text="找人:", className="android.widget.TextView").exists:
                    d(text="找人:", className="android.widget.TextView").click()
                    z.sleep(3)
                continue
            time.sleep(2)
            if d(text="风险提示").exists:  #风险提示
                z.sleep(1)
                z.heartbeat()
                d(text="取消").click()
                z.sleep(1)
                d(text='返回',
                  resourceId='com.tencent.tim:id/ivTitleBtnLeft').click()
                z.sleep(2)
                d(resourceId='com.tencent.tim:id/ib_clear_text',
                  description='清空').click()
                obj = d(text='QQ号/手机号/群',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(
                        QQnumber)  # 要改为从库里取-------------------------------
                obj = d(text='网络查找人',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.sleep(2)
                    obj.set_text(QQnumber)
                if d(text="找人:", className="android.widget.TextView").exists:
                    d(text="找人:", className="android.widget.TextView").click()
                    z.sleep(3)
                continue
            if d(text='必填',
                 resourceId='com.tencent.tim:id/name').exists:  #要回答问题的情况
                z.heartbeat()
                z.sleep(2)
                d(text='返回',
                  resourceId='com.tencent.tim:id/ivTitleBtnLeft').click()
                time.sleep(1)
                z.heartbeat()
                d(text='返回',
                  resourceId='com.tencent.tim:id/ivTitleBtnLeft').click()
                z.sleep(2)
                d(resourceId='com.tencent.tim:id/ib_clear_text',
                  description='清空').click()
                obj = d(text='QQ号/手机号/群',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.sleep(2)
                    obj.set_text(QQnumber)  # 下次要添加的号码-
                obj = d(text='网络查找人',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    z.heartbeat()
                    z.sleep(2)
                    obj.set_text(QQnumber)
                time.sleep(1)
                if d(text="找人:", className="android.widget.TextView").exists:
                    d(text="找人:", className="android.widget.TextView").click()
                    z.sleep(3)
                continue
            time.sleep(1)
            z.heartbeat()
            obj = d(text='发送',
                    resourceId='com.tencent.tim:id/ivTitleBtnRightText'
                    )  #不需要验证可直接添加为好友的情况
            if obj.exists:
                z.sleep(2)
                obj.click()
                if d(text='添加失败,请勿频繁操作',
                     resourceId='com.tencent.tim:id/name').exists:
                    # z.sleep( 1 )
                    # z.heartbeat( )
                    # d( text="确定", className="android.widget.TextView" ).click( )
                    # z.sleep( 1 )
                    # z.heartbeat( )
                    # d( text="返回", className="android.widget.TextView" ).click( )
                    z.toast("频繁操作,跳出模块")
                    return
                else:
                    print(str(QQnumber) + "请求发送成功")
                    time.sleep(1)
                    d(text='返回',
                      resourceId='com.tencent.tim:id/ivTitleBtnLeft').click()
                    z.sleep(2)
                    d(resourceId='com.tencent.tim:id/ib_clear_text',
                      description='清空').click()
                    obj = d(text='QQ号/手机号/群',
                            resourceId='com.tencent.tim:id/et_search_keyword')
                    if obj.exists:
                        z.heartbeat()
                        z.sleep(2)
                        obj.set_text(
                            QQnumber)  # 要改为从库里取-------------------------------
                    obj = d(text='网络查找人',
                            resourceId='com.tencent.tim:id/et_search_keyword')
                    if obj.exists:
                        z.sleep(2)
                        obj.set_text(QQnumber)
                    if d(text="找人:",
                         className="android.widget.TextView").exists:
                        d(text="找人:",
                          className="android.widget.TextView").click()
                        z.sleep(3)
                    continue
            time.sleep(2)
            obj = d(className='android.widget.EditText',
                    resourceId='com.tencent.tim:id/name').info  #将之前消息框的内容删除
            obj = obj['text']
            lenth = len(obj)
            t = 0
            while t < lenth:
                d.press.delete()
                t = t + 1
            time.sleep(2)
            d(className='android.widget.EditText',
              resourceId='com.tencent.tim:id/name').click()  #发送验证消息  material
            z.input(material)
            if "是" in switch_card:
                if d(index=2,
                     className="android.widget.CompoundButton",
                     resourceId="com.tencent.tim:id/name").exists:
                    d(index=2,
                      className="android.widget.CompoundButton",
                      resourceId="com.tencent.tim:id/name").click()
                else:
                    if d(text="设置我的名片").exists:
                        d(text="设置我的名片").click()
                        while True:
                            z.sleep(3)
                            z.heartbeat()
                            d.dump(compressed=False)
                            if d(text="添加我的名片").exists:
                                d(text="添加我的名片").click()
                            d(index=3,
                              resourceId="com.tencent.tim:id/name",
                              className="android.widget.Button").click()
                            z.sleep(2)
                            obj = d(
                                index=0,
                                className="com.tencent.widget.GridView",
                                resourceId="com.tencent.tim:id/photo_list_gv"
                            ).child(index=0,
                                    className="android.widget.RelativeLayout")
                            if obj.exists:
                                z.sleep(1)
                                z.heartbeat()
                                obj.click()
                                z.sleep(3)
                                d(text='确定',
                                  resourceId='com.tencent.tim:id/name').click(
                                  )
                                time.sleep(3)
                                z.heartbeat()
                                d(text="完成").click()
                                z.sleep(1)
                                z.heartbeat()
                                d(text="返回").click()
                                break
                            if d(index=0,
                                 resourceId="com.tencent.tim:id/name",
                                 className="android.widget.ImageButton"
                                 ).exists:
                                d(index=0,
                                  resourceId="com.tencent.tim:id/name",
                                  className="android.widget.ImageButton"
                                  ).click()
                                d(text="退出").click()
            d(text='下一步',
              resourceId='com.tencent.tim:id/ivTitleBtnRightText').click()
            z.sleep(1)
            d(text='发送',
              resourceId='com.tencent.tim:id/ivTitleBtnRightText').click()
            print(str(QQnumber) + "请求发送成功")
            time.sleep(1)
            if d(text='添加失败,请勿频繁操作',
                 resourceId='com.tencent.tim:id/name').exists:
                # z.sleep( 1 )
                # z.heartbeat( )
                # d( text="确定", className="android.widget.TextView" ).click( )
                # z.sleep( 1 )
                # z.heartbeat( )
                # d( text="返回", className="android.widget.TextView" ).click( )
                z.toast("频繁操作,跳出模块")
                return
            z.sleep(1)
            d(text='返回',
              resourceId='com.tencent.tim:id/ivTitleBtnLeft').click()
            z.sleep(2)
            d(resourceId='com.tencent.tim:id/ib_clear_text',
              description='清空').click()
            z.sleep(1)
            count = count + 1
            if count < add_count:
                obj = d(text='QQ号/手机号/群',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    obj.click()

                    z.input(QQnumber)
                    z.sleep(2)
                obj = d(text='网络查找人',
                        resourceId='com.tencent.tim:id/et_search_keyword')
                if obj.exists:
                    obj.set_text(QQnumber)
                    z.sleep(1)
                if d(text="找人:", className="android.widget.TextView").exists:
                    d(text="找人:", className="android.widget.TextView").click()
                    z.sleep(3)
            else:
                z.sleep(2)
                z.heartbeat()
                d(text="取消", className="android.widget.Button").click()
                z.sleep(2)
                d(text="返回", className="android.widget.TextView").click()

            if count == add_count:
                print("模块已完成")
                z.toast("模块已完成")
                break
        if (args["time_delay"]):
            time.sleep(int(args["time_delay"]))
Beispiel #17
0
 def __init__(self):
     self.type = 'tim'
     self.repo = Repo()
class WXSearchAddFriendsByV1:
    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath(__file__)

    def action(self, d, z, args):
        run_time = float(args['run_time']) * 60
        run_interval = z.getModuleRunInterval(self.mid)
        if run_interval is not None and run_interval < run_time:
            z.toast(u'锁定时间还差:%d分钟' % int(run_time - run_interval))
            z.sleep(2)
            return

        z.heartbeat()

        count = 1
        while True:
            wayList = ['3', '6', '13', '15', '17', '18', '30', '39']

            if count > int(args['add_count']):
                z.toast(args['add_count'] + '个好友已加完')
                break

            cateId = args['repo_material_id']
            Material = self.repo.GetMaterial(cateId, 0, 1)
            if len(Material) == 0:
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                    % cate_id).communicate()
                z.sleep(10)
                return
            message = Material[0]['content']  # 从素材库取出的要发的材料
            z.sleep(1)

            cate_id = args['repo_number_id']
            infoList = self.repo.GetNumber(cate_id, 0, 1)
            if len(infoList) == 0:
                z.toast(cate_id + '号仓库为空,没有取到v1值')
                return
            v1 = infoList[0]['number']

            if args['add_friend_way'] == '随机':
                indexStr = choice(wayList)
            else:
                indexStr = args['add_friend_way']

            z.wx_openuser_v1(v1, indexStr)
            z.sleep(3)

            z.heartbeat()
            if d(text='添加到通讯录').exists:
                d(text='添加到通讯录').click()
                z.sleep(5)

            if d(text='发消息').exists:
                count = count + 1
                danshuang = '单向'

            if d(text='验证申请').exists:
                count = count + 1
                danshuang = '双向'
                deltext = d(className='android.widget.EditText',
                            index=1).info  # 将之前消息框的内容删除
                deltext = deltext['text']
                lenth = len(deltext)
                m = 0
                while m < lenth:
                    d.press.delete()
                    m = m + 1
                z.heartbeat()
                d(className='android.widget.EditText', index=1).click()
                z.input(message)
                z.sleep(2)

                d(text='发送').click()
                z.sleep(1)
                d(description='返回').click()

            if d(text='确定').exists:
                d(text='确定').click()

            para = {"x_05": danshuang, 'x_20': v1}
            self.repo.PostInformation(args["repo_information_id"], para)
            z.toast("%s入库完成")

            if d(descriptionContains='返回').exists:
                d(descriptionContains='返回').click()

            if (args["time_delay"]):
                z.sleep(int(args["time_delay"]))

        now = datetime.datetime.now()
        nowtime = now.strftime(
            '%Y-%m-%d %H:%M:%S')  # 将日期转化为字符串 datetime => string
        z.setModuleLastRun(self.mid)
        z.toast('模块结束,保存的时间是%s' % nowtime)
Beispiel #19
0
class WXHelloNearPeople:
    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath(__file__)

    def action(self, d, z, args):
        run_time = float(args['run_time']) * 60
        run_interval = z.getModuleRunInterval(self.mid)
        if run_interval is not None and run_interval < run_time:
            z.toast(u'锁定时间还差:%d分钟' % int(run_time - run_interval))
            z.sleep(2)
            return

        z.heartbeat()
        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来

        str = d.info  # 获取屏幕大小等信息
        height = str["displayHeight"]
        width = str["displayWidth"]
        z.sleep(7)

        while True:
            if d(text='发现').exists and d(text='我').exists and d(
                    text='通讯录').exists:
                break
            else:
                d(descriptionContains='返回',
                  className='android.widget.ImageView').click()

        z.sleep(2)
        for i in range(0, 2):
            d(text='发现').click()
            z.sleep(2)
        if d(text='附近的人').exists:
            d(text='附近的人').click()
            z.sleep(15)

        if d(textContains='开始查看').exists:
            d(textContains='开始查看').click()
            z.sleep(1.5)

        if d(textContains='提高微信定位精确度').exists:
            d(text='跳过').click()
            z.sleep(1.5)

        if d(textContains='下次不提示').exists:
            d(textContains='下次不提示').click()

        if d(text='确定').exists:
            d(text='确定').click()

        if d(textContains='补充个人信息').exists:
            d(text='女').click()
            d(textContains='地区').click()
            z.sleep(3)
            d(className='android.widget.LinearLayout',
              index=1).child(className='android.widget.ImageView',
                             index=0).click()
            z.sleep(1.5)
            d(text='下一步').click()

        if d(text='查看附近的人').exists:
            d(text='查看附近的人').click()
            z.sleep(3)

        # while True:
        #     v1List1 = z.wx_userList()
        #     endIndex1 = len(list(json.loads(v1List1)))
        #     if endIndex1 < 20:
        #         break
        #
        #     for j in range(0, endIndex1):
        #         v1_1 = list(json.loads(v1List1))[j]  # 将字符串改为list样式
        #         self.repo.uploadPhoneNumber(v1_1, args['repo_number_id'])

        # d( descriptionContains='更多' ).click( )
        # if d(text='附近打招呼的人').exists:
        #     d(text='附近打招呼的人').click()
        #     while True:
        #         HolleNearPeople = d(className='android.widget.ListView', index=0).child(className='android.view.View', index=0)
        #         if HolleNearPeople.exists:
        #             HolleNearPeople.click()
        #             z.sleep(2)
        #         else:
        #             d(descriptionContains='返回', className='android.widget.ImageView').click()
        #             break
        #         if d(text='通过验证').exists:
        #             d(text='通过验证').click()
        #             z.sleep(2)
        #             if d( text='完成' ).exists:
        #                 d( text='完成' ).click( )
        #                 z.sleep( 2 )
        #             d( descriptionContains='返回', className='android.widget.ImageView' ).click()
        #             z.sleep( 2 )
        #             if HolleNearPeople.exists:
        #                 HolleNearPeople.long_click( )
        #             z.sleep( 1.5 )
        #             if d( textContains='删除' ).exists:
        #                 d( textContains='删除' ).click( )
        #             continue
        #         else:
        #             d(descriptionContains='返回', className='android.widget.ImageView').click()
        #             z.sleep(2)
        #             if HolleNearPeople.exists:
        #                 HolleNearPeople.long_click()
        #             z.sleep(1.5)
        #             if d(textContains='删除').exists:
        #                 d(textContains='删除').click()
        #             continue

        d(descriptionContains='更多').click()
        gender = args['gender']
        if gender == '男':
            d(text='只看男生').click()
            z.sleep(3)
        elif gender == '女':
            d(text='只看女生').click()
            z.sleep(3)
        else:
            d(text='查看全部').click()
            z.sleep(3)

        # while True:
        #     v1List = z.wx_userList()
        #     endIndex = len(list(json.loads(v1List)))
        #     if endIndex < 20:
        #         break
        #
        #     for a in range(0, endIndex):
        #         v1 = list(json.loads(v1List))[a]  # 将字符串改为list样式
        #         self.repo.uploadPhoneNumber(v1, args['repo_number_id'])

        z.sleep(8)
        i = 0
        count = 0
        while True:
            count = count + 1
            if count > int(args['hello_count']):
                z.toast('已完成设置打招呼次数')
                break
            i = i + 1
            nearObj = d(className='android.widget.ListView',
                        index=0).child(className='android.widget.LinearLayout',
                                       index=i)
            if nearObj.exists:
                if d(textContains='朋友不够多').exists:
                    continue
                nearObj.click()
                if d(text='打招呼').exists:
                    d(text='打招呼').click()
                    z.sleep(2)
                if d(text='向TA说句话打个招呼').exists:
                    cate_id = args['repo_material_id']
                    Material = self.repo.GetMaterial(cate_id, 0, 1)
                    Msg = Material[0]['content']
                    z.input(Msg)
                    z.sleep(1.5)
                d(text='发送').click()
                z.sleep(3)
                d(descriptionContains='返回',
                  className='android.widget.ImageView').click()
                z.sleep(2)
            else:
                i = 1
                d.swipe(width / 2, height * 7 / 8, width / 2, height / 8)

        now = datetime.datetime.now()
        nowtime = now.strftime(
            '%Y-%m-%d %H:%M:%S')  # 将日期转化为字符串 datetime => string
        z.setModuleLastRun(self.mid)
        z.toast('模块结束,保存的时间是%s' % nowtime)
Beispiel #20
0
class WXAutoReplyMsg:
    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath(__file__)

    def action(self, d, z, args):
        run_time = float(args['run_time']) * 60
        run_interval = z.getModuleRunInterval(self.mid)
        if run_interval is not None and run_interval < run_time:
            z.toast(u'锁定时间还差:%d分钟' % int(run_time - run_interval))
            z.sleep(2)
            return

        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来
        z.sleep(7)

        msg_count = int(args['msg_count'])

        while True:
            if d(text='发现').exists and d(text='我').exists and d(
                    text='通讯录').exists:
                d(text='微信').click()
                break
            else:
                d(descriptionContains='返回',
                  className='android.widget.ImageView').click()
        z.sleep(2)
        if d(text='腾讯新闻').exists:
            d(text='腾讯新闻').long_click()
            z.sleep(2)
            if d(text='删除该聊天').exists:
                d(text='删除该聊天').click()

        if d(text='微信团队').exists:
            d(text='微信团队').long_click()
            z.sleep(2)
            if d(text='删除该聊天').exists:
                d(text='删除该聊天').click()

        i = 0
        j = 0
        while True:
            i = i + 1
            nearObj = d(className='android.widget.RelativeLayout',
                        index=0).child(className='android.widget.TextView',
                                       resourceId='com.tencent.mm:id/i4',
                                       index=1)
            newNearObj = d(className='android.widget.RelativeLayout',
                           index=0).child(className='android.widget.TextView',
                                          resourceId='com.tencent.mm:id/ie',
                                          index=1)
            if nearObj.exists or newNearObj.exists:
                if j > int(args['reply_count']):
                    break
                if nearObj.exists:
                    nearObj.click()
                else:
                    newNearObj.click()
                z.sleep(1.5)
                for i in range(0, msg_count):
                    if d(textContains='(',
                         resourceId='com.tencent.mm:id/gh').exists:
                        break
                    cate_id = args["repo_material_id"]
                    Material = self.repo.GetMaterial(cate_id, 0, 1)
                    if len(Material) == 0:
                        d.server.adb.cmd(
                            "shell",
                            "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,等待中……\""
                            % cate_id).communicate()
                        z.sleep(10)
                        return
                    message = Material[0]['content']  # 取出发送消息的内容
                    if d(className='android.widget.EditText').exists:
                        d(className='android.widget.EditText').click()
                    else:
                        break
                    z.input(message)
                    z.sleep(1)
                    d(text='发送').click()
                d(descriptionContains='返回').click()
                z.sleep(1.5)
                d(className='android.widget.ListView',
                  index=0).child(className='android.widget.LinearLayout',
                                 index=i).long_click()
                if d(text='删除该聊天').exists:
                    d(text='删除该聊天').click()
                z.sleep(1)
                j += 1
            else:
                if i > 20:
                    break
                z.sleep(10)
                continue

        now = datetime.datetime.now()
        nowtime = now.strftime(
            '%Y-%m-%d %H:%M:%S')  # 将日期转化为字符串 datetime => string
        z.setModuleLastRun(self.mid)
        z.toast('模块结束,保存的时间是%s' % nowtime)
Beispiel #21
0
class MobilqqFilterPraiseGreet:
    def __init__(self):
        self.repo = Repo()

    def action(self, d, z, args):
        z.toast("准备执行QQ附近的人(筛选+点赞+打招呼)")
        z.toast("正在ping网络是否通畅")
        z.heartbeat()
        i = 0
        while i < 200:
            i += 1
            ping = d.server.adb.cmd("shell",
                                    "ping -c 3 baidu.com").communicate()
            print(ping)
            if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                z.toast("网络通畅。开始执行:QQ交友资料修改")
                break
            z.sleep(2)
        if i > 200:
            z.toast("网络不通,请检查网络状态")
            if (args["time_delay"]):
                z.sleep(int(args["time_delay"]))
            return
        # self.scode = smsCode( d.server.adb.device_serial( ) )
        z.heartbeat()
        d.server.adb.cmd(
            "shell",
            "am force-stop com.tencent.mobileqq").communicate()  # 强制停止
        d.server.adb.cmd(
            "shell",
            "am start -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity"
        ).communicate()  # 拉起来
        z.sleep(10)
        z.heartbeat()
        if d(text="消息").exists:
            z.toast("卡槽状态正常,继续执行")
        else:
            z.toast("卡槽状态异常,跳过此模块")
            return

        str = d.info  # 获取屏幕大小等信息
        height = str["displayHeight"]
        width = str["displayWidth"]
        z.heartbeat()
        if d(text='绑定手机号码').exists:
            d(text='关闭').click()
        if d(textContains='匹配').exists:
            d.press.back()
        # d(description='快捷入口').click()
        # d( descriptionContains='快捷入口' ).click( )
        # d(text='加好友/群').click()
        z.heartbeat()
        while not d(text='附近的人', className="android.widget.TextView").exists:
            if d(index=2, text="动态",
                 className="android.widget.TextView").exists:
                d(index=2, text="动态",
                  className="android.widget.TextView").click()
            z.sleep(1)
            z.heartbeat()
            if d(index=1, text="附近",
                 className="android.widget.TextView").exists:
                z.sleep(1)
                z.heartbeat()
                d(index=1, text="附近",
                  className="android.widget.TextView").click()

        tempnum = 0
        objtemp = d(index=2, className="android.widget.LinearLayout").child(
            index=0,
            className="android.widget.LinearLayout",
            resourceId="com.tencent.mobileqq:id/name").child(
                index="0", className="android.widget.RelativeLayout").child(
                    index=0,
                    className="android.widget.ImageView",
                    resourceId="com.tencent.mobileqq:id/icon")
        while True:
            if objtemp.exists:
                z.sleep(1)
                break
            else:
                z.sleep(2)
                if tempnum == 4:
                    break
                else:
                    tempnum = tempnum + 1

        getGender = args['gender']
        if getGender != '不限':
            d(resourceId='com.tencent.mobileqq:id/ivTitleBtnRightImage').click(
            )
            d(text='筛选附近的人').click()
            d(text=getGender).click()
            d(text='完成').click()
            while not d(textContains='等级').exists:
                z.sleep(2)
        z.heartbeat()
        prisenum = int(args['prisenum'])
        concernnum = int(args['concernnum'])
        textnum = int(args['textnum'])
        count = max(prisenum, concernnum, textnum)
        t = 0
        i = 3
        while t < count:
            forClick = d(className='android.widget.AbsListView').child(
                className='android.widget.LinearLayout',
                index=i).child(className='android.widget.RelativeLayout')
            if forClick.child(className='android.widget.LinearLayout',
                              index=2).exists:
                z.heartbeat()
                if forClick.child(text='直播中').exists:
                    i = i + 1
                    continue

                forClick.click()

                while not d(textContains='关注').exists:
                    z.sleep(2)
                    if d(text='知道了').exists:
                        d(text='知道了').click()
                if t < prisenum:
                    praise = 0
                    z.heartbeat()
                    while praise < 10:
                        if d(descriptionContains='赞').exists:
                            z.heartbeat()
                            d(descriptionContains='赞').click()
                            if d(text='取消').exists:  #当点赞够次超数的时候
                                d(text='取消').click()
                                praise = 10  #表明点赞已够次数,将点赞结束掉
                            praise = praise + 1
                        else:
                            praise = 10  # 无法赞的情况
                            continue
                z.sleep(2)
                if t < concernnum:
                    if d(text='关注').exists:
                        d(text='关注').click()
                        if d(text='关注').exists:
                            d(text='关注').click()
                            if d(text='关注').exists:
                                z.toast("关注频繁,进行其他操作")

                if t < textnum:
                    d(text='发消息').click()
                    z.sleep(1)
                    if d(text='发消息').exists:
                        z.toast('无法发消息')
                        d(text='返回').click()
                        i = i + 1
                        t = t + 1
                        continue

                    d(className='android.widget.EditText').click()
                    cate_id = args["repo_material_id"]
                    Material = self.repo.GetMaterial(cate_id, 0, 1)
                    if len(Material) == 0:
                        d.server.adb.cmd(
                            "shell",
                            "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                            % cate_id).communicate()
                        z.sleep(10)
                        return
                    message = Material[0]['content']
                    z.input(message)
                    d(text='发送').click()

                # d(text='返回').click()
                if d(index=1,
                     resourceId='com.tencent.mobileqq:id/rlCommenTitle',
                     className="android.widget.RelativeLayout").child(
                         index=0,
                         className="android.widget.LinearLayout").child(
                             index=0,
                             className="android.widget.ImageView").exists:
                    d(index=1,
                      resourceId='com.tencent.mobileqq:id/rlCommenTitle',
                      className="android.widget.RelativeLayout").child(
                          index=0,
                          className="android.widget.LinearLayout").child(
                              index=0,
                              className="android.widget.ImageView").click()
                i = i + 1
                t = t + 1

            elif d(className='android.widget.AbsListView').child(
                    className='android.widget.RelativeLayout',
                    index=i).child(text='广告').exists:  #被点击条件不存在的情况
                z.heartbeat()
                i = i + 1
                continue
            else:
                str = d.info  # 获取屏幕大小等信息
                width = str["displayWidth"]
                clickCondition = d(className='android.widget.AbsListView')
                obj = clickCondition.info
                obj = obj['visibleBounds']
                top = int(obj['top'])
                bottom = int(obj['bottom'])
                y = bottom - top
                d.swipe(width / 2, y, width / 2, 0)
                z.sleep(3)
                i = 1

        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
Beispiel #22
0
class MMCTIMAutoReply:
    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath(__file__)

    def GetUnique(self):
        nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        # 生成当前时间
        randomNum = random.randint(0, 1000)
        # 生成的随机整数n,其中0<=n<=100
        if randomNum <= 10:
            randomNum = str(00) + str(randomNum)
        uniqueNum = str(nowTime) + str(randomNum)
        return uniqueNum

    def action(self, d, z, args):
        startTime = args["startTime"]
        endTime = args["endTime"]
        try:
            if self.repo.timeCompare(startTime, endTime):
                z.toast("该时间段不允许运行")
                return
        except:
            z.toast("输入的时间格式错误,请检查后再试")
            return

        set_timeStart = int(args['set_timeStart'])  # 得到设定的时间
        set_timeEnd = int(args["set_timeEnd"])
        run_time = float(random.randint(set_timeStart, set_timeEnd))
        run_interval = z.getModuleRunInterval(self.mid)
        if run_interval is not None and run_interval < run_time:
            z.toast(u'锁定时间还差:%d分钟' % int(run_time - run_interval))
            z.sleep(2)
            return
        cate_id = args["repo_material_cate_id"]
        sendTime = args["sendTime"]
        sendTime = sendTime.split("-")
        try:
            sendTimeStart = int(sendTime[0])
            sendTimeEnd = int(sendTime[1])
        except:
            z.toast("发送间隔的参数格式有误")
            return
        z.toast("准备执行MMS版TIM监控自动回复")
        z.sleep(1)
        z.toast("正在ping网络是否通畅")
        z.heartbeat()
        i = 0
        while i < 200:
            i += 1
            ping = d.server.adb.cmd("shell",
                                    "ping -c 3 baidu.com").communicate()
            print(ping)
            if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                z.toast("网络通畅。开始执行:准备执行MMS版TIM监控自动回复")
                break
            z.sleep(2)
        if i > 200:
            z.toast("网络不通,请检查网络状态")
            if (args["time_delay"]):
                z.sleep(int(args["time_delay"]))
            return
        # self.scode = smsCode( d.server.adb.device_serial( ) )
        z.heartbeat()
        d.server.adb.cmd("shell",
                         "am force-stop com.tencent.tim").communicate()  # 强制停止
        d.server.adb.cmd(
            "shell",
            "am start -n com.tencent.tim/com.tencent.mobileqq.activity.SplashActivity"
        ).communicate()  # 拉起来
        z.sleep(8)
        z.heartbeat()

        if d(text="消息",
             resourceId="com.tencent.tim:id/ivTitleName").exists and not d(
                 text="马上绑定", className="android.widget.Button").exists:
            z.toast("登录状态正常,继续执行")
        else:
            if d(text="关闭",
                 resourceId="com.tencent.tim:id/ivTitleBtnLeftButton").exists:
                d(text="关闭",
                  resourceId="com.tencent.tim:id/ivTitleBtnLeftButton").click(
                  )
                z.sleep(1)
            elif d(text="消息",
                   className="android.widget.TextView").exists and d(
                       text="马上绑定", className="android.widget.Button").exists:
                d(text="消息", className="android.widget.TextView").click()
                z.sleep(1)
            elif d(text="返回").exists:
                d(text="返回").click()
                z.sleep(1)

            else:
                z.toast("登录状态异常,跳过此模块")
                now = datetime.datetime.now()
                nowtime = now.strftime(
                    '%Y-%m-%d %H:%M:%S')  # 将日期转化为字符串 datetime => string
                z.setModuleLastRun(self.mid)
                z.toast('模块结束,保存的时间是%s' % nowtime)
                return
        add_count = int(args["add_count"])
        i = 0
        cate_id = args["repo_material_cate_id"]
        sendTime = args["sendTime"]
        sendTime = sendTime.split("-")
        try:
            sendTimeStart = int(sendTime[0])
            sendTimeEnd = int(sendTime[1])
        except:
            z.toast("发送间隔的参数格式有误")
            return
        meg_count = int(args["meg_count"])
        k = 0
        while i < add_count:
            if k == 10:
                z.toast("连续等待了100秒都没一条消息,停止模块")
                now = datetime.datetime.now()
                nowtime = now.strftime(
                    '%Y-%m-%d %H:%M:%S')  # 将日期转化为字符串 datetime => string
                z.setModuleLastRun(self.mid)
                z.toast('模块结束,保存的时间是%s' % nowtime)
                return
            if d(resourceId="com.tencent.tim:id/no_chat",
                 text="暂时没有新消息").exists:
                # d( resourceId="com.tencent.tim:id/no_chat", text="暂时没有新消息" ).click()
                z.toast("无消息,等待10秒")
                z.sleep(10)
                z.heartbeat()
                k = k + 1
                continue
            k = 0
            obj = d(resourceId="com.tencent.tim:id/recent_chat_list",
                    index=1,
                    className="android.widget.AbsListView").child(
                        index=2, className="android.widget.LinearLayout")
            if obj.exists:
                z.heartbeat()
                bounds = obj.info["bounds"]
                top = bounds["top"]
                bottom = bounds["bottom"]
                right = bounds["right"]

                obj2 = obj.child(
                    index=0,
                    resourceId="com.tencent.tim:id/relativeItem",
                    className="android.widget.RelativeLayout").child(
                        index=1,
                        className="android.widget.RelativeLayout").child(
                            index=2,
                            resourceId="com.tencent.tim:id/unreadmsg",
                            className="android.widget.TextView")
                z.heartbeat()
                if obj2.exists:
                    obj.child(
                        index=0,
                        resourceId="com.tencent.tim:id/relativeItem",
                        className="android.widget.RelativeLayout").child(
                            index=1,
                            className="android.widget.RelativeLayout").click()
                    if d(resourceId='com.tencent.tim:id/input',
                         className="android.widget.EditText").exists and not d(
                             resourceId=
                             "com.tencent.tim:id/ivTitleBtnRightImage",
                             description="群资料卡").exists and not d(
                                 text="TIM团队",
                                 resourceId="com.tencent.tim:id/title").exists:
                        d(resourceId='com.tencent.tim:id/input',
                          className="android.widget.EditText").click()
                        for j in range(0, random.randint(1, meg_count)):
                            Material = self.repo.GetMaterial(cate_id, 0, 1)
                            if len(Material) == 0:
                                d.server.adb.cmd(
                                    "shell",
                                    "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,等待中……\""
                                    % cate_id).communicate()
                                z.sleep(10)
                                return
                            message = Material[0]['content']  # 取出发送消息的内容
                            z.input(message)
                            z.sleep(1)
                            if d(text="发送",
                                 resourceId="com.tencent.tim:id/fun_btn"
                                 ).exists:
                                d(text="发送",
                                  resourceId="com.tencent.tim:id/fun_btn"
                                  ).click()
                                z.sleep(
                                    random.randint(sendTimeStart, sendTimeEnd))
                        i = i + 1

                    d.press.back()
                    z.sleep(2)
                    if obj2.exists:
                        i = i + 1
                        continue
                    if not obj.exists:
                        d.press.back()
                        z.sleep(1)
                    z.heartbeat()
                    d.swipe(right - 50, bottom - (bottom - top) / 2, right / 2,
                            bottom - (bottom - top) / 2, 5)
                    z.sleep(1)
                    if d(resourceId="com.tencent.tim:id/name",
                         description="删除").exists:
                        d(resourceId="com.tencent.tim:id/name",
                          description="删除").click()
                        z.sleep(1)
                    else:
                        d.swipe(right - 50, bottom - (bottom - top) / 2,
                                right / 2, bottom - (bottom - top) / 2, 5)
                        z.sleep(1)
                        if d(resourceId="com.tencent.tim:id/name",
                             description="删除").exists:
                            d(resourceId="com.tencent.tim:id/name",
                              description="删除").click()
                            z.sleep(1)
                else:
                    d.swipe(right - 50, bottom - (bottom - top) / 2, right / 2,
                            bottom - (bottom - top) / 2, 5)
                    z.sleep(1)
                    if d(resourceId="com.tencent.tim:id/name",
                         description="删除").exists:
                        d(resourceId="com.tencent.tim:id/name",
                          description="删除").click()
                        z.sleep(1)

            else:
                z.toast("无消息")
                z.sleep(5)

        now = datetime.datetime.now()
        nowtime = now.strftime(
            '%Y-%m-%d %H:%M:%S')  # 将日期转化为字符串 datetime => string
        z.setModuleLastRun(self.mid)
        z.toast('模块结束,保存的时间是%s' % nowtime)
        return
Beispiel #23
0
class WXAssignSearchAddFriends:
    def __init__(self):
        self.repo = Repo()
        self.mid = os.path.realpath(__file__)

    def action(self, d, z, args):
        z.heartbeat()
        d.server.adb.cmd(
            "shell", "am force-stop com.tencent.mm").communicate()  # 将微信强制停止
        d.server.adb.cmd(
            "shell", "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"
        ).communicate()  # 将微信拉起来
        z.sleep(5)

        d(description='更多功能按钮',
          className='android.widget.RelativeLayout').click()
        z.sleep(1)
        if d(text='添加朋友').exists:
            d(text='添加朋友').click()
        else:
            d(description='更多功能按钮',
              className='android.widget.RelativeLayout').click()
            z.sleep(1)
            d(text='添加朋友').click()
        z.heartbeat()
        d(index='1', className='android.widget.TextView').click()  #点击搜索好友的输入框

        cate_id = int(args["repo_number_id"])  # 得到取号码的仓库号
        number_count = int(args['get_number'])  # 每次取一个号码
        while True:
            exist_numbers = self.repo.GetNumber(cate_id, 8888, number_count,
                                                'exist')
            remain = number_count - len(exist_numbers)
            normal_numbers = self.repo.GetNumber(cate_id, 8888, remain,
                                                 'normal')
            numbers = exist_numbers + normal_numbers
            if len(numbers) > 0:
                break
            d.server.adb.cmd(
                "shell",
                "am broadcast -a com.zunyun.zime.toast --es msg \"电话号码%s号仓库为空,结束运行\""
                % cate_id).communicate()
            z.sleep(30)
        if len(numbers) <= 0:
            return

        for i in range(len(numbers)):

            WXnumber = numbers[i]['number']
            z.input(WXnumber)
            z.heartbeat()
            z.sleep(3)
            d(textContains='搜索:').click()
            while d(textContains='正在查找联系人').exists:
                z.sleep(2)

            if d(textContains='操作过于频繁').exists:
                continue
                # return
            z.sleep(2)
            if d(textContains='用户不存在').exists:
                d(descriptionContains='清除', index=2).click()
                z.sleep(1)
                continue
            if d(textContains='状态异常').exists:
                d(descriptionContains='清除', index=2).click()
                continue
            z.heartbeat()

            if d(text='设置备注和标签').exists:
                d(text='设置备注和标签').click()
                z.sleep(3)
                beizhuObj = d(className='android.widget.EditText', index=1)
                if beizhuObj.exists:
                    deltext = beizhuObj.info  # 将之前消息框的内容删除
                    deltext = deltext['text']
                    lenth = len(deltext)
                    m = 0
                    while m < lenth:
                        d.press.delete()
                        m = m + 1
                    z.input(WXnumber)
                    d(text='保存').click()
                    z.sleep(3)

            z.heartbeat()
            if d(text='添加到通讯录').exists:  # 存在联系人的情况
                d(text='添加到通讯录').click()

                if d(text='发消息').exists:
                    d(descriptionContains='返回').click()
                    z.sleep(3)
                    d(descriptionContains='返回').click()
                    z.sleep(3)
                    d(descriptionContains='清除').click()
                    continue
                elif d(text='验证申请').exists:
                    d(text='发送').click()
                    z.sleep(2)
                    d(descriptionContains='返回').click()
                    z.sleep(2)
                    d(descriptionContains='清除').click()
                    continue
                else:
                    if d(text='取消').exists:
                        d(text='取消').click()
                        d(descriptionContains='返回').click()
                        z.sleep(3)
                        d(descriptionContains='清除').click()
                        continue

                    if d(text='确定').exists:
                        d(text='确定').click()
                        d(descriptionContains='返回').click()
                        z.sleep(3)
                        d(descriptionContains='清除').click()
                        continue

                    d(descriptionContains='返回').click()
                    z.sleep(3)
                    d(descriptionContains='返回').click()
                    z.sleep(3)
                    d(descriptionContains='清除').click()
                    continue
            elif d(text='发消息').exists:
                d(descriptionContains='返回').click()
                z.sleep(3)
                d(descriptionContains='清除').click()
                continue
Beispiel #24
0
class QQAdressAddfriends2:
    def __init__(self):
        self.repo = Repo()

    def GetUnique(self):
        nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        # 生成当前时间
        randomNum = random.randint(0, 1000)
        # 生成的随机整数n,其中0<=n<=100
        if randomNum <= 10:
            randomNum = str(00) + str(randomNum)
        uniqueNum = str(nowTime) + str(randomNum)
        return uniqueNum

    def Gender(self, d, z):
        base_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.path.pardir, "tmp"))
        if not os.path.isdir(base_dir):
            os.mkdir(base_dir)
        sourcePng = os.path.join(base_dir, "%s_s.png" % (self.GetUnique()))
        obj = d(resourceId='com.tencent.mobileqq:id/name',
                className='android.widget.TextView',
                descriptionContains='基本信息')  # 当弹出选择QQ框的时候,定位不到验证码图片
        if obj.exists:
            z.heartbeat()
            obj = obj.info
            obj = obj['bounds']  # 验证码处的信息
            left = obj["left"]  # 验证码的位置信息
            top = obj['top']
            right = obj['right']
            bottom = obj['bottom']

            d.screenshot(sourcePng)  # 截取整个输入验证码时的屏幕

            img = Image.open(sourcePng)
            box = (left, top, right, bottom)  # left top right bottom
            region = img.crop(box)  # 截取验证码的图片
            # show(region)       #展示资料卡上的信息
            image = region.convert('RGBA')
            # 生成缩略图,减少计算量,减小cpu压力
            image.thumbnail((200, 200))
            max_score = None
            dominant_color = None
            for count, (r, g, b,
                        a) in image.getcolors(image.size[0] * image.size[1]):
                # 跳过纯黑色
                if a == 0:
                    continue
                saturation = colorsys.rgb_to_hsv(r / 255.0, g / 255.0,
                                                 b / 255.0)[1]
                y = min(
                    abs(r * 2104 + g * 4130 + b * 802 + 4096 + 131072) >> 13,
                    235)
                y = (y - 16.0) / (235 - 16)
                # 忽略高亮色
                if y > 0.9:
                    continue

                score = (saturation + 0.1) * count
                if score > max_score:
                    max_score = score
                    dominant_color = (r, g, b)
            # print("---------------------------------------------------------------------------")
            # print(dominant_color)
            z.heartbeat()
            if None == dominant_color:
                # print('见鬼了')
                return '不限'
            red = dominant_color[0]
            blue = dominant_color[2]

            if red > blue:
                # print('女')
                return '女'
            else:
                # print('男')
                return '男'
        else:  # 没有基本资料的情况
            return '不限'

    def getAddressList(self, d, z, args):
        z.heartbeat()
        base_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.path.pardir, "tmp"))
        if not os.path.isdir(base_dir):
            os.mkdir(base_dir)
        filename = os.path.join(base_dir, "%s.txt" % (self.GetUnique()))

        number_count = int(args['number_count'])
        cate_id = args["repo_cate_id"]
        while True:
            exist_numbers = self.repo.GetNumber(cate_id, 0, number_count,
                                                'exist')
            print(exist_numbers)
            remain = number_count - len(exist_numbers)
            normal_numbers = self.repo.GetNumber(cate_id, 0, remain, 'normal')
            numbers = exist_numbers + normal_numbers
            if len(numbers) > 0:
                break

            d.server.adb.cmd(
                "shell",
                "am broadcast -a com.zunyun.zime.toast --es msg \"电话号码%s号仓库为空,等待中\""
                % cate_id).communicate()
            z.sleep(30)

        if numbers:
            file_object = open(filename, 'w')
            lines = ""
            pname = ""
            for number in numbers:
                if number["name"] is None:
                    random_name = args['random_name']
                    if random_name == '是':
                        pname = z.phoneToName(number["number"])
                    else:
                        pname = number["number"]
                else:
                    pname = number["name"]
                lines = "%s%s----%s\r" % (lines, pname, number["number"])

            file_object.writelines(lines)
            file_object.close()
            isclear = args['clear']
            if isclear == '是':
                d.server.adb.cmd(
                    "shell",
                    "pm clear com.android.providers.contacts").communicate()

            #d.server.adb.cmd("shell", "am", "start", "-a", "zime.clear.contacts").communicate()
            d.server.adb.cmd("push", filename,
                             "/data/local/tmp/contacts.txt").communicate()
            d.server.adb.cmd(
                "shell", "am", "start", "-n",
                "com.zunyun.zime/.ImportActivity", "-t", "text/plain", "-d",
                "file:////data/local/tmp/contacts.txt").communicate()

            #d.server.adb.cmd("shell", "am broadcast -a com.zunyun.import.contact --es file \"file:///data/local/tmp/contacts.txt\"").communicate()
            os.remove(filename)

            out = d.server.adb.cmd("shell",
                                   "dumpsys activity top  | grep ACTIVITY"
                                   ).communicate()[0].decode('utf-8')
            while out.find("com.zunyun.zime/.ImportActivity") > -1:
                z.heartbeat()
                out = d.server.adb.cmd(
                    "shell", "dumpsys activity top  | grep ACTIVITY"
                ).communicate()[0].decode('utf-8')
                z.sleep(5)

        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))

    def Bind(self, d, z):
        self.scode = smsCode(d.server.adb.device_serial())
        z.heartbeat()
        newStart = 1
        while newStart == 1:
            GetBindNumber = self.scode.GetPhoneNumber(
                self.scode.QQ_CONTACT_BIND)
            if isinstance(GetBindNumber, list) and GetBindNumber:
                GetBindNumber = GetBindNumber[0]
            elif GetBindNumber is None or GetBindNumber == []:
                return 'false'
            if 'Session' in GetBindNumber:
                self.Bind(d, z)
            print(GetBindNumber)
            z.sleep(2)
            d(resourceId='com.tencent.mobileqq:id/name',
              className='android.widget.EditText').set_text(
                  GetBindNumber)  # GetBindNumber
            z.heartbeat()
            z.sleep(1)
            d(text='下一步').click()
            z.sleep(3)
            while d(text="正在发送请求").exists:
                time.sleep(3)
            if d(text='下一步',
                 resourceId='com.tencent.mobileqq:id/name',
                 index=2).exists:  # 操作过于频繁的情况
                return 'false'

            if d(text='确定',
                 resourceId='com.tencent.mobileqq:id/name',
                 index='2').exists:  # 提示该号码已经与另一个qq绑定,是否改绑,如果请求失败的情况
                d(text='确定',
                  resourceId='com.tencent.mobileqq:id/name',
                  index='2').click()
            z.heartbeat()
            code = self.scode.GetVertifyCode(GetBindNumber,
                                             self.scode.QQ_CONTACT_BIND, '4')
            newStart = 0

            d(resourceId='com.tencent.mobileqq:id/name',
              className='android.widget.EditText').set_text(code)
            d(text='完成', resourceId='com.tencent.mobileqq:id/name').click()
            z.heartbeat()
            z.sleep(5)
            if d(textContains='没有可匹配的').exists:
                return 'false'

        return 'true'

    def action(self, d, z, args):
        z.heartbeat()
        z.toast("准备执行QQ通讯录加好友+导入通讯录+多选")
        z.toast("开始导入通讯录")
        self.getAddressList(d, z, args)
        z.heartbeat()

        z.heartbeat()
        str = d.info  # 获取屏幕大小等信息
        height = str["displayHeight"]
        width = str["displayWidth"]
        cate_id1 = args["repo_material_id"]
        Material = self.repo.GetMaterial(cate_id1, 0, 1)
        message = Material[0]['content']  # 取出验证消息的内容
        d.server.adb.cmd(
            "shell",
            "am force-stop com.tencent.mobileqq").communicate()  # 强制停止
        d.server.adb.cmd(
            "shell",
            "am start -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity"
        ).communicate()  # 拉起来
        z.sleep(10)
        z.heartbeat()
        if d(text="消息",
             resourceId="com.tencent.mobileqq:id/ivTitleName",
             className="android.widget.TextView").exists:
            z.toast("登录状态正常")
        elif d(text='绑定手机号码').exists:
            while d(text='关闭').exists:
                d(text='关闭').click()
                z.sleep(0.5)
            z.sleep(1)
        elif d(text='主题装扮').exists:
            while d(text='关闭').exists:
                d(text='关闭').click()
                z.sleep(0.5)
        elif d(text='马上绑定').exists:
            while d(text='关闭').exists:
                d(text='关闭').click()
                z.sleep(0.5)
        else:
            z.toast("登录状态异常,停止模块")
            return
        str = d.info  # 获取屏幕大小等信息
        height = str["displayHeight"]
        width = str["displayWidth"]
        z.heartbeat()
        cate_id = args["repo_material_id"]  # ------------------
        Material = self.repo.GetMaterial(cate_id, 0, 1)
        if len(Material) == 0:
            d.server.adb.cmd(
                "shell",
                "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                % cate_id).communicate()
            z.sleep(10)
            return
        message = Material[0]['content']  # 取出验证消息的内容

        z.heartbeat()
        if d(text="联系人", resourceId="com.tencent.mobileqq:id/name").exists:
            d(text="联系人", resourceId="com.tencent.mobileqq:id/name").click()
            time.sleep(1)
            d(text="添加",
              resourceId="com.tencent.mobileqq:id/ivTitleBtnRightText").click(
              )
            time.sleep(1)
        d(text='添加手机联系人').click()
        time.sleep(3)
        if d(resourceId='com.tencent.mobileqq:id/name',
             className='android.widget.EditText',
             index=2).exists:  # 检查到尚未 启用通讯录
            if d(text=' +null',
                 resourceId='com.tencent.mobileqq:id/name').exists:
                d(text=' +null',
                  resourceId='com.tencent.mobileqq:id/name').click()
                d(text='中国大陆',
                  resourceId='com.tencent.mobileqq:id/name').click()
            z.heartbeat()
            text = self.Bind(d, z)  # 未开启通讯录的,现绑定通讯录
            z.heartbeat()
            if text == 'false':  # 操作过于频繁的情况
                z.toast('模块结束')
                return
            z.sleep(7)
        if d(textContains='没有可匹配的').exists:
            if d(text="返回",
                 resourceId="com.tencent.mobileqq:id/ivTitleBtnLeft").exists:
                d(text="返回",
                  resourceId="com.tencent.mobileqq:id/ivTitleBtnLeft").click()
                z.sleep(1)
                if d(text='添加手机联系人').exists:
                    d(text='添加手机联系人').click()
                    z.sleep(1)
                    if d(textContains='没有可匹配的').exists:
                        if d(text="返回",
                             resourceId="com.tencent.mobileqq:id/ivTitleBtnLeft"
                             ).exists:
                            d(text="返回",
                              resourceId="com.tencent.mobileqq:id/ivTitleBtnLeft"
                              ).click()
                            z.sleep(1)
                            if d(text='添加手机联系人').exists:
                                d(text='添加手机联系人').click()
                                z.sleep(1)
                                if d(textContains='没有可匹配的').exists:
                                    z.toast("显示不出来")
                                    return
        if d(text='匹配手机通讯录').exists:
            d(text='匹配手机通讯录').click()
            while not d(text='多选').exists:
                z.sleep(2)
        z.heartbeat()
        d(text='多选').click()
        m = 0
        # while True:
        # if d( text='★' ).exists:
        #     z.heartbeat( )
        #     for m in range( 0, 12, +1 ):  # 快速加好友从#号下面的
        #         obj = d( className='android.widget.AbsListView' ).child( className='android.widget.LinearLayout',index=m ).child(
        #             className='android.widget.TextView' ).info
        #         if obj['text'] == '★':
        #             break
        #         else:
        #             m = m + 1
        #             continue
        #
        #     break
        # else:  # 当前页没有找到#时滑页
        #     d.swipe( width / 2, height * 4 / 5, width / 2, height / 5 )
        z.heartbeat()
        set1 = set()
        i = m + 1
        t = 0
        EndIndex = int(args['EndIndex'])  # ------------------
        while t < EndIndex:
            obj = d(className='android.widget.AbsListView').child(
                className='android.widget.LinearLayout', index=i)  # 滑动的条件
            if obj.exists:
                z.heartbeat()
                obj1 = d( className='android.widget.AbsListView' ).child( className='android.widget.LinearLayout',
                                                                          index=i ) \
                    .child( className='android.widget.LinearLayout', index=2 ).child(
                    className='android.widget.TextView' )  # 第i个内容存在并且是人的情况
                if obj1.exists:
                    obj1 = obj1.info
                    phone = obj1['text']
                    if phone in set1:
                        i = i + 1
                        continue
                    else:
                        set1.add(phone)
                        print(phone)
                        obj5 = d( className='android.widget.AbsListView' ).child(
                            className='android.widget.LinearLayout', index=i ) \
                            .child( className='android.widget.FrameLayout' ).child( text='等待验证' )  # 验证已经发过的情况
                        if obj5.exists:
                            z.heartbeat()
                            d(textContains='加好友').click()
                            obj = d(className='android.widget.EditText'
                                    ).info  # 将之前消息框的内容删除
                            obj = obj['text']
                            lenth = len(obj)
                            mn = 0
                            while mn < lenth:
                                d.press.delete()
                                mn = mn + 1
                            z.input(message)
                            d(text='发送').click()
                            return
                        obj4 = d(className='android.widget.AbsListView').child(
                            className='android.widget.LinearLayout',
                            index=i).child(className='android.widget.CheckBox'
                                           )  # 勾选框没被遮住的情况
                        if obj4.exists:
                            obj4.click()
                        else:
                            d(className='android.widget.AbsListView').child(
                                className='android.widget.LinearLayout',
                                index=i).click()
                        i = i + 1
                        t = t + 1
                        continue  # --------------------------------------------
                else:

                    i = i + 1
                    continue
            else:
                d.swipe(width / 2, height * 4 / 5, width / 2, height / 5)
                obj2 = d( className='android.widget.AbsListView' ).child( className='android.widget.LinearLayout',
                                                                          index=i ) \
                    .child( className='android.widget.LinearLayout', index=2 ).child(
                    className='android.widget.TextView' )  # 结束条件
                if obj2.exists:
                    obj2 = obj2.info
                else:
                    obj2 = d( className='android.widget.AbsListView' ).child( className='android.widget.LinearLayout',
                                                                              index=i-1 ) \
                        .child( className='android.widget.LinearLayout', index=2 ).child(
                        className='android.widget.TextView' )
                    if obj2.exists:
                        obj2 = obj2.info
                    else:
                        obj2 = d( className='android.widget.AbsListView' ).child(
                            className='android.widget.LinearLayout',
                            index=i - 2 ) \
                            .child( className='android.widget.LinearLayout', index=2 ).child(
                            className='android.widget.TextView' )
                        if obj2.exists:
                            obj2 = obj2.info
                        else:
                            i = 0
                            continue
                EndPhone = obj2['text']

                # obj2 = d( className='android.widget.AbsListView' ).child( className='android.widget.LinearLayout',
                #                                                           index=i - 1 ) \
                #     .child( className='android.widget.LinearLayout', index=2 ).child(
                #     className='android.widget.TextView' )  # 结束条件
                # if obj2.exists:
                #     obj2 = obj2.info
                # else:
                #     obj2 = d( className='android.widget.AbsListView' ).child( className='android.widget.LinearLayout',
                #                                                               index=i - 2 ) \
                #         .child( className='android.widget.LinearLayout', index=2 ).child(
                #         className='android.widget.TextView' ).info  # 结束条件
                # EndPhone = obj2['text']
                if EndPhone in set1:
                    z.heartbeat()
                    d(textContains='加好友').click()
                    obj = d(className='android.widget.EditText'
                            ).info  # 将之前消息框的内容删除
                    obj = obj['text']
                    lenth = len(obj)
                    mn = 0
                    while mn < lenth:
                        d.press.delete()
                        mn = mn + 1
                    z.input(message)
                    d(text='发送').click()
                    return
                i = 0
                continue

        d(textContains='加好友').click()
        obj = d(className='android.widget.EditText').info  # 将之前消息框的内容删除
        obj = obj['text']
        lenth = len(obj)
        mn = 0
        z.heartbeat()
        while mn < lenth:
            d.press.delete()
            mn = mn + 1
        z.input(message)
        d(text='发送').click()
        while d(textContains='发送').exists:
            time.sleep(2)

        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
        z.toast("模块完成!")
Beispiel #25
0
class MobilqqLogin2:
    def __init__(self):
        self.type = 'mobileqq'
        self.repo = Repo()
        self.slot = Slot('', self.type)
        self.logger = util.logger

    def GetUnique(self):
        nowTime = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        # 生成当前时间
        randomNum = random.randint(0, 1000)
        # 生成的随机整数n,其中0<=n<=100
        if randomNum <= 10:
            randomNum = str(00) + str(randomNum)
        uniqueNum = str(nowTime) + str(randomNum)
        return uniqueNum

    def login(self, d, args, z):
        z.heartbeat()
        base_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.path.pardir, "tmp"))
        if not os.path.isdir(base_dir):
            os.mkdir(base_dir)
        sourcePng = os.path.join(base_dir, "%s_s.png" % (self.GetUnique()))
        codePng = os.path.join(base_dir, "%s_c.png" % (self.GetUnique()))
        cate_id = args["repo_cate_id"]

        while True:
            time_limit1 = args['time_limit1']
            numbers = self.repo.GetAccount(cate_id, time_limit1, 1)
            t = 30
            while len(numbers) == 0:
                z.heartbeat()

                z.toast('QQ帐号库%s号仓库无%s分钟未用,即将跳出 %s' %
                        (cate_id, time_limit1, t))
                numbers = self.repo.GetAccount(cate_id, time_limit1, 1)
                z.sleep(2)
                t = t - 2
                if t <= 0:
                    return None

            QQNumber = numbers[0]['number']  # 即将登陆的QQ号
            QQPassword = numbers[0]['password']
            z.sleep(1)
            z.heartbeat()
            z.cmd("shell", "pm clear com.tencent.mobileqq")  # 清除缓存
            z.cmd(
                "shell",
                "am start -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity"
            )  # 拉起来
            while d(textContains='正在更新数据').exists:
                z.sleep(3)

            z.heartbeat()
            t = 15
            z.toast("等待 登录 按钮出现")
            while not d(resourceId='com.tencent.mobileqq:id/btn_login').exists:
                z.toast("等待 登录 按钮出现 %s" % t)
                dumpStr = d.dump(compressed=False)
                z.sleep(2)
                if t == 9:
                    self.logger.war(dumpStr)
                t = t - 2
            d(resourceId='com.tencent.mobileqq:id/btn_login').click()

            z.sleep(1)
            d(className='android.widget.EditText', index=0).click()
            d(className='android.widget.EditText', index=0).set_text(
                QQNumber)  # 1918697054----xiake1234.  QQNumber
            z.sleep(1)
            d(resourceId='com.tencent.mobileqq:id/password').set_text(
                QQPassword)  # Bn2kJq5l     QQPassword
            z.heartbeat()
            print('QQ号:%s,QQ密码:%s' % (QQNumber, QQPassword))
            d(resourceId='com.tencent.mobileqq:id/login').click()
            if d(text='QQ').exists:
                d(text='QQ').click()
                if d(text='仅此一次').exists:
                    d(text='仅此一次').click()
            z.sleep(1)
            while d(text='登录中').exists:
                z.sleep(2)
            z.sleep(4)
            z.heartbeat()
            if d(resourceId='com.tencent.mobileqq:id/name',
                 index='2',
                 className="android.widget.EditText").exists:  # 需要验证码的情况
                icode = imageCode()
                im_id = ""
                for i in range(0, 30, +1):  # 打码循环
                    if i > 0:
                        icode.reportError(im_id)
                    obj = d(resourceId='com.tencent.mobileqq:id/name',
                            className='android.widget.ImageView'
                            )  #当弹出选择QQ框的时候,定位不到验证码图片
                    obj = obj.info
                    obj = obj['bounds']  # 验证码处的信息
                    left = obj["left"]  # 验证码的位置信息
                    top = obj['top']
                    right = obj['right']
                    bottom = obj['bottom']

                    d.screenshot(sourcePng)  # 截取整个输入验证码时的屏幕

                    img = Image.open(sourcePng)
                    box = (left, top, right, bottom)  # left top right bottom
                    region = img.crop(box)  # 截取验证码的图片

                    img = Image.new('RGBA', (right - left, bottom - top))
                    img.paste(region, (0, 0))

                    img.save(codePng)
                    im = open(codePng, 'rb')

                    codeResult = icode.getCode(im,
                                               icode.CODE_TYPE_4_NUMBER_CHAR)

                    code = codeResult["Result"]
                    im_id = codeResult["Id"]
                    os.remove(sourcePng)
                    os.remove(codePng)
                    z.heartbeat()
                    d(resourceId='com.tencent.mobileqq:id/name',
                      index='2',
                      className="android.widget.EditText").set_text(code)
                    z.sleep(3)
                    d(text='完成',
                      resourceId='com.tencent.mobileqq:id/ivTitleBtnRightText'
                      ).click()
                    z.sleep(6)
                    z.heartbeat()
                    while d(className='android.widget.ProgressBar',
                            index=0).exists:  #网速不给力时,点击完成后仍然在加载时的状态
                        z.sleep(2)
                    z.sleep(3)
                    z.heartbeat()
                    if d(text='输入验证码',
                         resourceId='com.tencent.mobileqq:id/ivTitleName'
                         ).exists:
                        continue
                    else:
                        break

            else:
                d.server.adb.cmd("shell",
                                 "am force-stop com.tencent1314.mobileqq"
                                 ).communicate()  # 强制停止
                z.sleep(1)
                d.server.adb.cmd(
                    "shell",
                    "am start -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity"
                ).communicate()  # 拉起来
                z.sleep(4)
            z.heartbeat()
            if d(text='搜索', resourceId='com.tencent.mobileqq:id/name'
                 ).exists:  # 不需要验证码的情况
                return QQNumber
            z.sleep(1)
            if d(text='马上绑定').exists:
                return QQNumber
            z.sleep(1)
            if d(text='通讯录').exists:  #登陆上后弹出t通讯录的情况
                return QQNumber
            if d(textContains='更换主题').exists:
                return QQNumber
            if d(text='寻找好友').exists:
                return QQNumber
            if d(textContains='密码错误').exists:
                self.logger.info('===========密码错误==============帐号:%s,密码:%s' %
                                 (QQNumber, QQPassword))
            z.heartbeat()
            self.repo.BackupInfo(cate_id, 'frozen', QQNumber, '',
                                 '')  # 仓库号,使用中,QQ号,设备号_卡槽号QQNumber
            z.sleep(1)
            if d(text='帐号无法登录').exists:
                d(text='取消').click()
            continue

    def action(self, d, z, args):
        z.heartbeat()
        d.dump(compressed=False)
        time_limit = args['time_limit']
        cate_id = args["repo_cate_id"]
        slotnum = self.slot.getEmpty()  # 取空卡槽

        print(slotnum)
        if slotnum == 0:  #没有空卡槽的话
            slotnum = self.slot.getSlot(d, time_limit)  # 没有空卡槽,取2小时没用过的卡槽
            print(slotnum)
            while slotnum == 0:  # 2小时没有用过的卡槽也为空的情况
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"QQ卡槽全满,无间隔时间段未用\""
                ).communicate()
                z.heartbeat()
                z.sleep(30)
                slotnum = self.slot.getSlot(d, time_limit)
            z.heartbeat()
            d.server.adb.cmd(
                "shell", "pm clear com.tencent.mobileqq").communicate()  # 清除缓存

            getSerial = self.repo.Getserial(
                cate_id, '%s_%s_%s' %
                (d.server.adb.device_serial(), self.type, slotnum))  #得到之前的串号
            time.sleep(1)
            if len(getSerial) == 0:  #之前的信息保存失败的话
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"串号获取失败,重新设置\""
                ).communicate()  #在51上测时库里有东西但是王红机器关闭后仍获取失败
                print('切换失败')
                getSerial = z.generateSerial("788")  # 修改信息
            else:
                getSerial = getSerial[0]['imei']  #如果信息保存成功但串号没保存成功的情况
                print('卡槽切换时的sereial%s' % getSerial)
                if getSerial is None:  #如果串号为空,在该卡槽下保存新的串号
                    getSerial = z.generateSerial("788")  # 修改信息
                else:
                    z.generateSerial(getSerial)  # 将串号保存
            z.heartbeat()
            self.slot.restore(d, slotnum)  # 有time_limit分钟没用过的卡槽情况,切换卡槽
            z.heartbeat()
            while True:
                ping = d.server.adb.cmd("shell",
                                        "ping -c 3 baidu.com").communicate()
                print(ping)
                if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                    break
                z.sleep(2)
            d.server.adb.cmd(
                "shell",
                "am broadcast -a com.zunyun.zime.toast --es msg \"卡槽成功切换为" +
                str(slotnum) + "号\"").communicate()
            z.sleep(2)
            if d(textContains='主题装扮').exists:
                d(text='关闭').click()
                z.sleep(1)

            d.server.adb.cmd(
                "shell",
                "am start -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity"
            ).communicate()  # 拉起来
            z.sleep(2)
            z.heartbeat()
            while d(textContains='正在更新数据').exists:
                z.sleep(2)
            z.sleep(5)
            z.heartbeat()
            if d(textContains='主题装扮').exists:
                d(text='关闭').click()
                z.sleep(1)

            loginedFlag = True

            seconds = 15
            while seconds > 0:
                z.toast('检查是否出现登录界面%s' % seconds)
                seconds = seconds - 1
                z.sleep(1)

                if z.checkTopActivity("com.tencent.mobileqq/.activity.RegisterGuideActivity") \
                    or z.checkTopActivity("com.tencent.mobileqq/.activity.LoginActivity") \
                    or d(textContains='身份过期').exists:
                    loginedFlag = False
                    break

            obj = self.slot.getSlotInfo(d, slotnum)  # 得到切换后的QQ号
            QQnumber = obj['info']  # info为QQ号
            if loginedFlag:
                z.toast(u'卡槽恢复成功')
                z.heartbeat()
                self.slot.backup(d, slotnum, QQnumber)  # 设备信息,卡槽号,QQ号
                self.repo.BackupInfo(cate_id, 'using', QQnumber, getSerial,
                                     '%s_%s_%s' %
                                     (d.server.adb.device_serial(), self.type,
                                      slotnum))  # 仓库号,状态,QQ号,备注设备id_卡槽id
            else:  #切换不成功的情况
                #z.toast(u'卡槽恢复失败,开始补登')
                self.repo.BackupInfo(cate_id, 'frozen', QQnumber, '',
                                     '')  # 标记卡槽号码为冻结,仓库号,状态,QQ号,备注设备id_卡槽id
                z.cmd("shell", "pm clear com.tencent.mobileqq")  # 清除缓存
                serialinfo = z.generateSerial("788")  # 修改信息
                z.heartbeat()
                z.toast(u'卡槽恢复失败,开始补登')
                QQnumber = self.login(d, args, z)  # 帐号无法登陆则登陆,重新登陆
                if QQnumber:
                    self.slot.backup(
                        d, slotnum,
                        QQnumber)  # 登陆之后备份,将备份后的信息传到后台 仓库号,状态,QQ号,备注设备id_卡槽id
                    self.repo.BackupInfo(
                        cate_id, 'using', QQnumber, serialinfo,
                        '%s_%s_%s' % (d.server.adb.device_serial(), self.type,
                                      slotnum))  # 仓库号,使用中,QQ号,设备号_卡槽号

                else:
                    z.toast(u'补登失败了 :(')

        else:  # 有空卡槽的情况
            d.server.adb.cmd(
                "shell", "pm clear com.tencent.mobileqq").communicate()  # 清除缓存

            z.heartbeat()
            while True:
                ping = d.server.adb.cmd("shell",
                                        "ping -c 3 baidu.com").communicate()
                print(ping)
                if 'icmp_seq' and 'bytes from' and 'time' in ping[0]:
                    break
                z.sleep(2)
            serialinfo = z.generateSerial("788")  #修改串号等信息
            print('登陆时的serial%s' % serialinfo)
            z.heartbeat()
            QQnumber = self.login(d, args, z)
            z.heartbeat()
            self.slot.backup(d, str(slotnum) + '_' + QQnumber)  #设备信息,卡槽号,QQ号
            self.repo.BackupInfo(cate_id, 'using', QQnumber, serialinfo,
                                 '%s_%s_%s' %
                                 (d.server.adb.device_serial(), self.type,
                                  slotnum))  # 仓库号,使用中,QQ号,设备号_卡槽号

        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
Beispiel #26
0
class EIMAddGroup:
    def __init__(self):
        self.repo = Repo()

    def action(self, d, z, args):
        z.heartbeat()
        totalNumber = int(args['totalNumber'])  # 要给多少人发消息
        cate_id = int(args["repo_number_id"])  # 得到取号码的仓库号
        numbers = self.repo.GetNumber(cate_id, 0,
                                      totalNumber)  # 取出totalNumber条两小时内没有用过的号码
        if len(numbers) == 0:
            d.server.adb.cmd(
                "shell",
                "am broadcast -a com.zunyun.zime.toast --es msg \"QQ号码库%s号仓库为空,等待中\""
                % cate_id).communicate()
            z.sleep(10)
            return
        list = numbers  # 将取出的号码保存到一个新的集合
        print(list)
        z.sleep(15)
        z.heartbeat()
        for i in range(0, totalNumber, +1):
            cate_id = args["repo_material_id"]
            Material = self.repo.GetMaterial(cate_id, 0, 1)
            if len(Material) == 0:
                d.server.adb.cmd(
                    "shell",
                    "am broadcast -a com.zunyun.zime.toast --es msg \"消息素材%s号仓库为空,没有取到消息\""
                    % cate_id).communicate()
                z.sleep(10)
                return
            message = Material[0]['content']
            QQnumber = list[i]['number']
            z.sleep(1)
            z.heartbeat()
            d.server.adb.cmd(
                "shell",
                'am start -a android.intent.action.VIEW -d "mqqapi://card/show_pslcard?src_type=internal\&version=1\&uin=%s\&card_type=group&source=qrcode"'
                % QQnumber)  # 群页面
            z.sleep(2)

            if d(text='企业QQ').exists:
                d(text='企业QQ').click()
                z.sleep(0.5)
                if d(text='仅此一次').exists:
                    d(text='仅此一次').click()

            z.heartbeat()
            obj = d(className='android.widget.RelativeLayout',
                    index=5).child(className='android.widget.TextView',
                                   index=1).info
            member = obj['text']
            member = filter(lambda ch: ch in '0123456789', member)
            member = int(member)
            if member == 0:
                continue
            d(text='加入该群').click()
            z.sleep(1)
            z.heartbeat()
            if d(text='加入该群').exists:
                continue
            obj = d(className='android.widget.EditText').info  # 将之前消息框的内容删除
            obj = obj['text']
            lenth = len(obj)
            m = 0
            while m < lenth:
                d.press.delete()
                m = m + 1
            z.input(message)
            d(text='发送').click()

        if (args["time_delay"]):
            z.sleep(int(args["time_delay"]))
Beispiel #27
0
 def __init__(self):
     self.repo = Repo()
     self.xuma = None
class QQEmailSendTextAllUnifiedAccountCate:
    def __init__(self):

        self.repo = Repo()
        self.domain = '192.168.1.101:8888'

    def input(self,random_code,z,text):
        if random_code=="乱码":
            z.cmd( "shell", "am broadcast -a ZY_INPUT_TEXT --es text \\\"%s\\\"" % text )
        else:
            z.input(text)

    def get_material(self, cateId, interval, limit, wid=''):    #wid是用来发微信朋友圈的
        path = "/repo_api/material/pick?status=normal&cate_id=%s&interval=%s&limit=%s&wid=%s" % (cateId,interval,limit,wid)
        url = self.domain + path
        response = requests.get( url )
        if response.status_code == 200:
            data = response.text
            numbers = json.loads( data )
            return numbers
        else:
            return []

    def backup_info(self, cateId, status, Number, IMEI, remark):  # 仓库号,状态,QQ号,备注设备id_卡槽id
        # path = "/repo_api/account/statusInfo?cate_id=%s&status=%s&Number=%s&IMEI=%s&cardslot=%s" % (cateId,status,Number,IMEI,remark)
        # conn = httplib.HTTPConnection(self.domain, self.port, timeout=30)
        # conn.request("GET",path)
        data = {"cate_id": cateId, "status": status, 'Number': Number, 'IMEI': IMEI, "cardslot": remark}
        path = "/repo_api/account/statusInfo"
        headers = {"Content-Type": "application/x-www-form-urlencoded",
                   "Connection": "Keep-Alive"};
        url = self.domain + path
        response = requests.post( url, data, headers=headers )
        # print response.status_code

    def getTime(self, timeType):
        path = "/cgi-bin/cgi_svrtime"
        conn = httplib.HTTPConnection( "cgi.im.qq.com", None, timeout=30 )
        conn.request( "GET", path )
        response = conn.getresponse( )
        data = response.read( ).replace( "\n", "" )
        # if response.status == 200:
        #   data = response.read()
        # else:
        #   print u"http://cgi.im.qq.com/cgi-bin/cgi_svrtime 失效了"
        #  return ""
        timea = datetime.datetime.strptime( data, '%Y-%m-%d %H:%M:%S' )
        if timeType == "EnTime":
            return timea.strftime( "%a, %b %d,  %Y %I:%M %p" )
        elif timeType == "CnTime":
            nt = timea
            w = ""
            weekday = nt.weekday( )
            if weekday == 0:
                w = "星期一"
            elif weekday == 1:
                w = "星期二"
            elif weekday == 2:
                w = "星期三"
            elif weekday == 3:
                w = "星期四"
            elif weekday == 4:
                w = "星期五"
            elif weekday == 5:
                w = "星期六"
            elif weekday == 6:
                w = "星期日"
            p = nt.strftime( "%p" )
            if p == "PM" or p == "pm":
                p = "下午"
            else:
                p = "上午"

            nowtime = nt.strftime( '%Y年%m月%d日%I:%M' )
            nowtime = nowtime.replace( "日", "日 (%s) %s" % (w, p) )
            return nowtime
        else:
            return timea.strftime( "%a, %b %d,  %Y %I:%M %p" )

    def send_mail(self, d, z, args, fj, repo_mail_cateId, repo_mail_cateId2, account, check, account_num):
        # repo_mail_cateId = args['repo_mail_cateId']
        repo_material_cateId = args['repo_material_cateId']
        selectContent = args["selectContent"]
        repo_material_cateId2 = args['repo_material_cateId2']
        Str = d.info  # 获取屏幕大小等信息
        height = int( Str["displayHeight"] )
        width = int( Str["displayWidth"] )
        size = args['size']
        random_code = args['random_code']
        z.heartbeat( )
        numberArr = []
        if repo_mail_cateId:
            count = 1
        else:
            count = 0
        if repo_mail_cateId2:
            if "@" in repo_mail_cateId2:
                numberArr.append(repo_mail_cateId2)
                count2 = 0
            else:
                count2 = 1
        else:
            count2 = 0

        if count > 0:
            numbers = self.repo.GetNumber( repo_mail_cateId, 120, count )
            if len( numbers ) == 0:
                if args["nuberLoop"] == "循环":
                    self.repo.UpdateNumberStauts( "", repo_mail_cateId, "normal" )
                    numbers = self.repo.GetNumber( repo_mail_cateId, 120, count )
                    if len( numbers ) == 0:
                        z.toast( "%s号仓库没有号码" % repo_mail_cateId )
                        return
                else:
                    d.server.adb.cmd( "shell",
                                      "am broadcast -a com.zunyun.zime.toast --es msg \"%s号仓库为空,没有取到消息\"" % repo_mail_cateId ).communicate( )
                    z.sleep( 10 )
                    return
            QQEmail = numbers[0]['number'].encode( "utf-8" )
            if "@" not in QQEmail:
                QQEmail += "@qq.com"
            numberArr.append(QQEmail)

        if count2 > 0:
            numbers = self.repo.GetNumber( repo_mail_cateId2, 120, count2 )
            if len( numbers ) == 0:
                if args["nuberLoop"] == "循环":
                    self.repo.UpdateNumberStauts( "", repo_mail_cateId2, "normal" )
                    numbers = self.repo.GetNumber( repo_mail_cateId2, 120, count2 )
                    if len( numbers ) == 0:
                        z.toast( "%s号仓库没有号码" % repo_mail_cateId2 )
                        return
                else:
                    d.server.adb.cmd( "shell",
                                      "am broadcast -a com.zunyun.zime.toast --es msg \"%s号仓库为空,没有取到消息\"" % repo_mail_cateId2 ).communicate( )
                    z.sleep( 10 )
                    return
            QQEmail = numbers[0]['number'].encode( "utf-8" )
            if "@" not in QQEmail:
                QQEmail += "@qq.com"
            numberArr.append(QQEmail)

        Material = self.get_material( repo_material_cateId, 0, 1 )
        if len( Material ) == 0:
            d.server.adb.cmd( "shell",
                              "am broadcast -a com.zunyun.zime.toast --es msg \"%s号仓库为空,没有取到消息\"" % repo_material_cateId ).communicate( )
            z.sleep( 10 )
            return
        message = Material[0]['content']

        Material2 = self.get_material( repo_material_cateId2, 0, 1 )
        if len( Material ) == 0:
            d.server.adb.cmd( "shell",
                              "am broadcast -a com.zunyun.zime.toast --es msg \"%s号仓库为空,没有取到消息\"" % repo_material_cateId ).communicate( )
            z.sleep( 10 )
            return
        message2 = Material2[0]['content']
        z.heartbeat( )
        # if d(text="温馨提示​",className="android.widget.TextView").exists:
        #     d(text="确定",className="android.widget.Button").click()
        #     z.sleep(1)
        if d( description="写邮件和设置等功能" ).exists:
            d( description="写邮件和设置等功能" ).click( )
            z.sleep( 0.5 )
            if d( text="写邮件" ).exists:
                d( text="写邮件" ).click( )
                z.sleep( 0.5 )
                # d.click( 60 / 720 * width, 198 / 1280 * height )
                # z.sleep(0.5)
                flag2 = True
        else:
            d.swipe( width / 2, height * 1 / 5, width / 2, height * 4 / 5 )
            time.sleep( 3 )
            if d( text="写邮件" ).exists:
                d( text="写邮件" ).click( )
                z.sleep( 0.5 )
                # d.click( 60 / 720 * width, 198 / 1280 * height )
                # z.sleep(0.5)
                flag2 = True
        z.heartbeat( )
        if selectContent == "只发主题" or selectContent == "主题内容都发":
            d.click( 166 / 720 * width, 377 / 1280 * height )
            self.input(random_code,z, message2.encode( "utf-8" ) )
            z.sleep( 2 )
            z.heartbeat( )

        z.sleep( 1 )
        d.dump( compressed=False )
        if selectContent == "只发内容" or selectContent == "主题内容都发":
            if "@" not in account:
                account2 = account + "@qq.com"
            else:
                account2 = account
            message = message.replace( "+FromMail+", account2.encode( "utf-8" ) )
            email = numberArr[0]
            message = message.replace( "+ToMail+", email.encode( "utf-8" ) )
            message = message.replace( "+Subject+", message2.encode( "utf-8" ) )
            while True:
                try:
                    x = self.getTime( "CnTime" )
                    x = unicode( x.decode( "utf-8" ) )
                    message = message.replace( u"+CnTime+", x )
                    break
                except:
                    pass
            while True:
                try:
                    x2 = self.getTime( "EnTime" ).encode( "utf-8" )
                    x2 = unicode( x2.decode( "utf-8" ) )
                    message = message.replace( "+EnTime+", x2 )
                    break
                except:
                    pass
            z.heartbeat( )
            if not d( textContains="抄送/密送,发件人" ).exists:
                obj = d( index=0, className="android.webkit.WebView" ).child( index=0,
                                                                              className="android.view.View" ).child(
                    index=0, className="android.view.View" )
                while not obj.exists:
                    d.swipe( width / 2, height * 5 / 6, width / 2, height / 6 )
                    d.dump( compressed=False )
                obj.click( )
                self.input(random_code,z, message.encode( "utf-8" ) )
            else:
                while not d( index=0, className="android.widget.EditText" ).exists:
                    d.swipe( width / 2, height * 5 / 6, width / 2, height / 6 )
                    d.dump( compressed=False )
                if d( index=0, className="android.widget.EditText" ).exists:
                    text = d( index=0, className="android.widget.EditText" ).info["text"].encode( "utf-8" )
                    z.sleep( 0.5 )
                    if text == "" or text == None:
                        d( index=0, className="android.widget.EditText" ).click( )
                        self.input(random_code,z, message.encode( "utf-8" ) )
                        z.sleep( 0.5 )

        d.click( 81 / 720 * width, 189 / 1280 * height )
        for numberMail in numberArr:
            # self.input(z,height,QQEmail+" ")
            self.input(random_code,z, numberMail+" " )

        if fj:
            if d( index=0, resourceId="com.tencent.androidqqmail:id/p3", className="android.widget.Button" ).exists:
                d( resourceId="com.tencent.androidqqmail:id/p3", className="android.widget.Button" ).click( )
                z.sleep( 0.5 )
                if d( description="从相册选择文件" ).exists:
                    d( description="从相册选择文件" ).click( )
                    z.sleep( 5 )
                    obj = d( index=2, className="android.widget.GridView" ).child(
                        index=1, className="android.widget.RelativeLayout" ).child(
                        index=0, className="android.widget.CheckBox" )
                    if obj.exists:
                        obj.click( )
                        z.sleep( 0.5 )
                        if d( textContains="添加到邮件" ).exists:
                            d( textContains="添加到邮件" ).click( )
                            z.sleep( 2 )
                            addToText = args['addToText']
                            if addToText == "添加":
                                if d( index=1,
                                      className="android.widget.HorizontalScrollView" ).child( index=0,

                                                                                               className="android.widget.LinearLayout" ).exists:
                                    d( index=1,
                                       className="android.widget.HorizontalScrollView" ).child( index=0,
                                                                                                className="android.widget.LinearLayout" ).click( )
                                    z.sleep( 0.5 )
                                    z.heartbeat( )
                                    if d( text="添加到正文" ).exists:
                                        d( text="添加到正文" ).click( )
                                        z.sleep( 0.5 )

                    else:
                        z.toast( "没有图片,停止模块" )
                        return
        z.heartbeat( )
        d.dump( compressed=False)
        if d( text="发送​", className="android.widget.Button", resourceId="com.tencent.androidqqmail:id/a_" ).exists:
            d( text="发送​", className="android.widget.Button", resourceId="com.tencent.androidqqmail:id/a_" ).click( )
            z.sleep( 2 )
            if d( textContains=size, className="android.widget.TextView",
                  resourceId="com.tencent.androidqqmail:id/lj" ).exists:
                d( textContains=size, className="android.widget.TextView",
                   resourceId="com.tencent.androidqqmail:id/lj" ).click( )
            if d( text="确定" ).exists:
                d( text="确定" ).click( )
        else:
            pass
        if d( text="发送​", className="android.widget.Button", resourceId="com.tencent.androidqqmail:id/a_" ).exists:
            z.toast( "发送不了" )
            return
        time.sleep( 2 )
        if d( index=2, className="android.widget.Button" ).exists:
            d( index=2, className="android.widget.Button" ).click( )
        if d( text="取消", className="android.widget.Button" ).exists or d( text="取消",
                                                                          className="android.widget.Button" ).exists:
            d( text="取消", className="android.widget.Button" ).click( )
        time.sleep( 3 )
        # if d( text="收件箱​", className="android.widget.TextView" ).exists:
        #     d.swipe( width / 2, height * 4 / 5, width / 2, height / 5 )
        #     time.sleep( 2 )
        # elif d( text="群邮件​", resourceId="com.tencent.androidqqmail:id/t0" ).exists:
        #     pass
        # else:
        #     return
        obj = d( description='待发送' ).child( resourceId="com.tencent.androidqqmail:id/t4" )
        if obj.exists:
            # z.toast( "发送失败" )
            # for it in numbers:
            #     it2 = it["number"]
            #     self.repo.UpdateNumberStauts(it2,repo_mail_cateId,"normal")
            # for bcc in bccNumbers:
            #     bcc2 = bcc["number"]
            #     self.repo.UpdateNumberStauts(bcc2,repo_mail_cateId,"normal")
            failCount = int( args["failCount"] )
            num = 0

            if obj.exists:
                num = obj.info['text']
                if int( num ) >= failCount:
                    z.toast( "共有%s个未发送,跳出模块" % num )
                    return 'over'
        z.heartbeat( )
        if check:
            if (args["time_delay"]):
                z.toast("等待%s秒后查看另一个帐号是否收到邮件"%int(args["time_delay"]))
                time.sleep(int(args["time_delay"]))

            accountObj2 = d( descriptionContains='%s的收件箱有' % repo_mail_cateId2.split( '@' )[0] )
            if not accountObj2.exists:
                account_num2 = 0
            else:
                account_num2 = accountObj2.info['contentDescription']
                account_num2 = int( re.findall( r'\d+', account_num2 )[1] )

            if account_num2 > account_num:
                z.toast( "收到邮件" )
                return 'success'
            else:
                z.toast( "没有收到邮件" )
                return 'fail'

    def action(self, d, z, args):
        import sys
        reload( sys )
        sys.setdefaultencoding( 'utf8' )
        z.toast( "QQ邮箱根据另一个帐号的收信情况发信" )
        random_code = args['random_code']
        z.heartbeat( )
        # str = d.info  # 获取屏幕大小等信息
        # height = str["displayHeight"]
        # width = str["displayWidth"]
        repo_mail_cateId = int(args['repo_mail_cateId'])
        repo_material_cateId= args["repo_material_cateId"]
        repo_material_cateId2 = args["repo_material_cateId2"]
        size = args["size"]
        # d.server.adb.cmd( "shell", "am force-stop com.tencent.androidqqmail" ).communicate( )  # 强制停止
        # d.server.adb.cmd( "shell","am start -n com.tencent.androidqqmail/com.tencent.qqmail.launcher.desktop.LauncherActivity" ).communicate( )  # 拉起来
        d.server.adb.cmd( "shell","am start -n com.tencent.androidqqmail/com.tencent.qqmail.LaunchComposeMail" ).communicate( )  # 拉起QQ邮箱
        z.sleep( 2 )
        Str = d.info  # 获取屏幕大小等信息
        height = int(Str["displayHeight"])
        width = int(Str["displayWidth"])
        z.heartbeat( )
        flag1 = False
        flag2 = False
        for t in range(2):
            d.dump( compressed=False )
            if d( text="所有收件箱​",className="android.widget.TextView" ).exists:
                if d(textContains="密码错误,请重新输入").exists:
                    z.toast("密码错误,请重新输入")
                    return
                else:
                    z.toast( "状态正常,继续执行" )
                    break
            else:
                if d( text="温馨提示​", className="android.widget.TextView" ).exists:
                    d( text="确定", className="android.widget.Button" ).click( )
                    z.sleep( 1 )
                    break
                elif d(text="收件人:").exists and d(text="写邮件").exists:
                    flag1 = True
                    break
                elif d(text="取消​",resourceId='com.tencent.androidqqmail:id/a5',index=0).exists:
                    d( text="取消​", resourceId='com.tencent.androidqqmail:id/a5',index=0 ).click()
                    time.sleep(1)
                    if d(text="离开",className="android.widget.Button").exists:
                        d( text="离开", className="android.widget.Button" ).click()
                        time.sleep(1)
                    if d( text="收件箱​", className="android.widget.TextView" ).exists:
                        d.press.back()
                        time.sleep(1)
                        if d( textContains="密码错误,请重新输入" ).exists:
                            z.toast( "密码错误,请重新输入" )
                            return
                        else:
                            z.toast( "状态正常,继续执行" )
                            break

                elif d(index=1,text="写邮件​",className="android.widget.TextView").exists:
                    d.click(60/720 * width,198/1280 * height)
                    flag1 = True
                    break
                else:
                    if t>=1:
                        z.toast( "状态异常,跳过此模块" )
                        return
                    else:
                        d.server.adb.cmd( "shell", "am force-stop com.tencent.androidqqmail" ).communicate( )  # 强制停止
                        d.server.adb.cmd( "shell",
                                          "am start -n com.tencent.androidqqmail/com.tencent.qqmail.LaunchComposeMail" ).communicate( )  # 拉起QQ邮箱
                        time.sleep( 5 )
        if d( text="所有收件箱​", className="android.widget.TextView" ).exists:
            if d( textContains="密码错误,请重新输入" ).exists:
                z.toast( "密码错误,请重新输入" )
                return
            # else:
            #     z.toast( "状态正常,继续执行" )
        else:
            z.toast("状态不正常")
            return
        z.heartbeat()
        accountObj = d( className="android.widget.RelativeLayout", index=4, descriptionContains='的收件箱' )
        if accountObj.exists:
            accountObj2 = d(className="android.widget.RelativeLayout", index=5, descriptionContains='的收件箱')
            if not accountObj2.exists:
                z.toast("只有一个帐号,跳出模块")
                return
        else:
            accountObj = d( className="android.widget.RelativeLayout", index=5, descriptionContains='的收件箱' )
            accountObj2 = d( className="android.widget.RelativeLayout", index=6, descriptionContains='的收件箱' )
            if not accountObj2.exists:
                # accountObj2 = d( className="android.widget.RelativeLayout", index=4, descriptionContains='的收件箱' )
                z.toast( "只有一个帐号,跳出模块" )
                return
        z.heartbeat()
        domain = args['domain']
        if domain:
            if 'http' not in domain:
                self.domain = 'http://' + domain
            else:
                self.domain = domain
        else:
            z.toast( "参数错误,格式如:192.168.1.102:8888" )
            time.sleep( 3 )
            return

        account2 = accountObj2.info['contentDescription']
        account2 = re.search(r'\d{5,11}', account2).group(0) + '@qq.com'

        account = accountObj.info['contentDescription']
        account = re.search( r'\d{5,11}', account ).group( 0 ) + '@qq.com'
        # account = accountArr[0]
        sendCount = int(args["sendCount"])
        train_cate_id = args['train_cate_id']
        auto_reply_cate_id = account2
        fj = False
        success1 = False
        success2 = False
        success3 = False
        account_num = 0
        accountObj2 = d( descriptionContains='%s的收件箱有' % account2.split( '@' )[0] )
        if not accountObj2.exists:
            account_num = 0
        else:
            account_num = accountObj2.info['contentDescription']
            account_num = int( re.findall( r'\d+', account_num )[1] )
        qqNumber = account.split( '@' )[0]
        z.heartbeat()
        repo_account_A = args['repo_account_A']
        repo_account_B = args["repo_account_B"]
        for sc in range(2):
            z.heartbeat( )
            result = self.send_mail(d,z,args,fj,'',auto_reply_cate_id,account,True,account_num)
            if result=='over':
                return
            elif result=='success':
                # d.press.back( )
                # time.sleep( 1 )
                if sc==0:
                    success1 = True
                elif sc==1:
                    success2 = True
                self.backup_info( repo_account_A, 'using', qqNumber, '', '' )
                self.write_cate(qqNumber,repo_account_A,repo_account_B)
                break
            else:
                # d.press.back()
                # time.sleep(1)
                if sc==0:
                    fj = True
                    z.toast( "给 %s 『带附件』发消息"% account2 )
                else:
                    success3 = True
                    z.toast( "给小号发消息" )
                    break


        if success1:
            repo_mail_cateId = args['repo_mail_cateId']
            auto_reply_cate_id = ''
        elif success2:
            repo_mail_cateId = args['repo_mail_cateId']
            auto_reply_cate_id = ''
        elif success3:
            repo_mail_cateId = ''
            auto_reply_cate_id = args['train_cate_id']
            sendCount = random.randint(3,5)

        for sc in range( sendCount ):
            if success3:
                if random.randint( 0, 1 ) == 0:
                    fj = False
                else:
                    fj = True
            z.heartbeat( )
            result = self.send_mail( d, z, args, fj, repo_mail_cateId, auto_reply_cate_id, account, False,account_num )
            if result=='over':
                return



        z.toast("模块完成")

    def write_cate(self,qqNumber,numberCateId,cate_id):
        # qqNumber = '2879127010'
        # numberCateId = '407'
        path = "/repo_api/account/getAccountNumber?QQNumber=%s&cate_id=%s" % (qqNumber, numberCateId)
        url = self.domain + path
        response = requests.get( url )
        data = response.text
        numbers = json.loads( data )
        password = numbers[0]['password']
        print password

        data = {"QQNumber": qqNumber, "QQPassword": password, 'PhoneNumber': None, 'cate_id': cate_id,
                'status': 'normal', 'IMEI': None, "cardslot": None}
        path = "/repo_api/register/numberInfo"
        headers = {"Content-Type": "application/x-www-form-urlencoded",
                   "Connection": "Keep-Alive"}
        url = self.domain + path
        response = requests.post( url, data, headers=headers )
Beispiel #29
0
 def __init__(self):
     self.repo = Repo()
     self.type = 'token'
    def __init__(self):

        self.repo = Repo()
        self.domain = '192.168.1.101:8888'