def test_remove_links_from_names():
    service = ServerService({})

    links = [
        "www.google.com",
        "http://www.google.com",
        "https://www.google.com",
        "mailto:[email protected]",
        "www.url-with-querystring.com/?url=has-querystring",
        "192.168.0.1:8080",
        "www.192.168.0.1:8080",
        "www.192.168.0.1.com",
        "http://www.192.168.0.1:8080",
        "https://www.192.168.0.1.com",
    ]

    filtered_links = []
    for link in links:
        filtered_links.append(service._remove_links_from_name(link))

    all_safe = True
    for filtered in filtered_links:
        if filtered != "[LINK REMOVED]":
            all_safe = False

    assert all_safe
Exemplo n.º 2
0
def main():
    intents = discord.Intents.default()
    intents.members = True

    config = ConfigDict()
    server_service = ServerService(config)
    bot = NTPubBot(config, intents=intents, command_prefix="!")

    config_cog = Configuration(bot, config)
    roles_cog = Roles(bot, config["role_id"], config["reaction_msg_id"],
                      config["reaction_channel_id"])
    notification_cog = Notification(bot, config, server_service)

    bot.add_cog(config_cog)
    bot.add_cog(roles_cog)
    bot.add_cog(notification_cog)

    bot.run(bot.config["discord_token"])
def test_removes_markdown_from_name():
    service = ServerService({})

    # TODO More markdown elements
    name = "```Code```"
    assert service._remove_markdown_from_name(name).find("```") == -1
def test_removes_mentions_from_name():
    service = ServerService({})

    assert service._remove_mentions_from_name("@everyone").find("@") == -1
def test_server_not_pubbing_with_password(config_with_pop):
    service = ServerService(config_with_pop)

    info = {"password_protected": 1, "player_count": 0}

    assert service._is_server_pubbing(info) is False
def service(config):
    server_service = ServerService(config)
    service = NotificationService(config, server_service)
    yield service
    del service