1
1
mirror of https://gitlab.com/ceda_ei/Zeeth-Naaw-Bot synced 2025-03-12 16:26:52 +01:00

Added set follower to -1 if no follower found in bio.

This commit is contained in:
Ceda EI 2018-04-05 16:17:52 +05:30
parent ac2ff8925c
commit 47b59abbd8

View File

@ -101,6 +101,7 @@ function update_user_by_username($username) {
$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
$xpath = new \DOMXPath($dom);
$changed = false;
foreach ($xpath->query("descendant-or-self::div[@class and contains(concat(' ', normalize-space(@class), ' '), ' tgme_page_description ')]/a") as $node){
$username_follows = preg_replace('/^@/', '', $node->nodeValue);
$query = "SELECT user_id FROM users WHERE username = '" . $username_follows . "';" ;
@ -111,9 +112,14 @@ function update_user_by_username($username) {
$row = $result->fetch_assoc();
$query = "UPDATE users SET follows = " . $row['user_id'] . " WHERE username = '" . $username . "';" ;
$conn->query($query);
$changed = true;
return;
}
}
if (!$changed) {
$query = "UPDATE users SET follows = -1 WHERE username = '" . $username . "';" ;
$conn->query($query);
}
}
# Update users