Skip to content

Conversation

jacklul
Copy link
Collaborator

@jacklul jacklul commented Jun 5, 2017

This can be particulary useful now since bots can receive channel messages.

I hope I didn't miss anything, I guess travis will tell...

@jacklul jacklul requested a review from noplanman June 5, 2017 15:27
@@ -58,6 +58,7 @@ public function execute()
$results = DB::selectChats(
Copy link
Member

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 😖

Copy link
Collaborator Author

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?

Copy link
Member

@noplanman noplanman Jun 13, 2017

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',
]);

Copy link
Member

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.

@noplanman noplanman merged commit 195910c into php-telegram-bot:develop Jun 20, 2017
@jacklul jacklul deleted the selectchats_channels branch June 20, 2017 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants