cvs: embed /php-irssi/examples linkchan.php usercount.php
bs Thu Apr 3 07:17:37 2003 EDT
Added files:
/embed/php-irssi/examples usercount.php
Modified files:
/embed/php-irssi/examples linkchan.php
Log:
- added usercount.php which displays a little item with the number of ops, voiced, nonops and a
total in the statusbar
- fixed a typo in linkchan.php
Index: embed/php-irssi/examples/linkchan.php
diff -u embed/php-irssi/examples/linkchan.php:1.8 embed/php-irssi/examples/linkchan.php:1.9
--- embed/php-irssi/examples/linkchan.php:1.8 Wed Apr 2 15:49:38 2003
+++ embed/php-irssi/examples/linkchan.php Thu Apr 3 07:17:37 2003
@@ -1,5 +1,5 @@
<?php
-/* $Id: linkchan.php,v 1.8 2003/04/02 20:49:38 bs Exp $
+/* $Id: linkchan.php,v 1.9 2003/04/03 12:17:37 bs Exp $
*
* Links channels over different networks by forwarding messages, actions,
* modes, joins and kick.
@@ -8,7 +8,7 @@
* Usage:
* Load this script, then type /linkchan help
*
- * Author: Benjamin Schulz <[email protected]> */
+ * Author: Benjamin Schulz <[email protected]> */
namespace samples {
Index: embed/php-irssi/examples/usercount.php
+++ embed/php-irssi/examples/usercount.php
<?php
/* $Id: usercount.php,v 1.1 2003/04/03 12:17:37 bs Exp $
*
* displays a little item with the number of ops, voiced, nonops and a total
* in the statusbar
*
* after you have loaded this script activate it using
* /statusbar window add usercount
*
* Author: Benjamin Schulz <[email protected]> */
namespace samples {
class usercount {
function __construct()
{
irssi_statusbar_item_register('usercount', '$0', array($this,
'draw'));
irssi_signal_add('nicklist new', array($this, 'update'),
IRSSI_SIGNAL_PRIORITY_LOW);
irssi_signal_add('nicklist remove', array($this, 'update'),
IRSSI_SIGNAL_PRIORITY_LOW);
irssi_signal_add('nick mode changed', array($this, 'update'),
IRSSI_SIGNAL_PRIORITY_LOW);
}
function update()
{
irssi_statusbar_items_redraw('usercount');
}
function draw($item, $get_size_only)
{
$win = irssi_window_get_active();
$chan = $win->active;
// got to make a real check of the window-type here
if (get_class($chan) !== 'irssi_channel')
return;
$ops = $voices = $nonops = 0;
for($i = 0; $i < count($chan->nicks); $i++)
{
if ($chan->nicks[$i]->op)
$ops++;
elseif($chan->nicks[$i]->voice)
$voices++;
else
$nonops++;
}
$display = '';
if($ops > 0)
$display .= "@$ops ";
if($voices > 0)
$display .= "+$voices ";
if($nonops > 0)
$display .= "$nonops ";
$display .= "(".($ops + $voices + $nonops).")";
$item->default_handler($get_size_only, '{sb '.$display.'}', '',
true);
return;
}
}
}
new samples::usercount;
?>
Thread (1 message)
- Benjamin Schulz