Changeset 39035
- Timestamp:
- 10/01/11 08:52:12 (20 months ago)
- Files:
-
- 1 modified
-
lang/perl/tiarra/trunk/module/Auto/Notify.pm (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/tiarra/trunk/module/Auto/Notify.pm
r38984 r39035 148 148 require URI; 149 149 150 my $url = URI->new("https:// prowl.weks.net/publicapi/verify");150 my $url = URI->new("https://api.prowlapp.com/publicapi/verify"); 151 151 $url->query_form(apikey => $config->apikey); 152 152 my $runloop = $this->_runloop; … … 156 156 Callback => sub { 157 157 my $stat = shift; 158 $runloop->notify_warn(__PACKAGE__." verify failed: $stat")158 $runloop->notify_warn(__PACKAGE__." prowl: verify failed: $stat") 159 159 unless ref($stat); 160 160 ## FIXME: check response (should check 'error') … … 166 166 my ($this, $config, $text, $msg, $sender, $full_ch_name) = @_; 167 167 168 my $url = URI->new("https:// prowl.weks.net/publicapi/add");168 my $url = URI->new("https://api.prowlapp.com/publicapi/add"); 169 169 $text = Auto::AliasDB->stdreplace( 170 170 $msg->prefix, … … 174 174 raw_channel => Auto::Utils::get_raw_ch_name($msg, 0), 175 175 text => $this->strip_mirc_formatting($text), 176 ); 177 my $event; 178 if (defined $config->event_format) { 179 $event = Auto::AliasDB->stdreplace( 180 $msg->prefix, 181 $config->event_format, 182 $msg, $sender, 183 channel => $full_ch_name, 184 raw_channel => Auto::Utils::get_raw_ch_name($msg, 0), 185 text => $text, 186 ); 187 } else { 188 $event = $config->event || 'keyword'; 189 } 190 my $uri = Auto::AliasDB->stdreplace( 191 $msg->prefix, 192 $config->url_format || '', ## config and param are "URL" 193 $msg, $sender, 194 channel => $full_ch_name, 195 raw_channel => Auto::Utils::get_raw_ch_name($msg, 0), 196 text => $text, 176 197 ); 177 198 my @data = (apikey => $config->apikey, 178 199 priority => $config->priority || 0, 179 200 application => $config->application || 'tiarra', 180 event => $config->event || 'keyword', 201 event => $event, 202 ($uri ne "" ? (url => $uri) : ()), 181 203 description => $text); 182 204 $url->query_form(@data); … … 369 391 370 392 393 sub config_nma { 394 my ($this, $config) = @_; 395 396 # I don't have a good feeling to NMA, but Prowl didn't support 397 # Android, on 2011-09-30. 398 # see also http://www.cocoaforge.com/viewtopic.php?f=45&t=20765#p129361 399 # and check send_prowl and send_nma. 400 401 require Crypt::SSLeay; # https support 402 require URI; 403 404 foreach my $apikey (split(/,/, $config->apikey)) { 405 my $url = URI->new("https://www.notifymyandroid.com/publicapi/verify"); 406 $url->query_form(apikey => $apikey, 407 (defined $config->developerkey ? 408 (developerkey => $config->developerkey) : ())); 409 my $runloop = $this->_runloop; 410 Tools::HTTPClient->new( 411 Request => GET($url->as_string()), 412 )->start( 413 Callback => sub { 414 my $stat = shift; 415 $runloop->notify_warn(__PACKAGE__." NMA: verify failed: $stat") 416 unless ref($stat); 417 ## FIXME: check response (should check 'error') 418 }, 419 ); 420 } 421 } 422 423 sub send_nma { 424 my ($this, $config, $text, $msg, $sender, $full_ch_name) = @_; 425 426 my $url = URI->new("https://www.notifymyandroid.com/publicapi/notify"); 427 $text = Auto::AliasDB->stdreplace( 428 $msg->prefix, 429 $config->format || $this->config->format || '[tiarra][#(channel):#(nick.now)] #(text)', 430 $msg, $sender, 431 channel => $full_ch_name, 432 raw_channel => Auto::Utils::get_raw_ch_name($msg, 0), 433 text => $this->strip_mirc_formatting($text), 434 ); 435 my $event = Auto::AliasDB->stdreplace( 436 $msg->prefix, 437 $config->event_format || 'keyword', 438 $msg, $sender, 439 channel => $full_ch_name, 440 raw_channel => Auto::Utils::get_raw_ch_name($msg, 0), 441 text => $text, 442 ); 443 my @data = (apikey => $config->apikey, 444 priority => $config->priority || 0, 445 application => $config->application || 'tiarra', 446 event => $event, 447 description => $text, 448 (defined $config->developerkey ? 449 (developerkey => $config->developerkey) : ())); 450 $url->query_form(@data); 451 452 my $runloop = $this->_runloop; 453 Tools::HTTPClient->new( 454 Request => GET($url->as_string()), 455 )->start( 456 Callback => sub { 457 my $stat = shift; 458 if (!ref($stat)) { 459 $runloop->notify_warn(__PACKAGE__." NMA: post failed: $stat"); 460 } elsif ($stat->{Content} !~ /<success /) { 461 (my $content = $stat->{Content}) =~ s/\s+/ /; 462 $runloop->notify_warn(__PACKAGE__." NMA: post failed: $content"); 463 } 464 }, 465 ); 466 } 467 468 371 469 1; 372 470 … … 393 491 394 492 # 使用するブロックを指定します 395 -blocks: im prowl boxcar-growl boxcar-provider notifo 493 -blocks: im prowl boxcar-growl boxcar-provider notifo nma 396 494 397 495 im { … … 422 520 # 通知先ごとにフォーマットを指定できます。 423 521 # この例では先頭に時刻を追加しています。 424 -format: #(date:%H:%M:%S) [#(channel):#(nick.now)]#(text)522 -format: #(date:%H:%M:%S) #(text) 425 523 426 524 # Prowl で表示された apikey を入力します。 … … 428 526 -apikey: XXXXXX 429 527 528 # イベントのフォーマットを指定できます。 529 # 省略すると event の設定が利用されます。 530 event-format: #(channel):#(nick.now) 531 532 # URLのフォーマットを指定できます。 533 # 省略すると通知にURLを含めません。 534 # 現状の機構ではURLをエスケープする手段がないので、固定値以外はお勧めしません。 535 # また、 URL を指定するとアプリ側でのredirect設定は無視されるようです。 536 url-format: 537 538 # イベントを指定します。(固定値) 539 # event-format が指定された場合はそちらが優先されます。 540 event: keyword 541 542 430 543 # http://forums.cocoaforge.com/viewtopic.php?f=45&t=20339 431 544 priority: 0 432 545 application: tiarra 433 event: keyword434 546 435 547 } … … 530 642 } 531 643 644 nma { 645 646 # 通知先のタイプを指定します。 647 # Notify My Android には nma を指定してください。 648 type: nma 649 650 # 通知先ごとにフォーマットを指定できます。 651 # この例では先頭に時刻を追加しています。 652 format: #(date:%H:%M:%S) #(text) 653 654 # NMA で表示された apikey を入力します。 655 # https://www.notifymyandroid.com/account.php 656 # カンマで区切ると複数のAPIキーを指定することができます。 657 -apikey: XXXXXX 658 659 # イベントのフォーマットを指定できます。 660 # デフォルト値: keyword 661 event-format: #(channel):#(nick.now) 662 663 # https://www.notifymyandroid.com/api.php 664 priority: 0 665 application: tiarra 666 -developerkey: 667 668 } 669 532 670 533 671 =cut
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)