projects
/
MQR.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c1bd4ae
)
join IRC_ROOM and subscribe
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 29 Aug 2010 00:33:49 +0000
(
02:33
+0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 29 Aug 2010 00:33:49 +0000
(
02:33
+0200)
scripts/mqr-irc-client.pl
patch
|
blob
|
history
diff --git
a/scripts/mqr-irc-client.pl
b/scripts/mqr-irc-client.pl
index
63f8fee
..
9412ab9
100755
(executable)
--- a/
scripts/mqr-irc-client.pl
+++ b/
scripts/mqr-irc-client.pl
@@
-13,14
+13,23
@@
use AnyEvent::Redis;
use Data::Dump qw(dump);
my $nick = $ENV{IRC_NICK} || die "IRC_NICK";
use Data::Dump qw(dump);
my $nick = $ENV{IRC_NICK} || die "IRC_NICK";
-
-my $pub = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT} );
-my $sub = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT} );
+my $room = $ENV{IRC_ROOM} || die "IRC_ROOM";
my $c = AnyEvent->condvar;
my $stdout = AnyEvent::Handle->new (fh => \*STDOUT);
my $con = new AnyEvent::IRC::Client;
my $c = AnyEvent->condvar;
my $stdout = AnyEvent::Handle->new (fh => \*STDOUT);
my $con = new AnyEvent::IRC::Client;
+my $pub = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT} );
+my $sub = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT} );
+
+$sub->psubscribe( 'channel *', sub {
+ my ( $message, $from ) = @_;
+ return unless $from !~ m/\Q$nick\E/; # skip our messages
+ warn "#Q<< $from | $message\n";
+ my ( undef, $channel, $user ) = split(/ /,$from,3);
+ $con->send_msg( $room => join(' ',$channel, $user, $message) );
+});
+
$con->reg_cb (
connect => sub {
my ($con, $err) = @_;
$con->reg_cb (
connect => sub {
my ($con, $err) = @_;
@@
-45,6
+54,8
@@
$con->reg_cb (
if ( $msg->{command} eq 'PRIVMSG' ) {
my $channel = join(' ', 'channel', $msg->{params}->[0], $msg->{prefix});
$pub->publish( $channel, $msg->{params}->[1] );
if ( $msg->{command} eq 'PRIVMSG' ) {
my $channel = join(' ', 'channel', $msg->{params}->[0], $msg->{prefix});
$pub->publish( $channel, $msg->{params}->[1] );
+ } elsif ( $msg->{command} eq 'MODE' ) {
+ $con->send_srv( JOIN => $room );
}
},
debug_send => sub {
}
},
debug_send => sub {