-
Notifications
You must be signed in to change notification settings - Fork 26
/
hipchat.php
42 lines (36 loc) · 1.21 KB
/
hipchat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR . "autoload.php";
// import namespaces
use Namshi\Notificator\Manager;
use Namshi\Notificator\Notification\Handler\HipChat as HipChatHandler;
use HipChat\HipChat;
use Namshi\Notificator\Notification\HipChat\HipChatNotification;
// create the manager
$manager = new Manager(array(new HipChatHandler(new HipChat(
'YOUR_API_TOKEN_HERE'
))));
// lets have some fun
$messages = array(
'Yo @here',
'I am coming',
'to announce',
'that this notifications',
'are coming',
'from an ugly bot',
'and come from PHP',
'Can you imagine that now you can send messages to',
'HipChat directly from a script?',
'And you know what?',
'Python SUCKS. BIG TIME.'
);
// trigger multiple notifications!
foreach ($messages as $message) {
// create the notification
$notification = new HipChatNotification($message, 'NotificatorBot', 'Spam', array(
'hipchat_notify' => true,
'hipchat_color' => HipChat::COLOR_GREEN,
'hipchat_message_format' => HipChat::FORMAT_TEXT,
));
// trigger the notification
$manager->trigger($notification);
}