def setUp(self): setup_plugin() setup_cvars({ "qlx_owner": "1234567890", "qlx_discordBotToken": "bottoken", "qlx_discordRelayChannelIds": "1234", "qlx_discordTriggeredChannelIds": "456, 789", "qlx_discordUpdateTopicOnTriggeredChannels": "1", "qlx_discordKeepTopicSuffixChannelIds": "1234, 456", "qlx_discordKeptTopicSuffixes": "{1234: '', 456: ''}", "qlx_discordUpdateTopicInterval": "305", "qlx_discordTriggerTriggeredChannelChat": "trigger", "qlx_discordCommandPrefix": "%", "qlx_discordTriggerStatus": "minqlx", "qlx_discordMessagePrefix": "[DISCORD]", "qlx_discordEnableHelp": "1", "qlx_discordEnableVersion": "1", "qlx_displayChannelForDiscordRelayChannels": "0", "qlx_discordReplaceMentionsForRelayedMessages": "0", "qlx_discordReplaceMentionsForTriggeredMessages": "1", "qlx_discordAdminPassword": "******", "qlx_discordAuthCommand": "auth", "qlx_discordExecPrefix": "exec", "qlx_discordLogToSeparateLogfile": "0", "qlx_discordTriggeredChatMessagePrefix": "", "qlx_discordRelayTeamchatChannelIds": "242", "qlx_discord_extensions": "" }) self.logger = mock(spec=logging.Logger, strict=False) self.discord = SimpleAsyncDiscord("version information", self.logger) self.setup_discord_library()
def test_triggered_message_no_triggered_channels_configured(self): setup_cvar("qlx_discordTriggeredChannelIds", "") self.discord = SimpleAsyncDiscord("version information", self.logger) self.setup_discord_library() player = fake_player(steam_id=1, name="Chatting player") self.discord.triggered_message(player, "QL is great, @member #mention !") verify(self.triggered_channel(), times=0).send(any)
def test_relay_team_chat_message_discord_not_logged_in(self): setup_cvar("qlx_discordReplaceMentionsForRelayedMessages", "1") self.discord = SimpleAsyncDiscord("version information", self.logger) self.setup_discord_library() when(self.discord_client).is_ready().thenReturn(False) relay_channel = self.relay_teamchat_channel() player = fake_player(steam_id=1, name="Chatting player") minqlx_channel = "" self.discord.relay_team_chat_message(player, minqlx_channel, "QL is great, @member #mention !") verify(relay_channel, times=0).send(any)
def test_relay_team_chat_message_mentioned_channel_not_found(self): setup_cvar("qlx_discordReplaceMentionsForRelayedMessages", "1") self.discord = SimpleAsyncDiscord("version information", self.logger) self.setup_discord_library() relay_channel = self.relay_teamchat_channel() self.setup_discord_members() self.setup_discord_channels() player = fake_player(steam_id=1, name="Chatting player") minqlx_channel = "" self.discord.relay_team_chat_message(player, minqlx_channel, "QL is great, #mention !") assert_text_was_sent_to_discord_channel(relay_channel, "**Chatting player**: QL is great, #mention !")
def test_triggered_message_no_replacement_configured(self): setup_cvar("qlx_discordReplaceMentionsForTriggeredMessages", "0") self.discord = SimpleAsyncDiscord("version information", self.logger) self.setup_discord_library() trigger_channel1 = self.triggered_channel() mentioned_channel = mocked_channel(_id=456, name="mentioned-channel") self.setup_discord_members() self.setup_discord_channels(mentioned_channel) player = fake_player(steam_id=1, name="Chatting player") self.discord.triggered_message(player, "QL is great, @member #mention !") assert_text_was_sent_to_discord_channel( trigger_channel1, "**Chatting player**: QL is great, @member #mention !")
def test_relay_chat_message_does_not_replace_all_everyone_and_here(self): setup_cvar("qlx_discordReplaceMentionsForRelayedMessages", "1") self.discord = SimpleAsyncDiscord("version information", self.logger) self.setup_discord_library() relay_channel = self.relay_channel() unmentioned_user = mocked_user(_id=123, name="chatter") self.setup_discord_members(unmentioned_user) self.setup_discord_channels() player = fake_player(steam_id=1, name="Chatting player") minqlx_channel = "" self.discord.relay_chat_message(player, minqlx_channel, "QL is great, @all @everyone @here !") assert_text_was_sent_to_discord_channel( relay_channel, "**Chatting player**: QL is great, @all @everyone @here !")