Changeset 1101
- Timestamp:
- 11/04/07 18:38:35 (6 years ago)
- Location:
- lang/perl/mobirc/trunk/mobirc/lib/Mobirc
- Files:
-
- 5 modified
-
Channel.pm (modified) (1 diff)
-
HTTPD.pm (modified) (1 diff)
-
HTTPD/Controller.pm (modified) (1 diff)
-
Plugin/Component/IRCClient.pm (modified) (1 diff)
-
Plugin/Component/Twitter.pm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/mobirc/trunk/mobirc/lib/Mobirc/Channel.pm
r1063 r1101 71 71 } 72 72 73 sub post_command { 74 my ($self, $command) = @_; 75 76 for my $code (@{$self->{global_context}->get_hook_codes('process_command')}) { 77 my $ret = $code->($self->{global_context}, $command, $self); 78 last if $ret; 79 } 80 } 81 73 82 sub name { 74 83 my ($self, $name) = @_; -
lang/perl/mobirc/trunk/mobirc/lib/Mobirc/HTTPD.pm
r1082 r1101 69 69 my $c = { 70 70 config => $config, 71 poe => $poe,72 71 req => $request, 73 72 user_agent => $user_agent, 74 73 mobile_agent => HTTP::MobileAgent->new($user_agent), 75 74 irc_nick => $poe->kernel->alias_resolve('irc_session')->get_heap->{irc}->nick_name, 76 irc_incode => $poe->kernel->alias_resolve('irc_session')->get_heap->{config}->{incode},77 75 global_context => Mobirc->context, 78 76 }; -
lang/perl/mobirc/trunk/mobirc/lib/Mobirc/HTTPD/Controller.pm
r1082 r1101 131 131 DEBUG "POST MESSAGE $message"; 132 132 133 $c->{global_context}->get_channel($channel)->post_command($message); 134 133 135 my $irc_incode = $c->{irc_incode}; 134 if ($message) {135 if ($message =~ m{^/}) {136 DEBUG "SENDING COMMAND";137 $message =~ s!^/!!g;138 139 my @args =140 map { encode( $irc_incode, $_ ) } split /\s+/,141 $message;142 143 $c->{poe}->kernel->post('mobirc_irc', @args);144 } else {145 DEBUG "NORMAL PRIVMSG";146 147 $c->{poe}->kernel->post( 'mobirc_irc',148 privmsg => encode( $irc_incode, $channel ) =>149 encode( $irc_incode, $message ) );150 151 DEBUG "Sending message $message";152 if ($c->{config}->{httpd}->{echo} eq true) {153 $c->{global_context}->get_channel($channel)->add_message(154 Mobirc::Message->new(155 who => decode(156 $irc_incode,157 $c->{irc_nick}158 ),159 body => $message,160 class => 'publicfromhttpd',161 )162 );163 }164 }165 }166 136 167 137 my $response = HTTP::Response->new(302); -
lang/perl/mobirc/trunk/mobirc/lib/Mobirc/Plugin/Component/IRCClient.pm
r1082 r1101 18 18 DEBUG "register ircclient component"; 19 19 $global_context->register_hook( 20 'run_component' => sub { _init($conf, $global_context) }, 21 ); 20 'run_component' => sub { _init($conf, shift) }, 21 ); 22 $global_context->register_hook( 23 'process_command' => sub { my ($global_context, $command, $channel) = @_; _process_command($conf, $global_context, $command, $channel) }, 24 ); 25 } 26 27 sub _process_command { 28 my ($conf, $global_context, $command, $channel) = @_; 29 30 my $irc_incode = $conf->{incode}; 31 if ($command && $channel->name =~ /^[#*%]/) { 32 if ($command =~ m{^/}) { 33 DEBUG "SENDING COMMAND"; 34 $command =~ s!^/!!g; 35 36 my @args = 37 map { encode( $irc_incode, $_ ) } split /\s+/, 38 $command; 39 40 $poe_kernel->post('mobirc_irc', @args); 41 } else { 42 DEBUG "NORMAL PRIVMSG"; 43 44 $poe_kernel->post( 'mobirc_irc', 45 privmsg => encode( $irc_incode, $channel->name ) => 46 encode( $irc_incode, $command ) ); 47 48 DEBUG "Sending command $command"; 49 # FIXME: httpd $B4X78$J$$7o(B 50 if ($global_context->config->{httpd}->{echo} eq true) { 51 $channel->add_message( 52 Mobirc::Message->new( 53 who => decode( 54 $irc_incode, 55 $conf->{irc_nick} 56 ), 57 body => $command, 58 class => 'public', 59 ) 60 ); 61 } 62 } 63 return true; 64 } 65 return false; 22 66 } 23 67 -
lang/perl/mobirc/trunk/mobirc/lib/Mobirc/Plugin/Component/Twitter.pm
r1100 r1101 7 7 use POE; 8 8 use POE::Sugar::Args; 9 use Encode; 9 10 10 11 sub register { … … 15 16 'run_component' => sub { _init($conf, shift) }, 16 17 ); 18 $global_context->register_hook( 19 'process_command' => sub { my ($global_context, $command, $channel) = @_; _process_command($conf, $global_context, $command, $channel) }, 20 ); 17 21 18 22 $conf->{channel} ||= U '#twitter'; … … 20 24 $conf->{screenname} ||= $conf->{username}; 21 25 $conf->{friend_timeline_interval} ||= 60; 26 } 27 28 sub _process_command { 29 my ($conf, $global_context, $command, $channel) = @_; 30 31 if ($conf->{channel} eq $channel->name) { 32 $poe_kernel->post( $conf->{alias}, 'update', encode('utf-8', $command) ); 33 $channel->add_message( 34 Mobirc::Message->new( 35 who => $conf->{screenname}, 36 body => $command, 37 class => 'twitter', 38 ) 39 ); 40 return true; 41 } 42 return false; 22 43 } 23 44 … … 86 107 channel: #mytwitter 87 108 88 =head1 LIMITATION89 90 read only. you cannot post to twitter ;-(91
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)