Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # True Rainbow?
- # True Rainow
- use strict;
- use warnings;
- use feature 'switch';
- use Xchat ':all';
- Xchat::hook_command('rainbow', 'rainbow_test');
- my %colors = (
- Red => '04',
- Orange => '07',
- Yellow => '08',
- Green => '03',
- Blue => '02',
- Indigo => '06',
- Violet => '06');
- sub str2rainbow ($){
- my $data = shift;
- my @str = split(//, $data);
- rainbow(@str);
- }
- sub rainbow_test {
- my $msg = $_[1][1];
- Xchat::command('MSG '. Xchat::get_info('channel') . ' ' .str2rainbow($msg));
- }
- sub rainbow {
- my @str = @_;
- my $return_str = '';
- my $state = 0;
- foreach my $letter (@str) {
- if ($letter eq ' ') {
- $return_str .= ' ';
- }
- else {
- given ($state % 7) {
- when(0) { $return_str .= "\003$colors{Red}$letter"; }
- when(1) { $return_str .= "\003$colors{Orange}$letter"; }
- when(2) { $return_str .= "\003$colors{Yellow}$letter"; }
- when(3) { $return_str .= "\003$colors{Green}$letter"; }
- when(4) { $return_str .= "\003$colors{Blue}$letter"; }
- when(5) { $return_str .= "\003$colors{Indigo}$letter"; }
- when(6) { $return_str .= "\002\003$colors{Violet}$letter\002"; }
- }
- ++$state;
- }
- }
- return $return_str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement