-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
47 lines (37 loc) · 949 Bytes
/
main.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
43
44
45
46
47
#!/usr/bin/php
<?php
function Die_program_not_correct_parameter (){
global $argc, $argv;
echo $argv[0] . ' [sendmessage] room' . "\n";
die (3);
}
function main() {
global $argc, $argv;
if (!file_exists("config.php"))
{
echo "File config.php doesn't exists, please configure this matrix client\n";
die (10);
}
include_once("config.php");
include_once("matrixlib.php");
$matrix_client = new MatrixConnector($username, $password, $matrix_server);
if (isset($argv[1])) {
switch ($argv[1]){
case 'sendmessage':
$room = $argv[2];
$message = file_get_contents("php://stdin", "r");
//var_dump($message);
$result = $matrix_client->sendMessage($room, $message);
if ($result)
{
echo "Message send\n";
} else {
echo "Message not send\n";
}
break;
default:
break;
}
}
}
main();