diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:47 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:47 +0200 |
| commit | 630af0ed6c0af69c7df2e45aef7a87722a3c00c0 (patch) | |
| tree | ad76f850278b090f7e5c26561035d19c320400cc /0.7.2/modules/hierachie.pm | |
| parent | 2860b03f00e48264ed15c132ad90b240ebe6070b (diff) | |
tagging ychat-perl-legacyychat-perl-legacy
Diffstat (limited to '0.7.2/modules/hierachie.pm')
| -rw-r--r-- | 0.7.2/modules/hierachie.pm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/0.7.2/modules/hierachie.pm b/0.7.2/modules/hierachie.pm new file mode 100644 index 0000000..3a9e13c --- /dev/null +++ b/0.7.2/modules/hierachie.pm @@ -0,0 +1,74 @@ +sub hierachie { + my($alias, $room) = @_; + open FILE, "<data/online/rstat/$room"; + my(@rstat) = <FILE>; + close FILE; + shift @rstat; + shift @rstat; + open FILE, '<data/hierachie'; + my(@hierachie) = <FILE>; + close FILE; + my(@userlevels) = (@hierachie, @rstat); + foreach $_ (@userlevels) { + my($name, $level) = split(/<;/, $_, 3); + if ($name eq $alias) { + chomp $level; + return $level; + } + } +} +sub hierachie_rm { + my $alias = shift @_; + my @return; + open FILE, '<data/hierachie'; + my(@hierachie) = <FILE>; + close FILE; + foreach $_ (@hierachie) { + push @return, $_ unless /^$alias<;/; + } + open FILE, '>data/hierachie'; + print FILE @return; + close FILE; +} +sub hierachie_rm_rstat { + my($alias, $room) = @_; + my @return; + return unless open FILE, "<data/online/rstat/$room"; + my(@hierachie) = <FILE>; + close FILE; + foreach $_ (@hierachie) { + push @return, $_ unless /^$alias<;/; + } + open FILE, ">data/online/rstat/$room"; + print FILE @return; + close FILE; +} +sub hierachie_add { + my($alias, $level) = @_; + &hierachie_rm($alias); + open FILE, '>>data/hierachie'; + print FILE "$alias<;$level\n"; + close FILE; +} +sub hierachie_add_rstat { + my($alias, $level, $room) = @_; + &hierachie_rm_rstat($alias, $room); + return unless open FILE, ">>data/online/rstat/$room"; + print FILE "$alias<;$level\n"; + close FILE; +} +sub prove_away { + my($alias, $room) = @_; + return unless open AWAY, "<data/online/rstat/$room.away"; + @away = <AWAY>; + close AWAY; + my $name, $away; + foreach $_ (@away) { + if (/^$alias.*/) { + ($name, $away) = split(/<; /, $_, 3); + chomp $away; + return $away; + } + } +} +1; |
