Permalink
Browse files

リプライ制限機能は正常動作しない不具合を修正

  • Loading branch information...
shogo82148 committed Mar 22, 2012
1 parent ca94073 commit a8201b35ee6f95e59a3a1855c53d6fbc2b00be8f
Showing with 17 additions and 6 deletions.
  1. +11 −4 JO_RI_bot.py
  2. +6 −2 TwitterBot/AdminFunctions.py
View
@@ -63,10 +63,17 @@ def __init__(self):
reset_cycle = 20*60,
allowed_users = config.BOT_USER))
self.append_reply_hook(AdminFunctions.history_hook(
- reply_limit = config.REPLY_LIMIT,
- reset_cycle = config.RESET_CYCLE,
- limit_msg = u'今、ちょっと取り込んでまして・・・'
- u'またのご利用をお待ちしております!'))
+ reply_limit = config.REPLY_LIMIT1,
+ reset_cycle = config.RESET_CYCLE1,
+ limit_msg = [u'今、ちょっと取り込んでまして・・・'
+ u'またのご利用をお待ちしております!',
+ u'もっと時間を有意義に使いませんか?']))
+ self.append_reply_hook(AdminFunctions.history_hook(
+ reply_limit = config.REPLY_LIMIT2,
+ reset_cycle = config.RESET_CYCLE2,
+ limit_msg = [u'今、ちょっと取り込んでまして・・・'
+ u'またのご利用をお待ちしております!',
+ u'もっと時間を有意義に使いませんか?']))
self.append_reply_hook(JO_RI_bot.limit_hook)
self.translator = Translator(config.BING_APP_KEY)
@@ -4,6 +4,7 @@
import TwitterBot
import time
import datetime
+import random
class admin_hook(object):
"""特定ユーザしか実行できないコマンド"""
@@ -100,8 +101,11 @@ def __call__(self, bot, status):
#履歴更新
if author in history:
if history[author]['count']==self.reply_limit and self.limit_msg:
- self.reply_to(u'%s [%s]' %
- (self.limit_msg, bot.get_timestamp()),
+ msg = self.limit_msg
+ if isinstance(msg, (list, tuple)):
+ msg = random.choice(msg)
+ bot.reply_to(u'%s [%s]' %
+ (msg, bot.get_timestamp()),
status)
history[author]['count'] += 1
if history[author]['count']>self.reply_limit:

0 comments on commit a8201b3

Please sign in to comment.