-
Notifications
You must be signed in to change notification settings - Fork 0
Small cleanup fixes #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8855585
92608fd
7db0a91
b8e3b4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
namespace Longman\TelegramBot; | ||
|
||
use Longman\TelegramBot\DB; | ||
use Longman\TelegramBot\Exception\TelegramException; | ||
|
||
/** | ||
* Class ConversationDB | ||
|
@@ -63,7 +64,7 @@ public static function selectConversation($user_id, $chat_id, $limit = null) | |
|
||
$results = $sth->fetchAll(\PDO::FETCH_ASSOC); | ||
|
||
} catch (PDOException $e) { | ||
} catch (\Exception $e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PDOException didn't work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, unfortunately not 😕 This is the exception I get, which is not caught:
I checked the PDO documentation and found that the PDOException is the only exception type available, but the one being thrown is not of that type. If you can find a more specific one to catch that would be great, but I didn't find any... |
||
throw new TelegramException($e->getMessage()); | ||
} | ||
return $results; | ||
|
@@ -106,7 +107,7 @@ public static function insertConversation($user_id, $chat_id, $command) | |
$sth->bindParam(':date', $created_at); | ||
|
||
$status = $sth->execute(); | ||
} catch (PDOException $e) { | ||
} catch (\Exception $e) { | ||
throw new TelegramException($e->getMessage()); | ||
} | ||
return $status; | ||
|
@@ -178,7 +179,7 @@ public static function update($table, array $fields_values, array $where_fields_ | |
try { | ||
$sth = self::$pdo->prepare($query); | ||
$status = $sth->execute($tokens); | ||
} catch (PDOException $e) { | ||
} catch (\Exception $e) { | ||
throw new TelegramException($e->getMessage()); | ||
} | ||
return $status; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a stop the conversation I can leave conversation data inside instead to reset everything.
php-telegram-bot#104 (comment)
I my last comment i said that could be a nice idea to have a var for each column of the database instead of store everything inside the '$this->conversation' var
something like :
This can be useful because after updating we can just update the status var inside the class.
Do you think that this can work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between
stop()
andcancel()
?The way I understood it, is that a stopped conversation is one that's ended normally and a cancelled conversation has been cancelled somewhere in the middle of a conversation.
Is this right?
Since there's no way to "resume" a conversation at the moment, both
stop()
andcancel()
stop and end the conversation, marking it as "finished" so to speak. So either one would need to be restarted as a new conversation afterwards.Now about the separate variables in the class:
It could work both ways. Either as you say, or to modify the
update()
method to update the$conversation
variable for us.I still think it would be useful to have a specific getter and setter for the notes and a
revert()
command or something to undo any changes and not update them to the DB, but we'll discuss this in a later stage.