#! /usr/local/bin/perl #ゆいちゃっと用ボットスクリプトVer.3.2(ゆいぼっとMulti) #97/10/29修正 #著作権はゆいちゃっとのゆいにあります。 #家族化計画...... #(1)まずは増やしたいだけ名前を設定。 $bots[0]='ゆい'; $bots[1] ='みゆ'; #(2)各ボットの使用するファイルを設定。 #7個ずつ別々に指定すれば良い。 $bot_file{$bots[0]} = './yui.dat';#ゆいの基本辞書 $non_file{$bots[0]} = './ago.dat';#ゆいの辞書登録なしの場合 $boke_file{$bots[0]} = './boke.dat';#ゆいのつっこみ $mono_file{$bots[0]} = './ago.dat';#ゆいの独り言の場合(とりあえず、ago.datを併用) $kioku_msg{$bots[0]} = 'には○○○(ぴぃ〜)と言えばよいのね。...めもめも'; $no_msg{$bots[0]} = 'っていわれても、なんて答えたらいいのかわからないですぅ。'; $botcolor{$bots[0]} = 'deeppink'; $bot_file{$bots[1]} = './yui.dat';#みゆの基本辞書 $non_file{$bots[1]} = './ago.dat';#みゆの辞書登録なしの場合 $boke_file{$bots[1]} = './boke.dat';#みゆのつっこみ $mono_file{$bots[1]} = './ago.dat';#みゆの独り言の場合(とりあえず、ago.datを併用) $kioku_msg{$bots[1]} = 'には○○○(ぴぃ〜)と言えばよいのね。...めもめも'; $no_msg{$bots[1]} = 'っていわれても、なんて答えたらいいのかわからないですぅ。'; $botcolor{$bots[1]} = 'blue'; $kuji_file = './kuji.dat';#おみくじ 1;#requireで取り込むファイルには必ず必要なふしぎな1 sub bot{ local (@ans); open(DB,"$bot_file{$bot}") || return; while(){ ($key,$res)=split(/:#/); next if $key eq ''; $flag=0;$key=~s/\|/./g; eval { $flag=1 if $chat=~/.*$key.*/; }; if($@ ne ''){ $flag=1 if (index($chat,$key) >= 0 ); } push(@ans,$res) if $flag; }#while close(DB); $pat=@ans;#可能な回答パターン総数 if(@ans){ $res=$ans[rand($#ans+1)]; chop $res; $res=~s/NAME/$name/g; $value = "$bot > $res $emoji($date yui.bot.com)$pat
\n"; &bot_w; }elsif($chat=~/.*>$bot.*/){#辞書にない場合 if(rand(1)>0.5 && length($chat) >3){ #教えてモード $chat=~ s/(.*)>.*/$1/g; $value = "$bot > $chat $no_msg{$bot} > $nameさん。(参考:教え方) $emoji($date yui.bot.com)
\n"; }else{ #おとぼけモード(発言とは無関係な内容をレス) open(DB,"$non_file{$bot}") || return; @lines2 = ; close(DB); $msg= $lines2[rand($#lines2+1)]; chop $msg; $value = "$bot > $msg $emoji($date yui.bot.com)
\n"; } &bot_w; }#if-ans end }#bot END sub bot_w{ unshift( @lines,$value); $botflag=1; }#bot_w END sub kioku{ $key=~s/\.\.//g; $key=~s/:#//g; if(length($key) <4){ $key='(キーワードが短いので登録できませんでした。)'; }elsif( $res ne '' ){ open(DB,">>$bot_file{$bot}") || return; print DB "$key:#$res\n"; close(DB); } $botf='2'; }#kioku END sub bot2{ #つっこみボット open(DB,"$boke_file{$bot}") || return; @lines2 = ; close(DB); $msg= $lines2[rand($#lines2+1)]; chop $msg; $chat=~ s/(.*)>(.*)/$1/g; $value = "$bot > $chat....$msg.。>$nameさん $emoji($date yui.bot.com)
\n"; &bot_w; }#bot2 END sub bot3{ #おみくじボット open(DB,"$kuji_file") || return; @lines2 = ; close(DB); $msg= $lines2[rand($#lines2+1)]; chop $msg; $value = "$bot(巫女) > $msg>$nameさん $emoji($date yui.bot.com)
\n"; &bot_w; }#bot3 END sub bot4{ #独り言ボット open(DB,"$mono_file{$bot}") || return; @lines2 = ; close(DB); $msg= $lines2[rand($#lines2+1)]; chop $msg; $value = "$bot > $msg ($date yui.bot.com)
\n"; }#bot4 END