-
Notifications
You must be signed in to change notification settings - Fork 1
/
StatusBot.php
73 lines (55 loc) · 2.5 KB
/
StatusBot.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require("codebird\Codebird");
/**
* Single server query
*/
$server = new statusbot\ServerQuery("Play.network.net", 19132, "mcpe");
$server->query();// updates the data from the servers
// Eampe of how to use the single server Query in a tweet
$serverTweet = "Your Server Status!\n\nPlayers: " . (int) $server->getOnlinePlayers() . "/" . (int) $server->getMaxPlayers() . "\n Server is " . ($server->isOnline() ? "online" : "offline");
/**
* Gamemode query
*/
// You can add and remove servers to this array but make sure to keep the formatting.
$servers = [
"example.network.net:19132/mcpe",
"example2.network.net:19133/mcpe",
"example3.network.net:19134/mcpe",
"example4.network.net:19135/mcpe"
];
$gamemode = new statusbot\GamemodeQuery($servers);
$gamemode->query(); // updates the data from the servers
// Example of how to use the the gamemode Query in a tweet
$gamemodeTweet = "Your Gamemode Status!\n\nGamemode\nPlayers: " . (int) $gamemode->getOnlinePlayers() . "/" . (int) $gamemode->getMaxPlayers() . "\nServers: " . (int) $gamemode->getOnlineServers() . "/" . (int) $gamemode->getMaxServers();
/**
* Network Query
*/
$gamemodes = [
"example" => [
"example1.network.net:19132/mcpe",
"examlple2.network.net:19133/mcpe"
],
"2example" => [
"2example1.network.net:19132/mcpe",
"2example2.network.net:19133/mcpe"
]
];
$network = new statusbot\NetworkQuery($gamemodes);
$network->query();
// Example of how to use the the network Query in a tweet
$networkTweet = "Network Status!\n Example:\n Players: " . (int) $network->getOnlinePlayers("example") . "/" . (int) $network->getMaxPlayers("example") . " Servers: " . (int) $network->getOnlineServers("example") . "/" . (int) $network->getMaxServers("example") . "Example2:" . "\n Players: " . (int) $network->getOnlinePlayers("2example") . "/" . (int) $network->getMaxPlayers("2example") . "\n Servers: " . (int) $network->getOnlineServers("2example") . "/" . (int) $network->getMaxServers("2example");
/**
* Tweet!
*/
// Edit these to match your twitter apps info (Must be a registered application account)
$consumerKey = "";
$consumerSecret= "";
$accessToken = "";
$accessTokenSecret = "";
\codebird\Codebird::setConsumerKey($consumerKey, $consumerSecret);
$codebird = \codebird\Codebird::getInstance();
$codebird->setToken($accessToken, $accessTokenSecret);
$tweets = [$serverTweet, $gamemodeTweet, $networkTweet];
foreach($tweets as $tweet) {
$codebird->statuses_update(["status" => $tweet]);
}