Skip to content
This repository was archived by the owner on Mar 30, 2024. It is now read-only.

Commit f3e2835

Browse files
committed
Fix #2
1 parent dc82b80 commit f3e2835

File tree

7 files changed

+18
-8
lines changed

7 files changed

+18
-8
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
latest
2-
0.1.0
2+
0.1.1
33
0.1
44
0

bot/Commands/Message/GenericmessageCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function execute(): ServerResponse
5252
return $this->replyToUser('Please use the commands /ttt and /task!');
5353
}
5454
else{
55-
$text = $this->getMessage()->getText(true);
55+
$text = \TTTBot\Utilities::trimAndConvertInput($this->getMessage()->getText(true));
5656

5757
switch($handler) {
5858
case "categoryAdd":

bot/Commands/StartCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function execute(): ServerResponse
4444
return $this->replyToUser('You have started the bot already. Use /ttt or /task!');
4545
}
4646
else {
47-
$token = $this->getMessage()->getText(true);
47+
$token = \TTTBot\Utilities::trimAndConvertInput($this->getMessage()->getText(true));
4848
if( empty($token) ){
4949
return $this->replyToUser(
5050
'This bot requires you to register for the usage. Please get a token from your admin or host your own version!' . PHP_EOL .

bot/Commands/TaskCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function execute(): ServerResponse
5151
* Handle new Tasks
5252
*/
5353

54-
$text = $this->getMessage()->getText(true);
54+
$text = \TTTBot\Utilities::trimAndConvertInput($this->getMessage()->getText(true));
5555

5656
$th = new \TTTBot\AddTaskHelper($session);
5757
$th->taskCommand($text);

bot/Commands/TttCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function execute(): ServerResponse
5050
* Handle normal TTT Commands
5151
*/
5252
// get command
53-
$command = $this->getMessage()->getText(true);
53+
$command = \TTTBot\Utilities::trimAndConvertInput($this->getMessage()->getText(true));
5454
$command = explode(' ', $command);
5555

5656
// disallowed

bot/classes/AddTaskHelper.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ public function taskCommand(string $params) : void {
3535
if(!empty($params)){
3636
$params = \explode(' ', $params);
3737
if(\count($params) === 3){
38-
$this->runTTT($params[2], $params[0], $params[1]);
38+
$this->runTTT(trim($params[2]), trim($params[0]), trim($params[1]));
3939
}
4040
else if(\count($params) === 1 &&
4141
$this->session->getData('lastCategory') !== false &&
4242
$this->session->getData('lastTask') !== false
4343
){
4444
$time = str_replace('+', '', $params[0]);
45-
$this->runTTT($time, $this->session->getData('lastCategory'), $this->session->getData('lastTask'));
45+
$this->runTTT(trim($time), $this->session->getData('lastCategory'), $this->session->getData('lastTask'));
4646
}
4747
else{
48+
$this->runTTT("", "", "");
4849
$this->answer = "Use `/task Category Task 20m` or `/task +20m` or just `/task` for Step-by-Step query";
4950
}
5051
}
5152
else{
53+
$this->runTTT("", "", "");
5254
$this->answer = "Recoding new Task Step-by-Step, one may also use `/task Category Task 20m` or `/task +20m`." . PHP_EOL;
5355
$this->answer .= TTTLoader::runTTTCommand(['c', 'c', 'list']);
5456
$this->answer .= "Please choose a category:";
@@ -62,7 +64,7 @@ public function messageCommand(string $text) : void {
6264
switch($this->session->getTemp('taskStep')){
6365
case "category":
6466
$this->answer = "Please give the name of the task now:";
65-
$this->session->setData('lastCategory', $text);
67+
$this->session->setData('lastCategory', $text);
6668
$this->session->setTemp('taskStep', 'task');
6769
break;
6870
case "task":

bot/classes/Utilities.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ public static function randomCode( $len, $chars ){
6464
}
6565
return $r;
6666
}
67+
68+
public static function trimAndConvertInput(string $s) : string {
69+
return \str_replace(
70+
['ä','ü','ö','ß','Ä','Ü','Ö'],
71+
['ae','ue','oe','ss','Ae','Ue','Oe'],
72+
trim($s)
73+
);
74+
}
6775
}
6876

6977
?>

0 commit comments

Comments
 (0)