Commit 97a890a2 authored by Luke081515's avatar Luke081515

Let the user choose a different pattern

* Allows the user to enter a pattern different from the needle
parent 4c843f21
Pipeline #1814 failed with stages
in 1 minute and 42 seconds
...@@ -11,6 +11,7 @@ require './Cygnus/BotCore.php'; ...@@ -11,6 +11,7 @@ require './Cygnus/BotCore.php';
class Corrector extends Core { class Corrector extends Core {
private $summary; private $summary;
private $search; private $search;
private $pattern;
private $replace; private $replace;
private $needle; private $needle;
private $accountname; private $accountname;
...@@ -29,6 +30,9 @@ class Corrector extends Core { ...@@ -29,6 +30,9 @@ class Corrector extends Core {
* Defines the condition for search and replace * Defines the condition for search and replace
*/ */
private function defineConditions () { private function defineConditions () {
if ($this->askOperator('Use a pattern? [y/N] ') === 'y') {
$this->pattern = $this->askOperator('What should be the pattern? ');
}
$needle = $this->askOperator('What should be replaced? '); $needle = $this->askOperator('What should be replaced? ');
$replace = $this->askOperator('What should be the replacement? '); $replace = $this->askOperator('What should be the replacement? ');
$this->needle = $needle; $this->needle = $needle;
...@@ -59,8 +63,11 @@ class Corrector extends Core { ...@@ -59,8 +63,11 @@ class Corrector extends Core {
*/ */
private function searchPages () { private function searchPages () {
echo "\n" . 'Searching…' . "\n"; echo "\n" . 'Searching…' . "\n";
$suche = urlencode('insource:' . $this->needle); if (isset($this->pattern)) {
$suche = urlencode($this->pattern);
} else {
$suche = urlencode('insource:' . $this->needle);
}
$i = 0; $i = 0;
$Again = true; $Again = true;
$Continue = '0'; $Continue = '0';
......
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