-
Content Count
130 -
Joined
-
Last visited
-
Days Won
27
-
Simple Python Bot to Prevent Advertisement on Discord Servers
champ replied to champ's topic in Development
I’m not forcing anybody to use this. When I ran my server, I had hundreds of advertisements sent accords my channels from other servers’ owners on a daily basis. -
Yes, it is possible.
-
You’re not paying attention to the error message: msg parse resource file [./resource/garner\garnerNPC.txt] failed ,No [190 Starter - Npc], please chech format and version! it clearly states that the error is in garnerNPC.txt on line 190. Npc ID: 190, npc name: Starter - Npc You need to check that line out
-
Your error message states to check the format and version of your new npc entry - this suggests you might have not used tabs correctly or perhaps missed out on certain required fields (basically the format of your new npc line does not match the required format, check the ones that are working for reference)
-
I mean, if you have no idea what values you have modified in the executable, I’m not entirely sure what sort of help we can provide Based on the information you have provided, all I could suggest is change some hex values in game.exe and that might fix it!
-
Simple Python Bot to Prevent Advertisement on Discord Servers
champ replied to champ's topic in Development
You can use role permissions so that users inside your discord server with an unassigned role are unable to see a list of other users and then assign the necessary permissions only once their account has been validated. This way, bots will not be able to privately message your players -
Simple Python Bot to Prevent Advertisement on Discord Servers
champ replied to champ's topic in Development
Food for thought: we can create a “report message” command and then upon approval programmatically extract regex pattern from string and append it to our patterns.txt If many enough people are interested, then I can try to implement it. -
Hi all! We all know that certain users in this community tend to spam other discord servers with their ads, which sometimes can be rather annoying. I wish sometimes I had created this bot when I was running my server. Either way, I created a simple python bot that will prevent users from advertising on your server. It is fairly simple and doesn't involve any sort of complex logic. Feel free to modify it as needed, to make it even more challenging for bots, you could perhaps include AI into creating responses (for instance set up chatgpt api calls), which I'm not going to cover today. Introduction The Discord Anti-Advertisement Bot is designed to prevent users from posting advertisements on a Discord server. The bot monitors messages and deletes any content that it identifies as advertising. Additionally, the bot sends a challenge to new members to verify that they are not bots. Features Detects and deletes advertisement messages. Bans users who exceed the maximum number of advertisement violations. Sends a challenge to new members to verify they are not bots. Automatically assigns a "Bots" role to bots when they join the server. Supports customizable command prefix and challenge questions. Bot Permissions To function correctly, the bot requires the following permissions: Read Messages: To monitor messages in the server. Send Messages: To notify users about their violations and send challenge messages. Manage Messages: To delete advertisement messages. Ban Members: To ban users who exceed the maximum number of violations. Kick Members: To kick users who fail the new member challenge. Manage Roles: To assign roles to bots when they join the server. Configuration 1. Create a new bot To create a new bot, follow these steps: Go to the Discord Developer Portal and sign in with your Discord account. Click "New Application" in the top right corner and enter a name for your application. Navigate to the "Bot" tab on the left sidebar and click "Add Bot." Under the "Token" section, click "Copy" to copy the bot token. 2. Set up the code Clone the bot's repository or download the source code, and make sure you have Python installed. git clone https://github.com/bsgeorgi/discord-anti-ad-bot.git Optionally, you can create a virtual environment and execute your code from there: python -m venv venv venv/Scripts/activate Install the required dependencies using the following command: pip install -r requirements.txt 3. Configure the bot Modify config.py file in the same directory as your bot's code. Replace TOKEN with the token you copied in step 1. You can customize the following settings: TOKEN: The bot token. VIOLATIONS_FILE: The JSON file used to store user violations. MAX_VIOLATIONS: The maximum number of advertisement violations before a user is banned. ALLOWED_DOMAINS: A list of domains that will not trigger the bot's advertising detection. challenges: A list of challenge questions for new members. Each question is a tuple containing a string question and a list of acceptable string answers. 4. Start the bot Run the bot with the following command: python bot.py 5. Invite the bot to your server To invite the bot to your server, follow these steps: Go to the Discord Developer Portal and sign in with your Discord account. Click on your application, then navigate to the "OAuth2" tab on the left sidebar. In the "Scopes" section, select "bot." In the "Bot Permissions" section, select the permissions mentioned earlier in this guide. Copy the generated URL from the "Scopes" section and paste it into a new browser tab. Choose the server where you want to add the bot and click "Authorize." Now, your bot should be a member of your server and will start monitoring messages and performing its tasks. Usage Commands The bot currently has one built-in command: !hello: The bot responds with "Hello!". To use this command, type the command in a text channel in your Discord server. New Member Verification When a new member joins the server, the bot will send them a direct message with a challenge question. The new member must answer the question correctly within 30 seconds. If they answer incorrectly or don't respond within the time limit, they will be kicked from the server. They can rejoin and try again. Advertisement Detection and Handling The bot will continuously monitor messages in the server. If it detects a message containing an advertisement, it will delete the message and notify the sender about their violation. If the user reaches the maximum number of violations (configured in config.py), they will be banned from the server. Customization You can further customize the bot by modifying the code or adding new commands. To add new commands, follow the instructions provided earlier in this conversation. To modify the advertisement detection patterns, edit the patterns.txt file in the bot's directory. Advertisement Patterns I will not go into too much detail when it comes to creating regex patterns, please feel free to do your own research. However, I will explain a couple of patterns from the patterns.txt file. In the provided examples, there are two regular expressions: (?:come\s+)?(play|try|join|check\sout|check) my (new|awesome|amazing|incredible) (game|app|server) This regular expression is composed of several components: (?:come\s+)?: The (?: ... ) is a non-capturing group. It allows you to apply quantifiers to part of your regex without capturing the matched text. In this case, the ? quantifier means the group can occur 0 or 1 times. \s+ represents one or more whitespace characters. So, this part of the regex matches an optional "come" followed by at least one whitespace character. (play|try|join|check\sout|check): This is a capturing group, and the | symbol is an "or" operator, meaning any of the alternatives inside the group can be matched. In this case, the regex will match "play," "try," "join," "check out," or "check." my: Matches the literal string "my." (new|awesome|amazing|incredible): Another capturing group, this time matching any of the adjectives: "new," "awesome," "amazing," or "incredible." (game|app|server): The final capturing group matches one of the following words: "game," "app," or "server." https?://(www\.)?discord\.(?:gg|com/invite)/[^\s]+ This regex is designed to match Discord invite links: https?://: Matches the literal string "http://" or "https://" (the ? makes the "s" optional). (www\.)?: Matches an optional "www." string, with the ? making it optional. discord\.: Matches the literal string "discord." (the backslash is used to escape the dot, as it has a special meaning in regex). (?:gg|com/invite): A non-capturing group that matches either "gg" or "com/invite". /: Matches the literal forward slash character. [^\s]+: The square brackets [] denote a character class, and the ^ symbol inside the brackets negates the class. So, [^\s] means any character that is not a whitespace character. The + quantifier means one or more occurrences of the non-whitespace character. These regular expressions are used in the bot to detect specific patterns related to advertising and can be customized by modifying the patterns.txt file in the bot's directory. Good luck and hope this helps!
-
Очень много воды, но мало смысла. - В чём суть сценариста и какие задачи? - Какая выгода? - Какой объем работы и что уже готово? - Есть ли сайт проекта, дискорд? Советую писать об этом в оригинальном сообщении. Очень многие не станут писать вам индивидуально и пытаться выяснять данную информацию.
-
Здорово! Как освобожусь с работой, зайду поиграть ненадолго! поправка: когда ожидается запуск?
- 23 replies
-
- 2
-
-
- х1
- open source
-
(and 1 more)
Tagged with:
-
Hi @SeaTown Online! Out of curiosity, is there any particular reason behind the previous server reset?
-
Привет. А зачем писать новый гейт на шарпе? Он нативно будет работать медленнее плюсов. Если уж и решитесь переносить всё это дело и обновлять, не имеет ли больше смысла переписать на модернизированном с++?
-
This particular warning is shown due to you using a plus sign rather than a dot to concatenate strings. PHP uses dots to do that (inherited from Pearl), this behaviour can be tested using a PHP compiler. I have attached two screenshots of me running tests using different PHP compilers (versions 7 and 8). Using version 7 outputs the warning that you see, now if you upgrade to version 8 then the developers have explicitly converted this warning into an exception, so the code will not work (running this code on php < 7 should not show any errors, which could lead to invalid application logic behaviour).