rewrite: Setting input strings and localisation.
This commit is contained in:
@@ -28,6 +28,7 @@ class TextTrackerSettings(SettingGroup):
|
||||
"""
|
||||
class XPPerPeriod(ModelData, IntegerSetting):
|
||||
setting_id = 'xp_per_period'
|
||||
_set_cmd = 'configure message_exp'
|
||||
|
||||
_display_name = _p('guildset:xp_per_period', "xp_per_5min")
|
||||
_desc = _p(
|
||||
@@ -39,6 +40,10 @@ class TextTrackerSettings(SettingGroup):
|
||||
"Amount of message XP to give members for each 5 minute period in which they are active (send a message). "
|
||||
"Note that this XP is only given *once* per period."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:xp_per_period|accepts',
|
||||
"Number of message XP to reward per 5 minute active period."
|
||||
)
|
||||
_default = 101 # TODO: Make a dynamic default based on the global setting?
|
||||
|
||||
_model = CoreData.Guild
|
||||
@@ -55,6 +60,7 @@ class TextTrackerSettings(SettingGroup):
|
||||
|
||||
class WordXP(ModelData, IntegerSetting):
|
||||
setting_id = 'word_xp'
|
||||
_set_cmd = 'configure message_exp'
|
||||
|
||||
_display_name = _p('guildset:word_xp', "xp_per_100words")
|
||||
_desc = _p(
|
||||
@@ -66,6 +72,10 @@ class TextTrackerSettings(SettingGroup):
|
||||
"Amount of message XP to be given (additionally to the XP per period) for each hundred words. "
|
||||
"Useful for rewarding communication."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:word_xp|accepts',
|
||||
"Number of XP to reward per hundred words sent."
|
||||
)
|
||||
_default = 50
|
||||
|
||||
_model = CoreData.Guild
|
||||
@@ -92,6 +102,14 @@ class TextTrackerSettings(SettingGroup):
|
||||
"Messages sent in these channels will not count towards a member's message XP. "
|
||||
"If a category is selected, then all channels under the category will also be untracked."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:untracked_text_channels|accepts',
|
||||
"Comma separated list of untracked text channel names or ids."
|
||||
)
|
||||
_notset_str = _p(
|
||||
'guildset:untracked_text_channels|notset',
|
||||
"Not Set (all text channels will be tracked.)"
|
||||
)
|
||||
|
||||
_default = None
|
||||
_table_interface = TextTrackerData.untracked_channels
|
||||
@@ -101,6 +119,29 @@ class TextTrackerSettings(SettingGroup):
|
||||
|
||||
_cache = {}
|
||||
|
||||
@property
|
||||
def update_message(self):
|
||||
t = ctx_translator.get().t
|
||||
if self.data:
|
||||
resp = t(_p(
|
||||
'guildset:untracked_text_channels|set_response|set',
|
||||
"Messages in or under the following channels will be ignored: {channels}"
|
||||
)).format(channels=self.formatted)
|
||||
else:
|
||||
resp = t(_p(
|
||||
'guildset:untracked_text_channels|set_response|notset',
|
||||
"Message XP will now be tracked in every channel."
|
||||
))
|
||||
return resp
|
||||
|
||||
@property
|
||||
def set_str(self) -> str:
|
||||
t = ctx_translator.get().t
|
||||
return t(_p(
|
||||
'guildset:untracked_text_channels|set_using',
|
||||
"Channel selector below"
|
||||
))
|
||||
|
||||
@classmethod
|
||||
@log_wrap(action='Cache Untracked Text Channels')
|
||||
async def setup(cls, bot):
|
||||
@@ -127,6 +168,7 @@ class TextTrackerGlobalSettings(SettingGroup):
|
||||
"""
|
||||
class XPPerPeriod(ModelData, IntegerSetting):
|
||||
setting_id = 'xp_per_period'
|
||||
_set_cmd = 'leo configure experience_rates'
|
||||
|
||||
_display_name = _p('botset:xp_per_period', "xp_per_5min")
|
||||
_desc = _p(
|
||||
@@ -139,6 +181,10 @@ class TextTrackerGlobalSettings(SettingGroup):
|
||||
"for each 5 minute period in which they are active (send a message). "
|
||||
"Note that this XP is only given *once* per period."
|
||||
)
|
||||
_accepts = _p(
|
||||
'botset:xp_per_period|accepts',
|
||||
"Number of message XP to reward per 5 minute active period."
|
||||
)
|
||||
_default = 101
|
||||
|
||||
_model = TextTrackerData.BotConfigText
|
||||
@@ -155,6 +201,7 @@ class TextTrackerGlobalSettings(SettingGroup):
|
||||
|
||||
class WordXP(ModelData, IntegerSetting):
|
||||
setting_id = 'word_xp'
|
||||
_set_cmd = 'leo configure experience_rates'
|
||||
|
||||
_display_name = _p('botset:word_xp', "xp_per_100words")
|
||||
_desc = _p(
|
||||
@@ -166,6 +213,10 @@ class TextTrackerGlobalSettings(SettingGroup):
|
||||
"Amount of global message XP to be given (additionally to the XP per period) for each hundred words. "
|
||||
"Useful for rewarding communication."
|
||||
)
|
||||
_accepts = _p(
|
||||
'botset:word_xp|accepts',
|
||||
"Number of XP to reward per hundred words sent."
|
||||
)
|
||||
_default = 50
|
||||
|
||||
_model = TextTrackerData.BotConfigText
|
||||
|
||||
@@ -86,7 +86,7 @@ class TextTrackerConfigUI(ConfigUI):
|
||||
class TextTrackerDashboard(DashboardSection):
|
||||
section_name = _p(
|
||||
'dash:text_tracking|title',
|
||||
"Message XP configuration",
|
||||
"Message XP configuration ({commands[configure message_exp]})",
|
||||
)
|
||||
configui = TextTrackerConfigUI
|
||||
setting_classes = configui.setting_classes
|
||||
|
||||
@@ -33,9 +33,9 @@ _p = babel._p
|
||||
|
||||
class VoiceTrackerSettings(SettingGroup):
|
||||
class UntrackedChannels(ListData, ChannelListSetting):
|
||||
# TODO: Factor out into combined tracking settings?
|
||||
setting_id = 'untracked_channels'
|
||||
_event = 'guild_setting_update_untracked_channels'
|
||||
_set_cmd = 'configure voice_rewards'
|
||||
|
||||
_display_name = _p('guildset:untracked_channels', "untracked_channels")
|
||||
_desc = _p(
|
||||
@@ -47,6 +47,14 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
"Activity in these channels will not count towards a member's statistics. "
|
||||
"If a category is selected, all channels under the category will be untracked."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:untracked_channels|accepts',
|
||||
"Comma separated list of untracked channel name/ids."
|
||||
)
|
||||
_notset_str = _p(
|
||||
'guildset:untracked_channels|notset',
|
||||
"Not Set (all voice channels will be tracked.)"
|
||||
)
|
||||
|
||||
_default = None
|
||||
|
||||
@@ -68,12 +76,19 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
@property
|
||||
def update_message(self):
|
||||
t = ctx_translator.get().t
|
||||
return t(_p(
|
||||
'guildset:untracked_channels|response',
|
||||
"Activity in the following channels will now be ignored: {channels}"
|
||||
)).format(
|
||||
channels=self.formatted
|
||||
)
|
||||
if self.data:
|
||||
resp = t(_p(
|
||||
'guildset:untracked_channels|set_response|set',
|
||||
"Activity in the following channels will now be ignored: {channels}"
|
||||
)).format(
|
||||
channels=self.formatted
|
||||
)
|
||||
else:
|
||||
resp = t(_p(
|
||||
'guildset:untracked_channels|set_response|unset',
|
||||
"All voice channels will now be tracked."
|
||||
))
|
||||
return resp
|
||||
|
||||
@classmethod
|
||||
@log_wrap(action='Cache Untracked Channels')
|
||||
@@ -97,6 +112,7 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
class HourlyReward(ModelData, IntegerSetting):
|
||||
setting_id = 'hourly_reward'
|
||||
_event = 'guild_setting_update_hourly_reward'
|
||||
_set_cmd = 'configure voice_rewards'
|
||||
|
||||
_display_name = _p('guildset:hourly_reward', "hourly_reward")
|
||||
_desc = _p(
|
||||
@@ -107,6 +123,10 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
'guildset:hourly_reward|mode:voice|long_desc',
|
||||
"Number of LionCoins to each member per hour that they stay in a tracked voice channel."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:hourly_reward|accepts',
|
||||
"Number of coins to reward per hour in voice."
|
||||
)
|
||||
|
||||
_default = 50
|
||||
_min = 0
|
||||
@@ -127,29 +147,10 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
amount=data
|
||||
)
|
||||
|
||||
@property
|
||||
def set_str(self):
|
||||
# TODO: Dynamic retrieval of command id
|
||||
return '</configure voice_tracking:1038560947666694144>'
|
||||
|
||||
class HourlyReward_Voice(HourlyReward):
|
||||
"""
|
||||
Voice-mode specialised version of HourlyReward
|
||||
"""
|
||||
_desc = _p(
|
||||
'guildset:hourly_reward|mode:voice|desc',
|
||||
"LionCoins given per hour in a voice channel."
|
||||
)
|
||||
_long_desc = _p(
|
||||
'guildset:hourly_reward|mode:voice|long_desc',
|
||||
"Number of LionCoins rewarded to each member per hour that they stay in a tracked voice channel."
|
||||
)
|
||||
|
||||
@property
|
||||
def set_str(self):
|
||||
# TODO: Dynamic retrieval of command id
|
||||
return '</configure voice_tracking:1038560947666694144>'
|
||||
|
||||
@property
|
||||
def update_message(self):
|
||||
t = ctx_translator.get().t
|
||||
@@ -191,6 +192,7 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
"""
|
||||
setting_id = 'hourly_live_bonus'
|
||||
_event = 'guild_setting_update_hourly_live_bonus'
|
||||
_set_cmd = 'configure voice_rewards'
|
||||
|
||||
_display_name = _p('guildset:hourly_live_bonus', "hourly_live_bonus")
|
||||
_desc = _p(
|
||||
@@ -203,6 +205,10 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
"When a member streams or video-chats in a channel they will be given this bonus *additionally* "
|
||||
"to the `hourly_reward`."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:hourly_live_bonus|accepts',
|
||||
"Number of bonus coins to reward per hour when live."
|
||||
)
|
||||
|
||||
_default = 150
|
||||
_min = 0
|
||||
@@ -223,11 +229,6 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
amount=data
|
||||
)
|
||||
|
||||
@property
|
||||
def set_str(self):
|
||||
# TODO: Dynamic retrieval of command id
|
||||
return '</configure voice_tracking:1038560947666694144>'
|
||||
|
||||
@property
|
||||
def update_message(self):
|
||||
t = ctx_translator.get().t
|
||||
@@ -242,6 +243,7 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
class DailyVoiceCap(ModelData, DurationSetting):
|
||||
setting_id = 'daily_voice_cap'
|
||||
_event = 'guild_setting_update_daily_voice_cap'
|
||||
_set_cmd = 'configure voice_rewards'
|
||||
|
||||
_display_name = _p('guildset:daily_voice_cap', "daily_voice_cap")
|
||||
_desc = _p(
|
||||
@@ -254,6 +256,10 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
"Tracking will resume at the start of the next day. "
|
||||
"The start of the day is determined by the configured guild timezone."
|
||||
)
|
||||
_accepts = _p(
|
||||
'guildset:daily_voice_cap|accepts',
|
||||
"The maximum number of voice hours to track per day."
|
||||
)
|
||||
|
||||
_default = 16 * 60 * 60
|
||||
_default_multiplier = 60 * 60
|
||||
@@ -263,11 +269,6 @@ class VoiceTrackerSettings(SettingGroup):
|
||||
_model = CoreData.Guild
|
||||
_column = CoreData.Guild.daily_study_cap.name
|
||||
|
||||
@property
|
||||
def set_str(self):
|
||||
# TODO: Dynamic retrieval of command id
|
||||
return '</configure voice_tracking:1038560947666694144>'
|
||||
|
||||
@property
|
||||
def update_message(self):
|
||||
t = ctx_translator.get().t
|
||||
@@ -524,7 +525,7 @@ class VoiceTrackerConfigUI(ConfigUI):
|
||||
class VoiceTrackerDashboard(DashboardSection):
|
||||
section_name = _p(
|
||||
'dash:voice_tracker|title',
|
||||
"Voice Tracker Configuration"
|
||||
"Voice Tracker Configuration ({commands[configure voice_rewards]})"
|
||||
)
|
||||
configui = VoiceTrackerConfigUI
|
||||
setting_classes = configui.setting_classes
|
||||
|
||||
Reference in New Issue
Block a user