| | |
| | | foreach($data as $func) { |
| | | if(!is_file(BOT_TOPDIR.$func['dir'].$func['file'])) { |
| | | $st = $this->PDO->prepare('DELETE FROM functions WHERE dir=? AND file=?'); |
| | | $st->excecute(array($func['dir'], $func['file'])); |
| | | $st->execute(array($func['dir'], $func['file'])); |
| | | continue; |
| | | } |
| | | |
| | |
| | | <?php |
| | | @date_default_timezone_set('Europe/Warsaw'); |
| | | |
| | | class bot_data_module implements BotModule { |
| | | static $dni = array( |
| | | 'niedziela', |
| | |
| | | |
| | | if(empty($arg)) { |
| | | $data = time(); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | $data = calendar::parse_date($arg); |
| | | if(!$data) { |
| | | return new BotMsg('Podana data nie została rozpoznana<br />'."\n" |
| | |
| | | |
| | | if(date('d.m.Y') == date('d.m.Y', $data)) { |
| | | $txt = 'Dziś jest '; |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | $txt = 'Wybrany dzień to '; |
| | | } |
| | | |
| | | include('./data/data/data.php'); |
| | | |
| | | $txt .= self::$dni[date('w', $data)].', '.date('j', $data).' '.self::$miesiace[date('n', $data)].' '.date('Y').' r., '.(date('z', $data)+1).' dzień roku.<br />'."\n" |
| | | $txt .= self::$dni[date('w', $data)].', '.date('j', $data).' ' |
| | | . self::$miesiace[date('n', $data)].' '.date('Y').' r., ' |
| | | . (date('z', $data)+1).' dzień roku.<br />'."\n" |
| | | . '<br />'."\n"; |
| | | |
| | | $msg->session->setClass('pogoda'); |
| | | if(!isset($msg->session->geo)) { |
| | | $geo = array('lon' => '52.25', 'lat' => '21.0'); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | $geo = $msg->session->geo; |
| | | } |
| | | |
| | |
| | | . 'imieniny Ewy'); |
| | | } |
| | | |
| | | $txt = array(); |
| | | |
| | | foreach($imiona[$arg] as $dzien) { |
| | | $dzien = explode('.', $dzien); |
| | | |
| | |
| | | protected $xml; |
| | | protected $dane; |
| | | |
| | | static $symbols = array( |
| | | public static $symbols = array( |
| | | 1 => 'Słonecznie', |
| | | 2 => 'Lekkie zachmurzenie', |
| | | 3 => 'Częściowe zachmurzenie', |
| | |
| | | 23 => 'Deszcz ze śniegiem, burze' |
| | | ); |
| | | |
| | | static $wind = array( |
| | | public static $wind = array( |
| | | 'N' => 'północny', |
| | | 'NW' => 'północno-zachodni', |
| | | 'W' => 'zachodni', |
| | |
| | | 'NE' => 'północno-wschodni', |
| | | ); |
| | | |
| | | static function wind($dir) { |
| | | public static function wind($dir) { |
| | | if(isset(self::$wind[$dir])) { |
| | | return self::$wind[$dir]; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | function __construct($xml) { |
| | | public function __construct($xml) { |
| | | libxml_use_internal_errors(); |
| | | $this->xml = simplexml_load_string($xml); |
| | | libxml_clear_errors(); |
| | |
| | | } |
| | | } |
| | | |
| | | function mktime($time) { |
| | | public function mktime($time) { |
| | | return strtotime(substr($time, 0, -1)); |
| | | } |
| | | |
| | | function parseForecast() { |
| | | public function parseForecast() { |
| | | $this->dane = array( |
| | | '0h' => array(), |
| | | '3h' => array(), |
| | |
| | | } |
| | | } |
| | | |
| | | function getCurrentIcon() { |
| | | public function getCurrentIcon() { |
| | | $now = time(); |
| | | foreach($this->dane['3h'] as $value) { |
| | | if($value['from'] <= $now && $now < $value['to']) { |
| | |
| | | return NULL; |
| | | } |
| | | |
| | | function getCurrentWeather() { |
| | | public function getCurrentWeather() { |
| | | $dist = PHP_INT_MAX; |
| | | $current = NULL; |
| | | foreach($this->dane['0h'] as $time => $value) { |
| | |
| | | return $current; |
| | | } |
| | | |
| | | function getDaypartWeather($timestamp) { |
| | | public function getDaypartWeather($timestamp) { |
| | | $start = strtotime('6:00', $timestamp); |
| | | $dayend = strtotime('19:30', $timestamp); |
| | | $end = $start + 22*3600; |
| | |
| | | return array('temp' => $temp, 'wind' => $wind); |
| | | } |
| | | |
| | | function getDaypartIcon($timestamp) { |
| | | public function getDaypartIcon($timestamp) { |
| | | $start = strtotime('6:00', $timestamp); |
| | | $end = strtotime('24:00', $timestamp); |
| | | |
| | |
| | | $arg = trim($msg->args); |
| | | } |
| | | |
| | | $out = new BotMsg(); |
| | | |
| | | if(empty($arg)) { |
| | | if(isset($this->session->miasto)) { |
| | | if(isset($msg->session->miasto)) { |
| | | return new BotMsg('Aktualnie ustawione miejsce to: '.htmlspecialchars($this->session->miasto).', '.htmlspecialchars($this->session->countryName)); |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | $out = new BotMsg(); |
| | | |
| | | } |
| | | |
| | | $api = new api_geonames(); |
| | |
| | | MIASTO |
| | | */ |
| | | $miasta = self::getMiasta(); |
| | | $found = FALSE; |
| | | $miasto_num = $miasto_nazw = ''; |
| | | |
| | | if(!$miasta) { |
| | |
| | | foreach($miasta as $miasto => $numer) { |
| | | $szukaj = funcs::utfToAscii($miasto); |
| | | if(($pos = strpos($arg, $szukaj)) !== FALSE) { |
| | | $found = TRUE; |
| | | $miasto_nazw = htmlspecialchars($miasto); |
| | | $miasto_num = $numer; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if($found===FALSE && !empty($arg2)) { |
| | | if($miasto_num === '' && !empty($arg2)) { |
| | | foreach($miasta as $miasto => $numer) { |
| | | $szukaj = funcs::utfToAscii($miasto); |
| | | if(($pos = strpos($arg2, $szukaj)) !== FALSE) { |
| | | $found = TRUE; |
| | | $miasto_nazw = htmlspecialchars($miasto); |
| | | $miasto_num = $numer; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if($found === FALSE) { |
| | | if($miasto_num === '') { |
| | | $txt = 'Wybrane miasto nie został odnalezione. Obsługiwane miejscowości:'; |
| | | $miasto = 'Warszawa'; |
| | | foreach($miasta as $miasto => $num) { |
| | | $txt .= '<br />'."\n".htmlspecialchars($miasto); |
| | | } |
| | |
| | | KINO |
| | | */ |
| | | $kina = self::getKina($miasto_num, $czas); |
| | | $found = FALSE; |
| | | $kino_num = $kino_nazw = ''; |
| | | |
| | | if(!$kina) { |
| | |
| | | if(!empty($arg)) { |
| | | foreach($kina as $kino => $kino_id) { |
| | | if(levenshtein(funcs::utfToAscii($kino), $arg, 1, 1, 0) < 2) { |
| | | $found = TRUE; |
| | | $kino_num = $kino_id; |
| | | $kino_nazw = htmlspecialchars($kino); |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | if($found===FALSE && !empty($arg2)) { |
| | | if($kino_num === '' && !empty($arg2)) { |
| | | foreach($kina as $kino => $kino_id) { |
| | | if(levenshtein(funcs::utfToAscii($kino), $arg2, 1, 1, 0) < 2) { |
| | | $found = TRUE; |
| | | $kino_num = $kino_id; |
| | | $kino_nazw = htmlspecialchars($kino); |
| | | break; |
| | |
| | | } |
| | | } |
| | | |
| | | if($found === FALSE) { |
| | | if($kino_num === '') { |
| | | $txt = (!empty($arg) ? 'Podany obiekt nie został znaleziony. ' : '').'Dostępne kina w pasujących miastach:'; |
| | | $kino = ''; |
| | | foreach($kina as $kino => $num) { |
| | | $txt .= '<br />'."\n".$miasto_nazw.' '.htmlspecialchars($kino); |
| | | } |
| | |
| | | /* |
| | | REPERTUAR |
| | | */ |
| | | $filmy = self::getKino($miasto_num, $kino_id, $czas); |
| | | $filmy = self::getKino($miasto_num, $kino_num, $czas); |
| | | |
| | | if(!$filmy) { |
| | | return new BotMsg('Przepraszamy, wystąpił bład przy pobieraniu listy wyświelanych filmów.'); |