本文整理汇总了Python中pajbot.managers.handler.HandlerManager类的典型用法代码示例。如果您正苦于以下问题:Python HandlerManager类的具体用法?Python HandlerManager怎么用?Python HandlerManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HandlerManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_quest
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: stop_quest
def stop_quest(self):
HandlerManager.remove_handler('on_user_win_hs_bet', self.on_user_win_hs_bet)
redis = RedisManager.get()
self.reset_progress(redis=redis)
redis.delete(self.hsbet_points_key)
示例3: stop_quest
def stop_quest(self):
HandlerManager.remove_handler('on_duel_complete', self.on_duel_complete)
redis = RedisManager.get()
self.reset_progress(redis=redis)
redis.delete(self.points_required_key)
示例4: command_start
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)
示例5: create_stream
def create_stream(self, status):
log.info('Attempting to create a stream!')
with DBManager.create_session_scope(expire_on_commit=False) as db_session:
stream_chunk = db_session.query(StreamChunk).filter_by(broadcast_id=status['broadcast_id']).one_or_none()
new_stream = False
if stream_chunk is not None:
stream = stream_chunk.stream
else:
log.info('checking if there is an active stream already')
stream = db_session.query(Stream).filter_by(ended=False).order_by(Stream.stream_start.desc()).first()
new_stream = stream is None
if new_stream:
log.info('No active stream, create new!')
stream = Stream(status['created_at'],
title=status['title'])
db_session.add(stream)
db_session.commit()
log.info('Successfully added stream!')
stream_chunk = StreamChunk(stream, status['broadcast_id'], status['created_at'])
db_session.add(stream_chunk)
db_session.commit()
stream.stream_chunks.append(stream_chunk)
log.info('Created stream chunk')
self.current_stream = stream
self.current_stream_chunk = stream_chunk
db_session.expunge_all()
if new_stream:
HandlerManager.trigger('on_stream_start', stop_on_false=False)
log.info('Successfully created a stream')
示例6: stop_quest
def stop_quest(self):
HandlerManager.remove_handler('on_message', self.on_message)
redis = RedisManager.get()
self.reset_progress(redis=redis)
redis.delete(self.current_emote_key)
示例7: on_usernotice
def on_usernotice(self, source, message, tags):
if 'msg-id' not in tags or 'msg-param-months' not in tags:
return
if tags['msg-id'] == 'resub':
num_months = int(tags['msg-param-months'])
self.on_resub(source, num_months)
HandlerManager.trigger('on_user_resub', source, num_months)
示例8: commit_all
def commit_all(self):
log.info('Commiting all...')
for key, manager in self.commitable.items():
log.info('Commiting {0}'.format(key))
manager.commit()
log.info('Done with {0}'.format(key))
log.info('ok!')
HandlerManager.trigger('on_commit', stop_on_false=False)
示例9: base_paid_timeout
def base_paid_timeout(self, bot, source, message, _time, _cost):
if message is None or len(message) == 0:
return False
target = message.split(' ')[0]
if len(target) < 2:
return False
with bot.users.find_context(target) as victim:
if victim is None:
bot.whisper(source.username, 'This user does not exist FailFish')
return False
if victim.last_active is None or (datetime.datetime.now() - victim._last_active).total_seconds() > 10 * 60:
bot.whisper(source.username, 'This user has not been active in chat within the last 10 minutes.')
return False
"""
if victim == source:
bot.whisper(source.username, 'You can\'t timeout yourself FailFish')
return False
"""
if victim.moderator is True:
bot.whisper(source.username, 'This person has mod privileges, timeouting this person is not worth it.')
return False
if victim.level >= self.settings['bypass_level']:
bot.whisper(source.username, 'This person\'s user level is too high, you can\'t timeout this person.')
return False
now = datetime.datetime.now()
if victim.timed_out is True and victim.timeout_end > now:
victim.timeout_end += datetime.timedelta(seconds=_time)
bot.whisper(victim.username, '{victim.username}, you were timed out for an additional {time} seconds by {source.username}'.format(
victim=victim,
source=source,
time=_time))
bot.whisper(source.username, 'You just used {0} points to time out {1} for an additional {2} seconds.'.format(_cost, victim.username, _time))
num_seconds = int((victim.timeout_end - now).total_seconds())
bot._timeout(victim.username, num_seconds, reason='Timed out by {}'.format(source.username_raw))
# songs = session.query(PleblistSong, func.count(PleblistSong.song_info).label('total')).group_by(PleblistSong.youtube_id).order_by('total DESC')
else:
bot.whisper(source.username, 'You just used {0} points to time out {1} for {2} seconds.'.format(_cost, victim.username, _time))
bot.whisper(victim.username, '{0} just timed you out for {1} seconds. /w {2} !$unbanme to unban yourself for points forsenMoney'.format(source.username, _time, bot.nickname))
bot._timeout(victim.username, _time, reason='Timed out by {}'.format(source.username_raw))
victim.timed_out = True
victim.timeout_start = now
victim.timeout_end = now + datetime.timedelta(seconds=_time)
if self.settings['show_on_clr']:
payload = {'user': source.username, 'victim': victim.username}
bot.websocket_manager.emit('timeout', payload)
HandlerManager.trigger('on_paid_timeout',
source, victim, _cost,
stop_on_false=False)
示例10: on_message
def on_message(self, source, message, emotes, whisper, urls, event):
if whisper is False and source.username in self.valid_usernames:
# Did twitchnotify tell us about a new sub?
m = self.new_sub_regex.search(message)
if m:
username = m.group(1)
with UserManager.get().get_user_context(username) as user:
self.on_new_sub(user)
HandlerManager.trigger('on_user_sub', user)
示例11: start_quest
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
示例12: start_quest
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
示例13: disable
def disable(self, bot):
HandlerManager.remove_handler('on_message', self.on_message)
HandlerManager.remove_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 = {}
示例14: enable
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()
示例15: command_stop
def command_stop(self, **options):
bot = options['bot']
source = options['source']
if not self.trivia_running:
bot.safe_me('{}, no trivia is active right now'.format(source.username_raw))
return
self.job.pause()
self.trivia_running = False
self.step_end()
bot.safe_me('The trivia has been stopped.')
HandlerManager.remove_handler('on_message', self.on_message)