Permalink
Browse files

Added an option to subalert module to give points on sub

  • Loading branch information...
1 parent bfdd544 commit 387eba4ecfd0ea983ff45bd92eed6d7f9b6edb72 @pajlada committed Dec 23, 2016
Showing with 22 additions and 0 deletions.
  1. +22 −0 pajbot/modules/subalert.py
@@ -84,20 +84,40 @@ class SubAlertModule(BaseModule):
'min_str_len': 10,
'max_str_len': 400,
}),
+ ModuleSetting(
+ key='grant_points_on_sub',
+ label='Give points to user when they subscribe/resubscribe. 0 = off',
+ type='number',
+ required=True,
+ placeholder='',
+ default=0,
+ constraints={
+ 'min_value': 0,
+ 'max_value': 50000,
+ }),
]
def __init__(self):
super().__init__()
self.new_sub_regex = re.compile('^(\w+) just subscribed')
self.valid_usernames = ('twitchnotify', 'pajlada')
+ def on_sub_shared(self, user):
+ if self.settings['grant_points_on_sub'] <= 0:
+ return
+
+ user.points += self.settings['grant_points_on_sub']
+ self.bot.say('{} was given {} points for subscribing! FeelsAmazingMan'.format(user.username_raw, self.settings['grant_points_on_sub']))
+
def on_new_sub(self, user):
"""
A new user just subscribed.
Send the event to the websocket manager, and send a customized message in chat.
Also increase the number of active subscribers in the database by one.
"""
+ self.on_sub_shared(user)
+
self.bot.kvi['active_subs'].inc()
payload = {'username': user.username_raw}
@@ -115,6 +135,8 @@ def on_resub(self, user, num_months):
Send the event to the websocket manager, and send a customized message in chat.
"""
+ self.on_sub_shared(user)
+
payload = {'username': user.username_raw, 'num_months': num_months}
self.bot.websocket_manager.emit('resub', payload)

0 comments on commit 387eba4

Please sign in to comment.