dzunke / slackbundle Goto Github PK
View Code? Open in Web Editor NEWSlackBundle for Symfony2 with Guzzle-Integration
License: MIT License
SlackBundle for Symfony2 with Guzzle-Integration
License: MIT License
You send everything via GET, meaning it has certain limits. The only reason why I used this bundle was that I was too lazy to implement my own Slack API, and I needed to do that because webhooks do not allow you to upload files/snippets. WIth your bundle you can upload a snippet, but you're limited by max GET length. (414 Request-URI Too Large
)
Auto-registration of the command "DZunke\SlackBundle\Command\BotMessagingCommand" is deprecated since Symfony 3.4
Also for:
Just being in the Command/ directory is no longer enough. They must also be tagged. This can be done explicitly, listing them in the ./Resources/config/services.yml file, or with Symfony 3.3+ they can also be tagged if they extend a particular class - Symfony\Component\Console\Command\Command
is probably best.
Is this bundle going to be compatible with Symfony 4? I'd like to upgrade my application but I'd have to replace this Slack bundle. Is there anything I could help you with?
What about an SF5 compatibility?
Hi @DZunke, thanks for this useful package.
I'm in the process of upgrading a legacy codebase from Symfony 3.4 to 4.1.
And I was wondering if you have plans for supporting Sy4 anytime soon "like within 48 hours"!?
It's ok if you don't have time for it now, I may get someone or myself to handle it and contribute back, if you don't mind.
Best,
With the move in Symfony to defaulting all services to private, unless explicitly set public, using code like $this->getContainer()->get('dz.slack.users');
to get the services within the code is also somewhat obsolete.
By registering commands as services (see #28) it is also now better to inject any services into the constructor wherever possible rather than extending ContainerAwareCommand (extend Symfony\Component\Console\Command\Command
).
Hello @DZunke,
Thx for your work & this component.
I have been using this for several months without any problem. He is integrate in Symfony stack (v2.8 & more). Since yesterday in 2.4.0 I've a problem with service.
When I wanna clear my cache, I've this Exception :
[InvalidArgumentException]
Class "" used for service "dzunke\slackbundle\command\botmessagingcommand" cannot be found.
My configuration is really minimalist.
In my config.yml :
# Monolog configuration
monolog:
handlers:
# Slack logging
slack:
type: service
id: log_slack
d_zunke_slack:
token: "MyPrivateToken"
verify_ssl: false
identities:
my_profile:
icon_url:
icon_emoji:
In my services.yml :
log_slack:
class: DZunke\SlackBundle\Monolog\Handler\SlackHandler
# 400 = ERROR, see Monolog::Logger for the values of log levels
arguments: ['@dz.slack.messaging', '%channel_slack%', "my_profile", 400]
Have you got the same behavior ? Do you need more informations ?
Thx
Since the v2.0, in my localhost when SlackBundle wants to send one message, i've this error :
cURL error 60: SSL certificate problem: unable to get local issuer certificate
So I think this is a problem since you remplace guzzle by httpguzzle ?
Maybe you can let us set few parameters when you create ur $guzzle.
In fact, I think I need, in executeRequest method :
$client = new GuzzleHttp\Client(['defaults' => ['verify' => false]]);
Can we set parameters ?
In Symfony 3.4, the cannotBeEmpty directive cause this message:
Using Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::cannotBeEmpty() at path "d_zunke_slack.identities" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.
in DZunke/SlackBundle/DependencyInjection/Configuration.php:
/** @var $connectionNode ArrayNodeDefinition */
$microservicesNode = $node->requiresAtLeastOneElement()
->useAttributeAsKey('username')
->cannotBeEmpty()
->info('Usernames to use for Communication inside the Messaging')
->prototype('array');
Removing cannotBeEmpty() solve the deprecated alert (and I think requiresAtLeastOneElement and useAttributeAsKey should not be used at the same time).
The working version:
/** @var $connectionNode ArrayNodeDefinition */
$microservicesNode = $node->requiresAtLeastOneElement()
->useAttributeAsKey('username')
->info('Usernames to use for Communication inside the Messaging')
->prototype('array');
Would it be complicated to add the possibility to create a channel?
This way from an external app you can create it and then start publishing into it.
There is a warning with guzzle composer dependency.
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
From
->setName('dzunke:slack:message')
->setAliases(['slack:message'])
to
->setName('slack:message')
etc, in the commands configure()
methods. This closes the commit from db0247c
Tokens are deprecated. They are only for testing purposes.
https://api.slack.com/docs/oauth-test-tokens
It is needed to implement oauth2 as the prefered authentication.
I tried to add the icon_url attribute. I tried both with a file on my local machine and a file that is openly accessible. In both cases it's not showing.
I imagine, being an url, that that file must be accessible from outside (a public url).
Anyways, I've read in the documentation that it must be used in conjunction with "as_user = false" otherwise it gets ignored. But we cannot specify as_user = false as attribute when creating a message, right? Maybe because it was not accessible under https?
Hello everyone!
I'm struggling tonight by trying to put a link within the message. I try to follow this documentation
and it doesn't work. I thought that it was the HTTP method the problem so I changed GET to POST and I have the same result.
Regarding slack documentation, it shoud work like this.
Here is my code:
$identity = new \DZunke\SlackBundle\Slack\Messaging\Identity();
$identity->setUsername($sender->getFullName());
$identity->setIconUrl($avatar);
$this->slack->send(Actions::ACTION_POST_MESSAGE,
[
'identity' => $identity,
'channel' => "system",
'text' => "HEY <http://google.be|google>",
'icon_url' => $avatar,
'unfurl_links' => 0,
'parse' => 'full',
]);
With also this additional method:
public function send($action, array $parameter = [])
{
try {
if (isset($parameter["channel"]) AND $this->env != "prod") {
$parameter["channel"] = "#debug";
}
$this->originalSlackClient->send($action, $parameter);
} catch (\Exception $e) {
$context = $parameter;
if (isset($context['identity'])) unset($context['identity']);
$this->logger->error("Failed to send message to slack", $context);
}
}
`
And finally here is my configuration:
d_zunke_slack:
token: "ZZZ"
use_http_post: true
identities:
spartan: ~`
Could someone give me an example of message containing link in order to have an example?
Thank you in advance and thanks a lot for this bundle!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.