本文整理汇总了Python中lib.game.Game.is_political方法的典型用法代码示例。如果您正苦于以下问题:Python Game.is_political方法的具体用法?Python Game.is_political怎么用?Python Game.is_political使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.game.Game
的用法示例。
在下文中一共展示了Game.is_political方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lib.game import Game [as 别名]
# 或者: from lib.game.Game import is_political [as 别名]
class Bot:
def __init__(self):
self.config = config
self.irc = Irc(config)
self.game = Game()
self.stats = Stats()
if self.config['features']['gui_stats']:
self.GUI = GUI(self)
def run(self):
throttle_timers = {button:0 for button in config['throttled_buttons'].keys()}
while True:
new_messages = self.irc.recv_messages(1024)
if not new_messages:
continue
for message in new_messages:
button = message['message'].lower()
username = message['username'].lower()
if not self.game.is_valid_button(button):
continue
if button in self.config['throttled_buttons']:
if (time.time() - throttle_timers[button] <
self.config['throttled_buttons'][button]):
continue
throttle_timers[button] = time.time()
if not self.game.is_political(button):
if (self.config['features']['play_game'] and
not button in self.config['misc']['blocked_buttons']):
self.game.push_button(button)
self.stats.tally_message(username, message['message'])
if self.config['features']['stats_on']:
if self.config['features']['gui_stats']:
self.GUI.run()
if self.config['features']['console_stats']:
pframe(self.stats)
elif self.config['features']['pbutton_on']:
pbutton(self.stats.message_buffer)