Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

support join/part, nick completion with @ prefix

  • Loading branch information...
commit 347b6789a94d6a7682095c3914e9def117d3e79c 1 parent f325157
Daisuke Murase authored March 19, 2013

Showing 1 changed file with 41 additions and 9 deletions. Show diff stats Hide diff stats

  1. 50  lingr.pl
50  lingr.pl
@@ -98,12 +98,38 @@ sub cmd_start {
98 98
                     $win->printformat(
99 99
                         MSGLEVEL_PUBLIC,
100 100
                         $msg->{speaker_id} eq $lingr->user ? 'ownmsg' : 'pubmsg',
101  
-                        $msg->{nickname}, $msg->{text},
  101
+                        $msg->{speaker_id}, $msg->{text},
102 102
                         $is_owner ? '@' : ' ');
103 103
                 }
104 104
                 else {
105 105
                     $win->printformat(MSGLEVEL_NOTICES, 'notice_public',
106  
-                                      $msg->{nickname}, $msg->{room}, $msg->{text});
  106
+                                      $msg->{speaker_id}, $msg->{room}, $msg->{text});
  107
+                }
  108
+            }
  109
+        }
  110
+        elsif (my $presence = $event->{presence}) {
  111
+            my $win_name = 'lingr/' . $presence->{room};
  112
+            my $win = Irssi::window_find_name($win_name);
  113
+
  114
+            if ($win) {
  115
+                if ($presence->{status} eq 'online') {
  116
+                    $NICKMAP{ $presence->{room} }{ $presence->{username} } = {
  117
+                        speaker_id => $presence->{username},
  118
+                        %$presence,
  119
+                    };
  120
+
  121
+                    $win->printformat(
  122
+                        MSGLEVEL_JOINS, 'join',
  123
+                        $presence->{nickname}, $presence->{username}, $presence->{room},
  124
+                    );
  125
+                }
  126
+                elsif ($presence->{status} eq 'offline') {
  127
+                    delete $NICKMAP{ $presence->{room} }{ $presence->{username} };
  128
+
  129
+                    $win->printformat(
  130
+                        MSGLEVEL_PARTS, 'part',
  131
+                        $presence->{nickname}, $presence->{username}, $presence->{room}, '',
  132
+                    );
107 133
                 }
108 134
             }
109 135
         }
@@ -137,22 +163,28 @@ sub sig_complete_word {
137 163
     }
138 164
 
139 165
     my ($room) = $win->{name} =~ m!^lingr/(.*)$!;
140  
-    if ($room) {
141  
-        push @$strings, map { '@' . $_ } grep /^$word/, keys %{ $NICKMAP{$room} };
  166
+    if ($room and $word !~ m!^/!) {
  167
+        push @$strings, map { '@' . $_ } sort grep /^$word/i, keys %{ $NICKMAP{$room} };
142 168
         $$want_space = 1;
143 169
         Irssi::signal_stop();
144 170
     }
145 171
 }
146 172
 
147  
-Irssi::theme_register([
148  
-    'pubmsg'    => Irssi::current_theme()->get_format('fe-common/core', 'pubmsg'),
149  
-    'ownmsg' => Irssi::current_theme()->get_format('fe-common/core', 'own_msg'),
150  
-    'notice_public' => Irssi::current_theme()->get_format('fe-common/irc', 'notice_public'),
151  
-]);
  173
+sub cmd_update_theme {
  174
+    Irssi::theme_register([
  175
+        'pubmsg'        => Irssi::current_theme()->get_format('fe-common/core', 'pubmsg'),
  176
+        'ownmsg'        => Irssi::current_theme()->get_format('fe-common/core', 'own_msg'),
  177
+        'notice_public' => Irssi::current_theme()->get_format('fe-common/irc', 'notice_public'),
  178
+        'join'          => Irssi::current_theme()->get_format('fe-common/core', 'join'),
  179
+        'part'          => Irssi::current_theme()->get_format('fe-common/core', 'part'),
  180
+    ]);
  181
+}
  182
+cmd_update_theme();
152 183
 
153 184
 Irssi::command_bind('lingr', \&cmd_base);
154 185
 Irssi::command_bind('lingr start', \&cmd_start);
155 186
 Irssi::command_bind('lingr stop', \&cmd_stop);
  187
+Irssi::command_bind('lingr update_theme', \&cmd_update_theme);
156 188
 
157 189
 Irssi::settings_add_str('lingr', 'lingr_user', q[]);
158 190
 Irssi::settings_add_str('lingr', 'lingr_password', q[]);

0 notes on commit 347b678

Please sign in to comment.
Something went wrong with that request. Please try again.