Esempio n. 1
0
 def test_db_save_user_settings(self):
     stngs = BotSettings(db = ddb, settings_id = settings_id)
     stngs.settings = {"language": "cs_CZ"}
     stngs.save()
     stngs2 = BotSettings(db = ddb, settings_id = settings_id)
     stngs2.load()
     self.assertEqual(stngs.settings, stngs2.settings)
     self.assertEqual(stngs.stored, True)
Esempio n. 2
0
 async def configure(self, ctx, setting: str, value: str):
     """
     ?configure <setting_name> <setting_value>
     Configures the bot for your specific server, and persists the settings. 
     Configuration settings:
         - realm_region: EU, US
                 - Default: US
         - realm_time_zone: The time zone your server is hosted in
                 - Default: America/New York - valid values are any of the timezone names from the standard tz database.
         - notifications: bool - Automatically send messages to the channel printing the raid reset day/time for the configured raids. Accepts most "truthy" string values, like true, false, y, n, yes, no, etc.
                 - Default: True
         - notification_schedule: Integer array of the # of days before reset to notify the channel.
             0 = notify on reset day that the raid has reset, and output the next reset.
                 - Default: [0, 1, 3]
         - raids_enabled: The raids to enable notifications for.
                 - Default: [MC, Onyxia]
         - raid_days: This is used for calculating double reset periods based on your configured raid schedule.
                 - Default: [3, 4]
                 - 1: Monday
                 - 2: Tuesday
                 - 3: Wednesday
                 - 4: Thursday
                 - 5: Friday
                 - 6: Saturday
                 - 7: Sunday
         - alert_double_reset: bool - Whether or not the mention in the reset notification that this week is a double reset week for the given raid_days.
                 - Default: True
     """
     guild_id = str(ctx.guild.id)
     if setting in BotSettings.props():
         if BotSettings.validate_str_input(setting, value):
             settings = self.redis.get_guild_config(guild_id)
             settings[setting] = value
             self.redis.set_guild_config(guild_id, settings)
             await ctx.send(
                 f'Settings successfully updated, new Guild Settings: {settings}'
             )
             return
         await ctx.send(
             f'Invalid value for setting {setting}. See ?help for more information.'
         )
         return
     await ctx.send(
         f'Invalid setting name, valid setting names: {BotSettings.props}')
Esempio n. 3
0
 async def on_guild_join(self, guild):
     guild_id = str(guild.id)
     defaults = BotSettings.default()
     self.redis.set_guild_config(defaults)
Esempio n. 4
0
 def test_string(self):
     stngs = BotSettings()
     res_4 = bc.nested_replace_dict(TEST_STRING_1, TEST_REPLACE_2)
     self.assertEqual(res_4, TEST_RES_4)
Esempio n. 5
0
 def test_nested_localize(self):
     stngs = BotSettings()
     res_3 = bc.localize(TEST_DICT_2.copy(), "en_US")
     self.assertEqual(res_3, TEST_RES_3_EN)
     res_3 = bc.localize(TEST_DICT_2.copy(), "cs_CZ")
     self.assertEqual(res_3, TEST_RES_3_CZ)
Esempio n. 6
0
 def test_nested_dict(self):
     stngs = BotSettings()
     res_2 = bc.nested_replace_dict(TEST_DICT_2.copy(), TEST_REPLACE_2)
     self.assertEqual(res_2, TEST_RES_2)
Esempio n. 7
0
 def test_nested(self):
     stngs = BotSettings()
     res_1 = bc.nested_replace(TEST_DICT_1.copy(), "test_1", "aaa")
     self.assertEqual(res_1, TEST_RES_1)
Esempio n. 8
0
 def test_timestamp(self):
     stngs = BotSettings()
     self.assertEqual(stngs.timestamp, datetime.fromtimestamp(0).replace(tzinfo=timezone.utc))
     stngs.save()
     self.assertEqual(stngs.timestamp, datetime.fromtimestamp(stngs.timestamp.timestamp(), timezone.utc))
Esempio n. 9
0
 def test_non_existent_settings(self):
     stngs = BotSettings(settings_id = "NON_EXISTENT")
     stngs.load()
     self.assertEqual(stngs.stored, False)
Esempio n. 10
0
 def test_set_settings(self):
     stngs = BotSettings()
     stngs.settings = {"language": "cs_CZ"}
     self.assertEqual(stngs.settings, TEST_SETTINGS_1)
Esempio n. 11
0
 def test_default_settings(self):
     stngs = BotSettings()
     self.assertEqual(stngs.settings, TEST_SETTINGS_2)