Applescript成功实现检测手机号是否注册imessage,imessage数据筛选

发布时间 2023-08-23 03:15:59作者: 一路向北's

一、imessages数据检测的两种方式:
1.人工筛选,将要验证的号码输出到文件中,以逗号分隔。再将文件中的号码粘贴到iMessage客户端的地址栏,iMessage客户端会自动逐个检验该号码是否为iMessage账号,检验速度视网速而定。红色表示不是iMessage账号,蓝色表示iMessage账号。
2.编写苹果操作系统下的脚本程序进行过滤(全自动检测,无需人工干预),类似于群发iMessage;发送一条iMessage之后,如果捕获到发送失败的异常则不是iMessage账号,捕获到发送成功则把数据保存下来。

 

 

二、实现全自动无痕检测数据是否启用或开通imessages
1.电脑版程序全自动无痕检测手机号是否注册imessages,注意:检测不同国家手机号需要在手机号的前缀 +国家代码即可(自动检测导入的txt数据,蓝色的手机号数据自动保存,有偿提供源码或脚本程序联系飞机:@fz66168 )
电脑版检测脚本代码示例:

复制代码
  1 startApp()
  2 
  3 on clickOk()
  4     tell application "Messages" to activate
  5     tell application "System Events"
  6         tell process "Messages"
  7             tell window 1
  8                 entire contents
  9             end tell
 10         end tell
 11     end tell
 12 end clickOk
 13 
 14 
 15 on startApp()
 16     tell application "Finder" to activate
 17 
 18     tell application "Finder"
 19         set chosenfile to (choose file) --选择需要检测的数据文件,例如:phone.txt
 20     end tell
 21 
 22     tell application "Messages"
 23         tell application "Messages" to activate
 24 
 25         set phoneData to read chosenfile
 26         set cards to paragraphs of phoneData
 27 
 28         repeat with phone in cards
 29             --set msgText to (my AppendFace(" "))
 30 
 31             set num to the length of phone
 32             if (num > 0) then
 33                 my sendMsg(phone, ".")
 34                 delay 1
 35 
 36                 # 删除多余的消息
 37                 set chatNum to (get count of chat)
 38                 if chatNum is greater than 1 then
 39                     my deleteMsg(chatNum, phone)
 40                 end if
 41 
 42             end if
 43         end repeat
 44 
 45     end tell
 46 end startApp
 47 
 48 
 49 # 发送信息
 50 on sendMsg(phone, msg)
 51     tell application "System Events"
 52         tell process "Messages"
 53             tell window 1
 54                 delay 0.2
 55                 key code &
 56                 --核心代码,省略.........
 57             end tell
 58         end tell
 59     end tell
 60 end sendMsg
 61 
 62 
 63 # 删除信息
 64 on deleteMsg(maxNum, thisphone)
 65     tell application "Messages" to activate
 66 
 67     tell application "System Events"
 68         tell process "Messages"
 69             tell window 1
 70                 repeat maxNum times
 71 
 72                     delay 0.2
 73                     click row 1 of table 1 of scroll area 1 of splitter group 1 --选中第一个会话
 74                     delay 0.2
 75                     click menu item "删除对话…" of menu "文件" of menu bar item "文件" of menu bar 1 of application process "Messages" of application "System Events"
 76                     delay 0.2
 77 
 78                     try
 79                         click button "删除" of sheet 1
 80                         --对启用了imessage功能的手机号码进行记录
 81                         my WritePhone(thisphone)
 82 
 83                     end try
 84                 end repeat
 85             end tell
 86         end tell
 87     end tell
 88 end deleteMsg
 89 
 90 
 91 
 92 -- 记录有效手机号
 93 on WritePhone(the_phone)
 94     set num to the length of the_phone
 95     if (num > 0) then
 96         set fileName to date string of (current date)
 97         set logFilePath to my current_folder_path() & "send/检测成功的数据.txt"
 98         set this_file to (POSIX file logFilePath as string)
 99         set this_story to the_phone & "
100 "
101         try
102             set fp to open for access this_file
103             set myText to read fp
104 
105             if (myText does not contain the_phone) then
106                 my write_to_file(this_story, this_file, true, true)
107             end if
108         on error
109             my write_to_file(this_story, this_file, true, true)
110         end try
111     end if
112 end WritePhone
113 
114 
115 
116 -- 写入文件
117 --    this_data(文本内容,string)
118 --    target_file(文件路径,string)
119 --    append_data(是否拼接,boolean)
120 --    append_end(是否从后面拼接,boolean)
121 on write_to_file(this_data, target_file, append_data, append_end)
122     try
123         set the target_file to the target_file as text
124         set the open_target_file to ¬
125             open for access file target_file with write permission
126 
127         if append_data is false then
128             set eof of the open_target_file to 0
129             write this_data to the open_target_file starting at eof
130         else if append_end is false then
131             -- 1、读取原来内容;
132             -- 2、清空文件,写入新内容;
133             -- 3、在新内容后面拼接原始内容
134             try
135                 set fp to open for access target_file
136                 set myText to read fp
137                 set eof of the open_target_file to 0
138                 write this_data to the open_target_file starting at eof
139                 write myText to the open_target_file starting at eof
140             on error
141                 write this_data to the open_target_file starting at eof
142             end try
143         else
144             write this_data to the open_target_file starting at eof
145         end if
146 
147         close access the open_target_file
148         return target_file
149     on error
150         try
151             close access file target_file
152         end try
153         return false
154     end try
155 end write_to_file
156 
157 
158 -- 取文件夹路径
159 on current_folder_path()
160     set UnixPath to POSIX path of ((path to me as text) & "::")
161     return UnixPath
162 end current_folder_path
复制代码

全自动检测是否imessages数据(0.3秒到0.5秒检测一封,无痕检测,检验速度视网速而定)

 

2.手机版脚本全自动检测数据是否imessages(全自动检测用户导入的手机号数据,蓝色的数据自动保存)