| 226 | } |
| 227 | |
| 228 | func detectSite(name, site, nameType string, siteBody gjson.Result) { |
| 229 | defer wg.Done() |
| 230 | |
| 231 | // flag for precisely mode |
| 232 | flag := false |
| 233 | |
| 234 | url := siteBody.Get("url").String() |
| 235 | |
| 236 | if siteBody.Get("isNSFW").Bool() && !detectArgs.isNSFW { |
| 237 | log.Debugf(nsfwInfo, name, site, site) |
| 238 | return |
| 239 | } |
| 240 | |
| 241 | // Check name |
| 242 | if nameCheck := siteBody.Get("nameCheck"); nameCheck.Exists() && len(nameCheck.Str) != 0 && nameType == "username" { |
| 243 | match, err := regexp.MatchString(nameCheck.String(), name) |
| 244 | if err != nil { |
| 245 | log.Fatalln(err) |
| 246 | } |
| 247 | |
| 248 | if !match { |
| 249 | log.Debugf(nonExistInfo, name, site) |
| 250 | return |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | whoisData := siteBody.Get("whois") |
| 255 | |
| 256 | detectReq := siteBody.Get("detect").Array() |
| 257 | |
| 258 | detectCount := len(detectReq) - 1 |
| 259 | for index, detectData := range detectReq { |
| 260 | |
| 261 | // check status |
| 262 | if status := detectData.Get("status"); status.Exists() && !status.Bool() { |
| 263 | log.Debugf(disableSiteInfo, name, site, site) |
| 264 | break |
| 265 | } |
| 266 | retryTimes := 0 |
| 267 | |
| 268 | if search := detectData.Get("search"); search.Exists() { |
| 269 | // google options |
| 270 | if detectArgs.google { |
| 271 | searchString := search.String() |
| 272 | if strings.Contains(searchString, "%s") { |
| 273 | searchString = fmt.Sprintf(searchString, name) |
| 274 | } |
| 275 | searchUrl := fmt.Sprintf(detectData.Get("searchUrl").String(), searchString) |
| 276 | log.Infof(searchInfo, name, site, searchUrl) |
| 277 | break |
| 278 | } |
| 279 | } else if strings.Contains(detectData.Get("type").String(), nameType) && detectUser(name, site, url, index, retryTimes, detectCount, &flag, detectData, whoisData) { |
| 280 | continue |
| 281 | } else { |
| 282 | break |
| 283 | } |
| 284 | } |
| 285 | } |