Commit 19048f8f authored by MBoretto's avatar MBoretto

fix chat type and cs

parent 7f170b07
......@@ -69,7 +69,7 @@ class ChatsCommand extends Command
$chat = new Chat($result);
if ($chat->isPrivateChat()) {
$text .= '- P '.$chat->tryMentionChat()."\n";
$text .= '- P '.$chat->tryMention()."\n";
++$user_chats;
} elseif ($chat->isGroupChat()) {
$text .= '- G '.$chat->getTitle()."\n";
......
......@@ -38,7 +38,7 @@ class SendtoallCommand extends Command
$data['text'] = 'Sorry no database connection, unable to execute '.$this->name.' command.';
$result = Request::sendMessage($data);
return $result->isOk();
}
}
public function execute()
{
......
......@@ -30,6 +30,6 @@ class ChannelchatcreatedCommand extends Command
$channel_chat_created = $message->getChannelChatCreated();
// temporary do nothing
return 1
return 1;
}
}
......@@ -30,6 +30,6 @@ class GroupchatcreatedCommand extends Command
$group_chat_created = $message->getGroupChatCreated();
// temporary do nothing
return 1
return 1;
}
}
......@@ -57,37 +57,37 @@ class WeatherCommand extends Command
return false;
}
try{
$data = $this->getWeather($location);
$decode = json_decode($data, true);
if (empty($decode) || $decode['cod'] != 200) {
return false;
}
$city = $decode['name'];
$country = $decode['sys']['country'];
$temp = 'The temperature in ' . $city . ' (' . $country . ') is ' . $decode['main']['temp'] . '°C';
$conditions = 'Current conditions are: ' . $decode['weather'][0]['description'];
switch (strtolower($decode['weather'][0]['main'])) {
case 'clear':
$conditions.= ' ☀';
break;
case 'clouds':
$conditions.= ' ☁☁';
break;
case 'rain':
$conditions.= ' ☔';
break;
case 'thunderstorm':
$conditions.= ' ☔☔☔☔';
break;
}
$result = $temp . "\n" . $conditions;
try {
$data = $this->getWeather($location);
$decode = json_decode($data, true);
if (empty($decode) || $decode['cod'] != 200) {
return false;
}
$city = $decode['name'];
$country = $decode['sys']['country'];
$temp = 'The temperature in ' . $city . ' (' . $country . ') is ' . $decode['main']['temp'] . '°C';
$conditions = 'Current conditions are: ' . $decode['weather'][0]['description'];
switch (strtolower($decode['weather'][0]['main'])) {
case 'clear':
$conditions.= ' ☀';
break;
case 'clouds':
$conditions.= ' ☁☁';
break;
case 'rain':
$conditions.= ' ☔';
break;
case 'thunderstorm':
$conditions.= ' ☔☔☔☔';
break;
}
$result = $temp . "\n" . $conditions;
} catch (\Exception $e) {
$result = '';
}
......
......@@ -59,7 +59,7 @@ class DB
*
* @param array credential, string table_prefix
*/
public static function initialize(array $credentials, $table_prefix = null, Telegram $telegram)
public static function initialize(array $credentials, Telegram $telegram, $table_prefix = null)
{
self::$telegram = $telegram;
if (empty($credentials)) {
......@@ -338,7 +338,7 @@ class DB
//this can be also a message sent by the bot to the user
$fake_update['update_id'] = 0;
$fake_update['message'] = $reply_to_message->reflect();
// please notice that, as explaied in the documentation, reply_to_message don't contain other
// please notice that, as explaied in the documentation, reply_to_message don't contain other
// reply_to_message field so recursion deep is 1
self::insertRequest(new Update($fake_update, self::$telegram->getBotName(), 1));
}
......
......@@ -117,7 +117,7 @@ class Chat extends Entity
public function tryMention()
{
if ($chat->isPrivateChat()) {
if ($this->isPrivateChat()) {
if (is_null($this->username)) {
if (!is_null($this->last_name)) {
return $this->first_name.' '.$this->last_name;
......@@ -126,6 +126,6 @@ class Chat extends Entity
}
return '@'.$this->username;
}
return $chat->getTitle();
return $this->getTitle();
}
}
......@@ -180,7 +180,7 @@ class Telegram
*/
public function enableMySQL(array $credential, $table_prefix = null)
{
$this->pdo = DB::initialize($credential, $table_prefix, $this);
$this->pdo = DB::initialize($credential, $this, $table_prefix);
$this->mysql_enabled = true;
}
......
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