irc_broadcast_part $self_id, $chan->{Id}
if rtm_update_part $self_id, $chan->{Id};
} else {
- rtm_apicall "channels.leave", { channel => $chan->{Id} };
+ #rtm_apicall "channels.leave", { channel => $chan->{Id} };
+ rtm_apicall "conersations.leave", { channel => $chan->{Id} };
}
}
}
sub irc_privmsg {
my ($id, $subtype, $msg) = @_;
+ print "id = $id\n";
irc_do_message $id, $users{$id}->{Name}, $subtype, $msg;
}
sub rtm_update_channel {
my ($type, $c) = @_;
-
my $id = $c->{id};
- my $mhash = {};
- my $name = $c->{name};
-
- $name = "+$name" if $type eq "G";
-
- # Cross-reference users/channels
- foreach my $u (@{$c->{members}}) {
- rtm_record_unknown_uid $u;
- # Filter ourselves out of the membership list if this is a
- # closed group chat.
- next if $type eq 'G' && $u eq $self_id && !$c->{is_open};
- $mhash->{$u} = 1;
- $users{$u}->{Channels}->{$id} = 1;
- }
- if (exists $channels{$id}) {
- my $chan = $channels{$id};
- $chan->{Members} = $mhash;
- $chan->{Topic} = $c->{topic}->{value};
- $chan->{Type} = $type;
- } else {
- my $name = irc_pick_name($name, \%channels_by_name);
- my $chan = {
- Id => $c->{id},
- Members => $mhash,
- Name => $name,
- Type => $type,
- Topic => $c->{topic}->{value}
- };
+ rtm_apicall "conversations.members", { channel => $id }, sub {
- $channels{$c->{id}} = $chan;
- $channels_by_name{irc_lcase($name)} = $chan;
- }
+ my $id = $c->{id};
+ my $data = shift;
+ my $mhash = {};
+ my $name = $c->{name};
+
+ $c->{members} = $data->{'members'};
+
+ $name = "+$name" if $type eq "G";
+
+ # Cross-reference users/channels
+ foreach my $u (@{$c->{members}}) {
+ rtm_record_unknown_uid $u;
+ # Filter ourselves out of the membership list if this is a
+ # closed group chat.
+ next if $type eq 'G' && $u eq $self_id && !$c->{is_open};
+ $mhash->{$u} = 1;
+ $users{$u}->{Channels}->{$id} = 1;
+ }
+
+ if (exists $channels{$id}) {
+ my $chan = $channels{$id};
+ $chan->{Members} = $mhash;
+ $chan->{Topic} = $c->{topic}->{value};
+ $chan->{Type} = $type;
+ } else {
+ my $name = irc_pick_name($name, \%channels_by_name);
+ my $chan = {
+ Id => $c->{id},
+ Members => $mhash,
+ Name => $name,
+ Type => $type,
+ Topic => $c->{topic}->{value}
+ };
+
+ $channels{$c->{id}} = $chan;
+ $channels_by_name{irc_lcase($name)} = $chan;
+ }
+ };
}
sub rtm_delete_channel {
unless (defined $rtm_mark_timer) {
$rtm_mark_timer = AnyEvent->timer(after => 5, cb => sub {
for my $chid (keys %rtm_mark_queue ) {
- rtm_apicall "channels.mark", {
+ rtm_apicall "conversations.mark", {
channel => $chid,
ts => $rtm_mark_queue{$chid}
};