static function schedule($id, $datetime = NULL) { if ($datetime === NULL) { $datetime = time(); } $dane = simplexml_load_file(self::$file); $abc = $dane->xpath('programme[@channel=\'' . $id . '\' and number(substring(@stop, 1, 12))>\'' . date('YmdHi', $datetime) . '\' and number(substring(@start, 1, 12))<\'' . date('YmdHi', $datetime + 3600 * 24) . '\']'); $last = 0; $concat = ''; foreach ($abc as $value) { $now = date('d.m.Y', strtotime(substr($value['start'], 0, -6))); if ($now != $last) { if (!empty($concat)) { GGapi::putRichText($concat); } GGapi::putRichText("\n" . $now . "\n", TRUE); $last = $now; $concat = ''; } $concat .= date('H:i', strtotime(substr($value['start'], 0, -6))) . ' ' . $value->title . "\n"; } if (!empty($concat)) { GGapi::putRichText($concat); } }
static function help($cmd = NULL) { if ($cmd === NULL) { GGapi::putRichText('rej ', TRUE); GGapi::putRichText('rejestracja', FALSE, TRUE); GGapi::putRichText("\n" . ' Informacje o polskiej tablicy rejestracyjnej' . "\n"); } else { GGapi::putRichText('rej ', TRUE); GGapi::putRichText('rejestracja', FALSE, TRUE); GGapi::putRichText("\n" . ' Zwraca informacje o tablicy rejestracyjnej. Jak argument należy podać pełny, poprawny numer lub tylko wyróżnik (1-3 liter).'); } }
static function help($cmd = NULL) { if ($cmd === NULL) { GGapi::putRichText('humor', TRUE); GGapi::putRichText("\n" . ' Coś humorystycznego' . "\n"); } else { GGapi::putRichText('humor', TRUE); GGapi::putRichText(' (alias: '); GGapi::putRichText('s, smieszne', TRUE); GGapi::putRichText(')' . "\n" . ' Coś humorystycznego na dziś'); } }
static function cmd_kurs($nazwa, $argument) { $argument = funcs::utfToAscii(trim($argument)); if (isset(self::$name2iso[$argument])) { $argument = self::$name2iso[$argument]; } else { $argument = strtoupper($argument); } $waluty_A = unserialize(file_get_contents('./data/kurs/A_kursy.txt')); if (empty($argument)) { $waluty_C = unserialize(file_get_contents('./data/kurs/C_kursy.txt')); $txt = 'Kursy średnie walut obcych z dnia ' . $waluty_A['i_n_f_o']['data'] . ' (tabela NBP nr ' . $waluty_A['i_n_f_o']['tabela'] . ') oraz kursy kupna i sprzedaży z dnia ' . $waluty_C['i_n_f_o']['data'] . ' (tabela NBP nr ' . $waluty_C['i_n_f_o']['tabela'] . ')' . "\n"; foreach ($waluty_C as $kod => $dane) { if ($kod == 'i_n_f_o') { continue; } $txt .= "\n" . $dane['ilosc'] . ' ' . $kod . ' => ' . $waluty_A[$kod]['kurs'] . ' PLN'; $txt .= ' (kupno: ' . $dane['kupno'] . ' PLN, sprzedaż: ' . $dane['sprzedaz'] . ' PLN)'; } GGapi::putText($txt); return TRUE; } if (isset($waluty_A[$argument])) { $txt = 'Kursy średnie walut obcych z dnia ' . $waluty_A['i_n_f_o']['data'] . ' (tabela NBP nr ' . $waluty_A['i_n_f_o']['tabela'] . ')'; $waluty_C = unserialize(file_get_contents('./data/kurs/C_kursy.txt')); if (isset($waluty_C[$argument])) { $txt .= ' oraz kursy kupna i sprzedaży z dnia ' . $waluty_C['i_n_f_o']['data'] . ' (tabela NBP nr ' . $waluty_C['i_n_f_o']['tabela'] . ')'; } $txt .= "\n\n" . $waluty_A[$argument]['ilosc'] . ' ' . $argument . ' => ' . $waluty_A[$argument]['kurs'] . ' PLN'; if (isset($waluty_C[$argument])) { $txt .= ' (kupno: ' . $waluty_C[$argument]['kupno'] . ' PLN, sprzedaż: ' . $waluty_C[$argument]['sprzedaz'] . ' PLN)'; } GGapi::putText($txt); return TRUE; } else { $waluty_B = unserialize(file_get_contents('./data/kurs/B_kursy.txt')); if (!isset($waluty_B[$argument])) { GGapi::putText('Nie znaleziono żądanej waluty. Sprawdź, czy kod waluty jest zgodny z ISO 4217.' . "\n\n"); GGapi::putRichText('Przykłady', FALSE, FALSE, TRUE); GGapi::putRichText("\n" . 'kurs USD' . "\n" . 'kurs EUR'); return FALSE; } GGapi::putText('Kursy średnie walut obcych z dnia ' . $waluty_B['i_n_f_o']['data'] . ' (tabela NBP nr ' . $waluty_B['i_n_f_o']['tabela'] . ')' . "\n\n" . $waluty_B[$argument]['ilosc'] . ' ' . $argument . ' => ' . $waluty_B[$argument]['kurs'] . ' PLN'); return TRUE; } }
static function cmd_tv($name, $args) { self::$file = './data/tv/xmltv-utf.xml'; self::$aliases = './data/tv/aliases'; $time = self::parse_date($args); if (empty($args)) { $args = $name; } $tv = self::aliases($args); if (!$tv) { GGapi::putText('Nieznana stacja telewizyjna. Spróbuj:' . "\n" . 'tv TVP 1' . "\n" . 'tv Discovery' . "\n\n" . 'lub wpisz '); GGapi::putRichText('lista', TRUE); GGapi::putRichText(' by uzyskać listę dostępnych stacji telewizyjnych'); return; } GGapi::putRichText('Program stacji ' . $tv . "\n", TRUE, FALSE, TRUE); self::schedule($tv, $time); }
static function cmd_bash($name, $arg) { $data = unserialize(file_get_contents('./data/bash/index.txt')); $arg = (int) trim($arg); if (!$arg || !isset($data[$arg])) { $arg = array_rand($data); } $data = $data[$arg]; $fp = fopen('./data/bash/text.txt', 'r'); fseek($fp, $data); $data = ''; $line = ''; while (!feof($fp) && trim($line) != '%') { $data .= $line; $line = fgets($fp); } fclose($fp); GGapi::putRichText('Cytat #' . $arg, TRUE); GGapi::putText("\n" . trim($data)); }
static function cmd_setex($name, $arg) { if (!$arg) { GGapi::putText('Podaj pełny adres kanału (z http://)!' . "\n\n"); GGapi::putRichText('Przykład:', FALSE, FALSE, TRUE); GGapi::putRichText("\n" . 'kanal2 http://wiadomosci.onet.pl/2,kategoria.rss'); } else { $ret = self::testurl($arg); if (is_object($ret)) { database::add($_GET['from'], 'rssex', 'kanal', $arg[1]); GGapi::putText('Kanał ' . $arg . ' został ustawiony jako domyślny. Teraz zamiast:' . "\n" . 'rss ' . $arg . "\n" . 'możesz wpisać samo' . "\n" . 'rss'); } elseif (is_array($ret)) { GGapi::putText('Nie udało się pobrać wybranego kanału RSS. Błąd: ' . $ret[1]); } else { GGapi::putText('Wystąpił nieznany błąd przy pobieraniu danych. Przepraszamy.'); } } }