本文整理汇总了Python中pajbot.managers.handler.HandlerManager.add_handler方法的典型用法代码示例。如果您正苦于以下问题:Python HandlerManager.add_handler方法的具体用法?Python HandlerManager.add_handler怎么用?Python HandlerManager.add_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pajbot.managers.handler.HandlerManager
的用法示例。
在下文中一共展示了HandlerManager.add_handler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_quest
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def start_quest(self):
HandlerManager.add_handler('on_message', self.on_message)
redis = RedisManager.get()
self.load_progress(redis=redis)
self.load_data(redis=redis)
示例2: command_start
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def command_start(self, **options):
bot = options['bot']
source = options['source']
message = options['message']
if self.trivia_running:
bot.safe_me('{}, a trivia is already running'.format(source.username_raw))
return
self.trivia_running = True
self.job.resume()
try:
self.point_bounty = int(message)
if self.point_bounty < 0:
self.point_bounty = 0
elif self.point_bounty > 50:
self.point_bounty = 50
except:
self.point_bounty = self.settings['default_point_bounty']
if self.point_bounty > 0:
bot.safe_me('The trivia has started! {} points for each right answer!'.format(self.point_bounty))
else:
bot.safe_me('The trivia has started!')
HandlerManager.add_handler('on_message', self.on_message)
示例3: start_quest
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def start_quest(self):
HandlerManager.add_handler('on_user_win_hs_bet', self.on_user_win_hs_bet)
redis = RedisManager.get()
self.load_progress(redis=redis)
self.load_data(redis=redis)
self.LIMIT = self.hsbet_points_required
示例4: start_quest
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def start_quest(self):
HandlerManager.add_handler('on_duel_complete', self.on_duel_complete)
redis = RedisManager.get()
self.load_progress(redis=redis)
self.load_data(redis=redis)
self.LIMIT = self.points_required
示例5: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
HandlerManager.add_handler('on_message', self.on_message, priority=200)
HandlerManager.add_handler('on_commit', self.on_commit)
if self.db_session is not None:
self.db_session.commit()
self.db_session.close()
self.db_session = None
self.links = {}
self.db_session = DBManager.create_session()
示例6: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
HandlerManager.add_handler('on_pubmsg', self.on_pubmsg)
self.bot = bot
示例7: __init__
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
#.........这里部分代码省略.........
self.users = UserManager()
self.decks = DeckManager()
self.module_manager = ModuleManager(self.socket_manager, bot=self).load()
self.commands = CommandManager(
socket_manager=self.socket_manager,
module_manager=self.module_manager,
bot=self).load()
self.filters = FilterManager().reload()
self.banphrase_manager = BanphraseManager(self).load()
self.timer_manager = TimerManager(self).load()
self.kvi = KVIManager()
self.emotes = EmoteManager(self)
self.twitter_manager = TwitterManager(self)
HandlerManager.trigger('on_managers_loaded')
# Reloadable managers
self.reloadable = {
'filters': self.filters,
}
# Commitable managers
self.commitable = {
'commands': self.commands,
'filters': self.filters,
'banphrases': self.banphrase_manager,
}
self.execute_every(10 * 60, self.commit_all)
self.execute_every(1, self.do_tick)
try:
self.admin = self.config['main']['admin']
except KeyError:
log.warning('No admin user specified. See the [main] section in config.example.ini for its usage.')
if self.admin:
with self.users.get_user_context(self.admin) as user:
user.level = 2000
self.parse_version()
relay_host = self.config['main'].get('relay_host', None)
relay_password = self.config['main'].get('relay_password', None)
if relay_host is None or relay_password is None:
self.irc = MultiIRCManager(self)
else:
self.irc = SingleIRCManager(self)
self.reactor.add_global_handler('all_events', self.irc._dispatcher, -10)
twitch_client_id = None
twitch_oauth = None
if 'twitchapi' in self.config:
twitch_client_id = self.config['twitchapi'].get('client_id', None)
twitch_oauth = self.config['twitchapi'].get('oauth', None)
# A client ID is required for the bot to work properly now, give an error for now
if twitch_client_id is None:
log.error('MISSING CLIENT ID, SET "client_id" VALUE UNDER [twitchapi] SECTION IN CONFIG FILE')
self.twitchapi = TwitchAPI(twitch_client_id, twitch_oauth)
self.data = {}
self.data_cb = {}
self.url_regex = re.compile(self.url_regex_str, re.IGNORECASE)
self.data['broadcaster'] = self.streamer
self.data['version'] = self.version
self.data['version_brief'] = self.version_brief
self.data['bot_name'] = self.nickname
self.data_cb['status_length'] = self.c_status_length
self.data_cb['stream_status'] = self.c_stream_status
self.data_cb['bot_uptime'] = self.c_uptime
self.data_cb['current_time'] = self.c_current_time
self.silent = True if args.silent else self.silent
if self.silent:
log.info('Silent mode enabled')
"""
For actions that need to access the main thread,
we can use the mainthread_queue.
"""
self.mainthread_queue = ActionQueue()
self.execute_every(1, self.mainthread_queue.parse_action)
self.websocket_manager = WebSocketManager(self)
try:
if self.config['twitchapi']['update_subscribers'] == '1':
self.execute_every(30 * 60,
self.action_queue.add,
(self.update_subscribers_stage1, ))
except:
pass
# XXX: TEMPORARY UGLY CODE
HandlerManager.add_handler('on_user_gain_tokens', self.on_user_gain_tokens)
HandlerManager.add_handler('send_whisper', self.whisper)
示例8: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
self.bot = bot
HandlerManager.add_handler('on_message', self.on_message)
示例9: start_quest
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def start_quest(self):
HandlerManager.add_handler('on_duel_complete', self.on_duel_complete)
redis = RedisManager.get()
self.load_progress(redis=redis)
示例10: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
HandlerManager.add_handler('on_message', self.on_message)
HandlerManager.add_handler('on_usernotice', self.on_usernotice)
self.bot = bot
示例11: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
self.bot = bot
HandlerManager.add_handler('on_user_sub', self.on_user_sub)
HandlerManager.add_handler('on_user_resub', self.on_user_resub)
HandlerManager.add_handler('on_tick', self.on_tick)
示例12: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
HandlerManager.add_handler('on_message', self.on_message, priority=100)
self.bot = bot
示例13: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
HandlerManager.add_handler('on_stream_start', self.on_stream_start)
HandlerManager.add_handler('on_stream_stop', self.on_stream_stop)
HandlerManager.add_handler('on_managers_loaded', self.on_managers_loaded)
self.bot = bot
示例14: start_quest
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def start_quest(self):
HandlerManager.add_handler('on_user_win_hs_bet', self.on_user_win_hs_bet)
redis = RedisManager.get()
self.load_progress(redis=redis)
示例15: enable
# 需要导入模块: from pajbot.managers.handler import HandlerManager [as 别名]
# 或者: from pajbot.managers.handler.HandlerManager import add_handler [as 别名]
def enable(self, bot):
HandlerManager.add_handler('on_paid_timeout', self.on_paid_timeout)
self.bot = bot