Skip to content
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

Support multiple teams #60

Open
maknz opened this issue Jun 26, 2016 · 4 comments
Open

Support multiple teams #60

maknz opened this issue Jun 26, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@maknz
Copy link
Owner

maknz commented Jun 26, 2016

We need to support multiple teams. As part of the 2.0 release, we'll be moving away from simply an 'endpoint' and have a first-class Team object. A client can be instantiated with one or more teams. Each team will have a default channel, and a name which can be used to refer to that team, e.g. 'mycompany'.

Example usage:

$team = new Team(['name' => 'mycompany', 'webhook' => 'https://hooks.slack.com/...', 'default_channel' => '#general']);
$client = new Client($team);
$client->send('Hello'); // sends to the one team configured, to the default channel of #general
$teams = [
  new Team(['name' => 'company1', 'webhook' => 'https://hooks.slack.com/...', 'default_channel' => '#engineering']),
  new Team(['name' => 'company2', 'webhook' => 'https://hooks.slack.com/...', 'default_channel' => '#devops'])
];

$client = new Client($teams);
$client->team('company1')->send('hello company1'); // #engineering in company1
$client->team('company2')->send('hello company2'); // #devops in company2

The full lead up discussion to the feature is over at #44.

I plan to work on this next weekend.

@Gummibeer
Copy link

Wouldn't it be cool to be able to instantiate a Client just by Team name!? Something like: new Client('mycompany'); this will make it easier to use the default settings. Same would be possible with an array new Client(['company1', 'company2']);.

@maknz
Copy link
Owner Author

maknz commented Jun 28, 2016

You'd still need to provide the endpoints as well, so wrapping all that up in a Team seems to solve that while still keeping the client easy to interact with.

Ideally the client would generally only be instantiated in the Laravel service provider, or some other IoC type deal. But, even if it was in a a controller, it should still be a one-off thing.

We could also have an addTeam method to Client so you could just do new Client and then $instance->addTeam($team)->addTeam($anotherTeam).

@Gummibeer
Copy link

Gummibeer commented Jun 29, 2016

Ok, so the teams are not in the config file? It feels a bit away from the quick and simple usage yet.
My idea is something like the different DB connections - everything is in the config file and you have a default one - so the usage of \Slack::send('Hello world!'); is possible but it's also possible to use it like \Slack::team('myteam')->send('hello world') or with an array of teams \Slack::team(['myteam1', 'myteam2'])->send('hello world') and with the Team object \Slack::team(new Team(...))->send('hello world') or with an array of team objects or mix it up.

Edit: Ok, you have moved the laravel parts in another repo - sorry. So this is everything thought for laravel.^^

@maknz
Copy link
Owner Author

maknz commented Jun 29, 2016

Ah yes, sorry for the confusion. Yeah, for Laravel you'd have your teams in a config file, and then just simply Slack::team('company1')->send('message') 👍. The teams would be required for instantiating the client for uses outside Laravel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants