-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull.php
More file actions
55 lines (46 loc) · 2.02 KB
/
pull.php
File metadata and controls
55 lines (46 loc) · 2.02 KB
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
<?php
/**
* firechat
*
* @author workonfire aka Buty935
* @version 2.0.0-alpha
*/
define('VERSION', '2.0.0-alpha');
// TODO: Jakieś tam zabezpieczenia
require "core/util.php";
require_once "api/PushConnection.php";
require_once "api/MessageBuilder.php";
require_once "core/User.php";
require_once "core/Room.php";
require_once "core/Group.php";
$config = require "config.php";
$PushConnection = new PushConnection($bot_number, $config['BotAPI']['login'], $config['BotAPI']['password']);
$db = new mysqli($config['database']['host'],
$config['database']['credentials']['username'],
$config['database']['credentials']['password'],
$config['database']['database_name']
);
$user = new User($gg_number);
if (!$user->exists) {
if ($PushConnection->isBot($gg_number))
finalMessage("Rejestracja zakończyła się niepowodzeniem. Jesteś botem!", null, "PULL", "ERROR");
registerNewUser($gg_number);
$user = new User($gg_number);
sendMessage("Użytkownik {$user->nick} zarejestrował się na czacie.", getOnlineUsers(new Room('main')), "PUSH");
finalMessage("Rejestracja przebiegła pomyślnie. Użyj komendy /join, by się zalogować.", null, "PULL", "INFO");
}
if ($user->online == 0) {
$command = $command == "j" ? "join" : $command;
if ($command != "join") finalMessage("Nie jesteś zalogowany. Użyj komendy /join, by się zalogować.",
null, "PULL", "WARN");
}
if ($message[0] != '/' AND $message[0] != '.' AND $user->online == 1)
sendMessage("{$user->group->prefix}{$user->nick}: {$message}", getOnlineUsers(new Room($user->room)), "PUSH");
else {
$command_shortcuts = include "core/command_shortcuts.php";
if (in_array($command, $command_shortcuts)) $command = array_search($command, $command_shortcuts);
$command_path = "core/commands/{$command}.php";
if ($command == '') finalMessage("Podaj nazwę komendy.", null, "PULL", "WARN");
if (file_exists($command_path)) include $command_path;
else finalMessage("Komenda /{$command} nie istnieje.", null, "PULL", "WARN");
}