Commit 2f557506 authored by Luke081515's avatar Luke081515

Replace echo

* Replaced echo with echoMsg
parent 89aa9ada
...@@ -60,12 +60,12 @@ class Core extends Password { ...@@ -60,12 +60,12 @@ class Core extends Password {
} }
$this->login(); $this->login();
$this->createCleanUsername(); $this->createCleanUsername();
echo "\n***** Starting up....\nVersion: " . $this->version . " *****"; $this->echoMsg("***** Starting up....\nVersion: " . $this->version . " *****", "notice");
$this->ua = "User:" . $this->cleanUsername . " - " . $this->job . " - " . $this->version; $this->ua = "User:" . $this->cleanUsername . " - " . $this->job . " - " . $this->version;
echo "\nUsed UserAgent: '" . $this->ua . "'\n"; $this->echoMsg("Used UserAgent: '" . $this->ua . "'\n", "notice");
if ($this->cleanUsername === $this->username) { if ($this->cleanUsername === $this->username) {
echo "\nWarning: Main-account login via \"action=login\" is deprecated and may stop working without warning. "; $this->echoMsg("Warning: Main-account login via \"action=login\" is deprecated and may stop working without warning. ", "warning");
echo "To continue login with \"action=login\", see [[Special:BotPasswords]]."; $this->echoMsg("To continue login with \"action=login\", see [[Special:BotPasswords]].", "warning");
} }
} }
/** initcurlArgs /** initcurlArgs
...@@ -99,12 +99,12 @@ class Core extends Password { ...@@ -99,12 +99,12 @@ class Core extends Password {
$this->createCleanUsername(); $this->createCleanUsername();
$this->ua = "User:" . $this->cleanUsername . " - " . $this->job . " - " . $this->version; $this->ua = "User:" . $this->cleanUsername . " - " . $this->job . " - " . $this->version;
if (!$supress) { if (!$supress) {
echo "\n***** Starting up....\nVersion: " . $this->version . " *****"; $this->echoMsg("***** Starting up....\nVersion: " . $this->version . " *****", "notice");
echo "\nUsed UserAgent: '" . $this->ua . "'\n"; $this->echoMsg("Used UserAgent: '" . $this->ua . "'\n", "notice");
} }
if ($this->cleanUsername === $this->username) { if ($this->cleanUsername === $this->username) {
echo "\nWarning: Main-account login via \"action=login\" is deprecated and may stop working without warning."; $this->echoMsg("Warning: Main-account login via \"action=login\" is deprecated and may stop working without warning. ", "warning");
echo "To continue login with \"action=login\", see [[Special:BotPasswords]]."; $this->echoMsg("To continue login with \"action=login\", see [[Special:BotPasswords]].", "warning");
} }
// change if you need more, default is 5 // change if you need more, default is 5
$this->setMaxlag(5); $this->setMaxlag(5);
...@@ -188,13 +188,13 @@ class Core extends Password { ...@@ -188,13 +188,13 @@ class Core extends Password {
$success = true; $success = true;
break 1; break 1;
} else { } else {
echo "\nCurl request with arguments \"" . $arguments . "\" to " . $this->site . " failed ($i/20): " . curl_error($this->curlHandle); $this->echoMsg("Curl request with arguments \"" . $arguments . "\" to " . $this->site . " failed ($i/20): " . curl_error($this->curlHandle), "error");
sleep(10); sleep(10);
} }
} }
if ($success === true) { if ($success === true) {
if ($this->debugMode) { if ($this->debugMode) {
echo "\nResult for " . $arguments . ":\n'" . $rqResult . "'"; $this->echoMsg("Result for '" . $arguments . "':\n'" . $rqResult . "'", "none");
} }
return $rqResult; return $rqResult;
} else { } else {
...@@ -324,7 +324,7 @@ class Core extends Password { ...@@ -324,7 +324,7 @@ class Core extends Password {
*/ */
private function checkResult($result) { private function checkResult($result) {
if ($result === 'maxlag' || $result === 'readonly' || $result === 'unknownerror-nocode' || $result === 'unknownerror' || $result === 'ratelimited') { if ($result === 'maxlag' || $result === 'readonly' || $result === 'unknownerror-nocode' || $result === 'unknownerror' || $result === 'ratelimited') {
echo "\nAction failed. Reason: " . $result . ". Please try again"; $this->echoMsg("Action failed. Reason: " . $result . ". Please try again", "error");
return 'retry'; return 'retry';
} else if ($result === 'blocked' || $result === 'confirmemail' || $result === 'autoblocked') { } else if ($result === 'blocked' || $result === 'confirmemail' || $result === 'autoblocked') {
throw new Exception("You will not be able to execute writing actions soon. Reason: " . $result); throw new Exception("You will not be able to execute writing actions soon. Reason: " . $result);
...@@ -336,12 +336,12 @@ class Core extends Password { ...@@ -336,12 +336,12 @@ class Core extends Password {
$this->login(); $this->login();
return "retry"; return "retry";
} else if ($result === "editconflict") { } else if ($result === "editconflict") {
echo "\nEditconflict detected"; $this->echoMsg("Editconflict detected", "error");
return "conflict"; return "conflict";
} else if ($result === "nosuchsection") { } else if ($result === "nosuchsection") {
return "nosuchsection"; return "nosuchsection";
} else { } else {
echo "\nAction failed. Error: " . $result; $this->echoMsg("Action failed. Error: " . $result, "error");
return "fail"; return "fail";
} }
} }
...@@ -1120,7 +1120,7 @@ class Core extends Password { ...@@ -1120,7 +1120,7 @@ class Core extends Password {
return $result; return $result;
} }
} catch (Exception $e) { } catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n"; $this->echoMsg("Error: " . $e->getMessage() . "\n", "critical");
return false; return false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment