commit | author | age
|
8bd4d9
|
1 |
<?php |
JK |
2 |
include('./data/tv/xmltv_parse.php'); |
|
3 |
|
|
4 |
class tv extends xmltv_parse implements module { |
|
5 |
static function register_cmd() { |
|
6 |
return array( |
|
7 |
't' => 'cmd_tv', |
|
8 |
'tv' => 'cmd_tv', |
|
9 |
'program' => 'cmd_tv', |
|
10 |
'tvp' => 'cmd_tv', |
|
11 |
'tvp1' => 'cmd_tv', |
|
12 |
'tvp2' => 'cmd_tv', |
|
13 |
'tvn' => 'cmd_tv', |
|
14 |
'axn' => 'cmd_tv', |
|
15 |
'polsat' => 'cmd_tv', |
|
16 |
'polsta' => 'cmd_tv', |
|
17 |
'l' => 'cmd_list', |
|
18 |
'list' => 'cmd_list', |
|
19 |
'lita' => 'cmd_list', |
|
20 |
'lista' => 'cmd_list', |
|
21 |
); |
|
22 |
} |
|
23 |
|
|
24 |
static function parse_date(&$txt) { |
|
25 |
$known = array( |
|
26 |
'teraz' => 'now', |
|
27 |
'dzis' => 'today', |
|
28 |
'dzisiaj' => 'today', |
|
29 |
'jutro' => 'tomorrow', |
|
30 |
'pojutrze' => 'tomorrow +1 day', |
|
31 |
'po jutrze' => 'tommorow +1 day', |
|
32 |
'poniedzialek' => 'Monday', |
|
33 |
'wtorek' => 'Tuesday', |
|
34 |
'sroda' => 'Wednesday', |
|
35 |
'czwartek' => 'Thursday', |
|
36 |
'piatek' => 'Friday', |
|
37 |
'sobota' => 'Saturday', |
|
38 |
'niedziela' => 'Sunday', |
|
39 |
); |
|
40 |
for($i=0; $i<3; $i++) { |
|
41 |
$known[date('d.m', strtotime('+'.$i.' day'))] = 'today +'.$i.' day'; |
|
42 |
$known[date('j.m', strtotime('+'.$i.' day'))] = 'today +'.$i.' day'; |
|
43 |
} |
|
44 |
foreach($known as $test => $time) { |
|
45 |
if(substr($txt, -strlen($test))==$test) { |
|
46 |
$txt = trim(substr($txt, 0, -strlen($test))); |
|
47 |
return strtotime($time); |
|
48 |
} |
|
49 |
elseif(substr($txt, 0, strlen($test))==$test) { |
|
50 |
$txt = trim(substr($txt, strlen($test))); |
|
51 |
return strtotime($time); |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
return time(); |
|
56 |
} |
|
57 |
|
|
58 |
static function help($cmd=NULL) { |
|
59 |
if($cmd === NULL) { |
|
60 |
GGapi::putRichText('tv ', TRUE); |
|
61 |
GGapi::putRichText('kanał [kiedy]', FALSE, TRUE); |
|
62 |
GGapi::putRichText("\n".' Program telewizyjny dla stacji '); |
|
63 |
GGapi::putRichText('kanał'."\n", FALSE, TRUE); |
|
64 |
GGapi::putRichText('lista ', TRUE); |
|
65 |
GGapi::putRichText("\n".' Lista dostępnych stacji telewizyjnych'."\n\n"); |
|
66 |
} |
|
67 |
elseif(substr($cmd, 0, 1) == 'l') { |
|
68 |
GGapi::putRichText('lista ', TRUE); |
|
69 |
GGapi::putRichText("\n".' Podaje listę dostępnych w komendzie '); |
|
70 |
GGapi::putRichText('tv', TRUE); |
|
71 |
GGapi::putRichText(' stacji telewizyjnych'."\n\n"); |
|
72 |
} |
|
73 |
else |
|
74 |
{ |
|
75 |
GGapi::putRichText('tv ', TRUE); |
|
76 |
GGapi::putRichText('kanał [kiedy]', FALSE, TRUE); |
|
77 |
GGapi::putRichText(' (alias: '); |
|
78 |
GGapi::putRichText('program', TRUE); |
|
79 |
GGapi::putRichText(')'."\n".' Podaje program dla stacji '); |
|
80 |
GGapi::putRichText('kanał', FALSE, TRUE); |
|
81 |
GGapi::putRichText(' na '); |
|
82 |
GGapi::putRichText('[kiedy]'."\n\n", FALSE, TRUE); |
|
83 |
GGapi::putRichText('Przykład', FALSE, FALSE, TRUE); |
|
84 |
GGapi::putRichText("\n".'tv TVP 1'."\n".'tv TVP 1 sobota'); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
static function cmd_list($name, $args) { |
|
89 |
self::$aliases = './data/tv/aliases'; |
|
90 |
|
|
91 |
GGapi::putRichText('Dostępne stacje telewizyjne:', TRUE); |
|
92 |
GGapi::putRichText("\n".implode("\n", self::channels())); |
|
93 |
} |
|
94 |
|
|
95 |
static function cmd_tv($name, $args) { |
|
96 |
self::$file = './data/tv/xmltv-utf.xml'; |
|
97 |
self::$aliases = './data/tv/aliases'; |
|
98 |
|
|
99 |
$time = self::parse_date($args); |
|
100 |
|
|
101 |
if(empty($args)) { |
|
102 |
$args = $name; |
|
103 |
} |
|
104 |
|
|
105 |
$tv = self::aliases($args); |
|
106 |
|
|
107 |
if(!$tv) { |
|
108 |
GGapi::putText('Nieznana stacja telewizyjna. Spróbuj:'."\n".'tv TVP 1'."\n".'tv Discovery'."\n\n".'lub wpisz '); |
|
109 |
GGapi::putRichText('lista', TRUE); |
|
110 |
GGapi::putRichText(' by uzyskać listę dostępnych stacji telewizyjnych'); |
|
111 |
return; |
|
112 |
} |
|
113 |
|
|
114 |
GGapi::putRichText('Program stacji '.$tv."\n", TRUE, FALSE, TRUE); |
|
115 |
self::schedule($tv, $time); |
|
116 |
} |
|
117 |
} |
|
118 |
?> |