-
-
Notifications
You must be signed in to change notification settings - Fork 962
Allow selecting channels with selectChats() and sendToActiveChats() #524
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
Allow selecting channels with selectChats() and sendToActiveChats() #524
Conversation
@@ -58,6 +58,7 @@ public function execute() | |||
$results = DB::selectChats( |
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.
This is screaming for bit flags / bitmask:
https://stackoverflow.com/questions/11880360/how-to-implement-a-bitmask-in-php
Having so many boolean parameters is just waaay confusing 😖
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.
Well, I think I have no clue how to do this in a clean way, I would have to declare those somewhere, but where to make them accessible at all time?
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.
An option could be to just pop them into the DB class:
const SINGLE_CHAT = 1;
const GROUP_CHAT = 2;
const SUPERGROUP_CHAT = 4;
const CHANNEL = 8;
But this may seem a bit confusing 😕
Probably makes sense to do the same here like with other parameters, passing the values as an array (as described further down from my link above: https://stackoverflow.com/a/29089798):
$results = DB::selectChats([
'groups' => true,
'supergroups' => true,
'channels' => true,
'single_chats' => true, // or 'user_chats', or just 'single'?
'date_from' => 'yyyy-mm-dd hh:mm:ss', // or better, use DateTimeImmutable objects
'date_to' => 'yyyy-mm-dd hh:mm:ss',
]);
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.
@jacklul Have made a PR to your PR that implements the solution with the array, please check it out when you have a moment, thanks.
Use array for select-parameters, instead of individual parameters.
This can be particulary useful now since bots can receive channel messages.
I hope I didn't miss anything, I guess travis will tell...