Ωmega
Ωmega

Reputation: 43673

How to read IRC chat messages

Using Perl module AnyEvent::IRC::Connection I am able to connect to Twitch server as follows:

use AnyEvent;
use AnyEvent::IRC::Connection;
use Data::Dumper;  

use constant IRC_ADDR    =>   'irc.chat.twitch.tv';
use constant IRC_PORT    =>    6667;
use constant IRC_AUTH    =>   'my_token';          # http://www.twitchapps.com/tmi/
use constant IRC_NICK    =>   'my_nick';
use constant IRC_CHAN    =>   'some_channel';

my $c = AnyEvent->condvar;
my $con = new AnyEvent::IRC::Connection;
$con->connect(IRC_ADDR, IRC_PORT);
$con->reg_cb (
  connect => sub {
    my ($con) = @_;
    $con->send_msg (PASS => 'oauth:' . IRC_AUTH);
    $con->send_msg (NICK => IRC_NICK);
    $con->send_msg (JOIN => IRC_CHAN);
  },
  'irc_*' => sub {
    my ($con, $msg) = @_;
    print ">> " . Dumper($msg) . "\n";
  },
  dcc_chat_msg => sub {
    my ($con, $id, $msg) = @_;
    print "DCC $id> $msg\n";
  },
);
$c->wait;

However, I can't get read any public chat messages. How can I access them?

Upvotes: 1

Views: 192

Answers (1)

Barry Carlyon
Barry Carlyon

Reputation: 1058

Rooms on IRC are prefixed by # so you joined some_channel which doesn't exist instead of #some_channel which does.

Also note that channels on Twitch are ALWAYS lower case, so #barrycarlyon not #BarryCarlyon

Upvotes: 1

Related Questions