Exemplo n.º 1
0
    def __init__(self, alerter, summoner):
        '''
		Constructor
		
		:param alerter: The ActiveAlerter parent of the user
		:param summoner: The summoner associated with the user
		'''
        self.active_alerter = alerter
        self.summoner = summoner
        self.user = summoner.user
        self.sub_tracker = SubTracker(self)
        self.donation_tracker = DonateTracker(self)
        self.champion = ''
Exemplo n.º 2
0
	def __init__(self, alerter, summoner):
		'''
		Constructor
		
		:param alerter: The ActiveAlerter parent of the user
		:param summoner: The summoner associated with the user
		'''
		self.active_alerter = alerter
		self.summoner = summoner
		self.user = summoner.user
		self.sub_tracker = SubTracker(self)
		self.donation_tracker = DonateTracker(self)
		self.champion = ''
Exemplo n.º 3
0
class ActiveUser(object):
    '''
	An ActiveUser is a particular user identified as an active LoLAlerter user.
	
	The role of an ActiveUser is to house a subscriber tracker and donation 
	tracker.
	'''
    def __init__(self, alerter, summoner):
        '''
		Constructor
		
		:param alerter: The ActiveAlerter parent of the user
		:param summoner: The summoner associated with the user
		'''
        self.active_alerter = alerter
        self.summoner = summoner
        self.user = summoner.user
        self.sub_tracker = SubTracker(self)
        self.donation_tracker = DonateTracker(self)
        self.champion = ''

    def start(self):
        '''
		Starts the activeuser polling
		'''
        self.sub_tracker.start()
        self.donation_tracker.start()

    def stop(self):
        '''
		Stops the connections to activeuser
		'''
        self.sub_tracker.stop()
        self.donation_tracker.stop()
        self.champion = ''

    def new_subscriber(self, username, resub):
        '''
		Triggers the events for a new subscriber
		
		:param username: The username of the new subscriber
		:param resub: A boolean of whether the user is re-subscribing
		'''
        Logger().get().info("New Subscriber ({}) for {}({})".format(
            username, self.user.twitchusername, self.summoner.summonerid))

        UserStatistic.update(totalsubscribed=UserStatistic.totalsubscribed+1)\
         .where(UserStatistic.user==self.user).execute()

        self.active_alerter.new_subscriber(self.summoner, username, resub)

    def new_donation(self, donator, amount, message):
        '''
		Triggers the events for a new donation
		
		:param donator: The user who donated the amount 
		:param amount: The amount of money that was donated
		:param message: The message attached to the donation
		'''
        Logger().get().info("New Donation ({} - {}) for {}({}) - {}".format(
            amount, donator, self.user.twitchusername,
            self.summoner.summonerid, message))

        self.active_alerter.new_donation(self.summoner, donator, amount,
                                         message)

    def __eq__(self, other):
        if isinstance(other, ActiveUser):
            return self.summoner.id == other.summoner.id
        return NotImplemented
Exemplo n.º 4
0
class ActiveUser(object):
	'''
	An ActiveUser is a particular user identified as an active LoLAlerter user.
	
	The role of an ActiveUser is to house a subscriber tracker and donation 
	tracker.
	'''
	
	def __init__(self, alerter, summoner):
		'''
		Constructor
		
		:param alerter: The ActiveAlerter parent of the user
		:param summoner: The summoner associated with the user
		'''
		self.active_alerter = alerter
		self.summoner = summoner
		self.user = summoner.user
		self.sub_tracker = SubTracker(self)
		self.donation_tracker = DonateTracker(self)
		self.champion = ''
		
	def start(self):
		'''
		Starts the activeuser polling
		'''
		self.sub_tracker.start()
		self.donation_tracker.start()
		
	def stop(self):
		'''
		Stops the connections to activeuser
		'''
		self.sub_tracker.stop()
		self.donation_tracker.stop()
		self.champion = ''
		
	def new_subscriber(self, username, resub):
		'''
		Triggers the events for a new subscriber
		
		:param username: The username of the new subscriber
		:param resub: A boolean of whether the user is re-subscribing
		'''
		Logger().get().info("New Subscriber ({}) for {}({})".format(username, 
			self.user.twitchusername, self.summoner.summonerid))
		
		UserStatistic.update(totalsubscribed=UserStatistic.totalsubscribed+1)\
			.where(UserStatistic.user==self.user).execute()
		
		self.active_alerter.new_subscriber(self.summoner, username, resub)
		
	def new_donation(self, donator, amount, message):
		'''
		Triggers the events for a new donation
		
		:param donator: The user who donated the amount 
		:param amount: The amount of money that was donated
		:param message: The message attached to the donation
		'''
		Logger().get().info("New Donation ({} - {}) for {}({}) - {}".format(
			amount, donator, self.user.twitchusername, self.summoner.summonerid
			, message))
		
		self.active_alerter.new_donation(self.summoner, 
			donator, amount, message)
		
	def __eq__(self, other):
		if isinstance(other, ActiveUser):
			return self.summoner.id == other.summoner.id
		return NotImplemented