Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit a8201b35ee6f95e59a3a1855c53d6fbc2b00be8f 1 parent ca94073
@shogo82148 authored
Showing with 17 additions and 6 deletions.
  1. +11 −4 JO_RI_bot.py
  2. +6 −2 TwitterBot/AdminFunctions.py
View
15 JO_RI_bot.py
@@ -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)
View
8 TwitterBot/AdminFunctions.py
@@ -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:
Please sign in to comment.
Something went wrong with that request. Please try again.