社å IRCãã«ãèãã¦ããªããªãã¦ãã®ã§çãç³»botãæå ¥ããå¾ããªãã¤ã³ãã¼æ©è½ãæè¼ãã話
社å
ã®ã ãããã+1ã¿ãããªãªã¢ã¯ã·ã§ã³ãããªãã¦åãªãã®ã§ãã
æã社ã®ç¤¾å
IRCã«ã¯unazu_kunã¨ããbotãçæ¯ãã¦ããã¾ãã
ã¿ãããªæãã§ãã¢ãã«ã³ãã¡ããããã殺ä¼ã¨ããIRCãã£ã³ãã«ã«
ã©ãã§ããããã¨ã§ãé ·ãã¦ãããçãç³»ã®botãªã®ã§ããã
ãã¾ã«å¿ã®æ½¤ããæ±ãã¦è©±ãããã人ã¯ãããã®ã®
ããã¾ãå½¹ã«ç«ã¤æãã§ã¯ãªãã£ãã®ã§ãæå®ããæéã«ãªã£ãã
ã¡ãã»ã¼ã¸ããã®ã¾ã¾æãã¦ããããªãã¤ã³ãã¼æ©è½ä»ãã¦ã¿ã話ã§ãã
botã¯Perlã§åãã¦ã¦ãAnyEvent::IRC::Clientã¨ãAnyEvent::DateTime::Cronã¨ã使ã£ã¦ãã¦
ä»åå®è£
ããã®ã¯ãæéãkeyã«ãã¦ï¼ä¾ãã° 10:00 => "1000"ã9:9 => "0909"ï¼
valueã対象ã¡ãã»ã¼ã¸ã«ããæãã«ãã¾ããã
my $r = Redis->new(server => 'localhost:6379'); $r->lpush($hour . $min => "$nick: $hour:$minã ãã¼ã");
ã¿ãããªæãã§LPUSHã$hourã¨$minã®ä¸èº«ã¯
$hour = sprintf("%02d", $hour);
ãªã©ã¨ãã¦å¼·å¶çã«2æ¡ã§æ ¼ç´ããããã«ãã¦ãã¾ã(ãã£ã¨åªé ãªæ¹æ³ãããã)
Redisã¯(L|R)PUSHã§LISTåã§ç»é²ããã°
åãæéã«ããã¤ãã¡ãã»ã¼ã¸ã貯ãã¦ãããã®ã§ä¾¿å©ã§ããã
ã¡ãã»ã¼ã¸ãããããªããã
$type = $r->type($key); if ("list" eq $type) { ... }
keyã®typeãlistã§ããã°çã¿ãããªåãæ¹ã§ã§ãã¾ãã
å¤ãããã°
$message = $r->rpop($key);
ã¨ããæãã§valueãæã£ã¦ããããã«ãã¾ããã
ãã®ããã«valueããªããã°(LISTå¤ã¨ãã¦æ»ãå¤ããªããã°)
å®è¡ãããªãã®ã§ã³ã¹ããããããªãã¦è¯ãæãã§ãã
ä¸å¿ 00:00 ã«ãªã£ãã flushall ã§å
¨ã¦ãç¡ã«è¿ããããã®ã«ã¸ã¥ã¢ã«ããæã£ã¦
ãã¼ã¿ã®è¥å¤§åãé¿ãã¦ãã¾ãããããããªãã¤ã³ãã¼ã¯
æéã¨åããæå®ã§ããªãã®ã§ãå½æ¥ä»¥å¤ã®å¤ãæã£ã¦ãã¦ãä»æ¹ãªãã®ã§ãããã¦ãã¾ãã
æ¬å½ã¯ã½ã¼ã¹æããæ¹ãããã®ã§ããããªã«ã¶ããã¼ã«ããªãã³ã§é
ããªãã
ãªãã¤ã³ãã¼æ©è½è¿½å ããã®ã§ãä»ã§ãä½ãæ¸ãã¦ããã®ãããããã£ã¦ãªãã¨ãããããã¾ãã
Perlåå¿è
ãªãããçæéã§ãããããã®å®è£
ã§ããããã«ãªã£ãã®ã¯ã
天女ãéãã¦ãã¦å²©ã羽衣ã§æ«ã§ããããã®é²æ©ã¯ããã®ããªã¼ã¨æã£ããæããªãã£ããã
ããããç¡é§æ©è½è¿½å ã§ããã®ã社å
IRCbotãªãã§ã¯ãªæããã¾ãã®ã§
社å
IRCæã¦ä½ãã¦ããããå®åçãªbotããã¡ããè¯ãã§ãã
å¤ãªbotçæ¯ãããã®ãé¢ç½ãã®ã§ã¯ãªãã§ããããã
...
( '-')-3