Compare commits

..
81 Commits
Author SHA1 Message Date
retoor 7805a3bee2 New bots.
Build Ragnar anti spam bot / Build (push) Successful in 1m43s
2024-12-15 01:35:03 +01:00
retoor 74a57de434 Repair. 2024-12-14 06:34:40 +01:00
retoor d501aa5076 Better process pool.. 2024-12-14 06:33:30 +01:00
bot fc50e6cd4e Update export statistics 2024-12-14 05:24:37 +00:00
retoor 6dc231111f Package update.
Build Ragnar anti spam bot / Build (push) Successful in 1m26s
2024-12-14 05:22:59 +00:00
retoor c6bb785e2c Added new bots.
Build Ragnar anti spam bot / Build (push) Has been cancelled
2024-12-14 06:22:14 +01:00
bot 765193223d Update export statistics 2024-12-13 22:38:20 +00:00
retoor e8fa37cb47 Repaired build buildstep.
Build Ragnar anti spam bot / Build (push) Successful in 1m55s
2024-12-13 23:36:18 +01:00
retoor dec68e4337 New package version.
Build Ragnar anti spam bot / Build (push) Failing after 2m19s
2024-12-13 19:54:49 +00:00
retoor e0d471930b Updated message.
Build Ragnar anti spam bot / Build (push) Failing after 43s
2024-12-13 20:53:52 +01:00
retoor bc237f1aef New build pacakge.
Build Ragnar anti spam bot / Build (push) Failing after 57s
2024-12-13 19:00:53 +00:00
retoor 9405fe728b Updated Makefile. 2024-12-13 19:00:07 +00:00
bot 46fa756d94 Update export statistics 2024-12-13 18:59:27 +00:00
retoor 5c172c9da3 Removed dead bots.
Build Ragnar anti spam bot / Build (push) Successful in 2m51s
2024-12-13 19:56:29 +01:00
retoor 9930e62bf8 Formatting. 2024-12-13 19:55:23 +01:00
retoor bd2c68118c Added a few of the bots. 2024-12-13 19:54:20 +01:00
bot 3c0707be6b Update export statistics 2024-12-10 19:47:51 +00:00
retoor 9dc785ba1b New version.
Build Ragnar anti spam bot / Build (push) Successful in 1m27s
2024-12-10 16:41:06 +01:00
retoor b73c7565ce More rules.
Build Ragnar anti spam bot / Build (push) Waiting to run
2024-12-10 14:56:24 +01:00
retoor 9ea75329b3 Added message.
Build Ragnar anti spam bot / Build (push) Waiting to run
2024-12-10 10:36:38 +01:00
retoor 6b3274dfd2 Doubled amount of rants to check.
Build Ragnar anti spam bot / Build (push) Waiting to run
2024-12-10 05:07:05 +01:00
retoor 532a102719 Update.
Build Ragnar anti spam bot / Build (push) Waiting to run
2024-12-10 04:18:19 +01:00
retoor ed0e2887d5 Update flagged checker. 2024-12-10 04:18:19 +01:00
bot 1abc5d38d1 Update export statistics 2024-12-09 21:25:56 +00:00
retoor fa3660754e Merge.
Build Ragnar anti spam bot / Build (push) Successful in 1m7s
2024-12-09 22:24:29 +01:00
bot ed83e642ad Update export statistics 2024-12-09 20:50:01 +00:00
retoor 06c2f8ffd0 Added Buffon blocker.
Build Ragnar anti spam bot / Build (push) Successful in 1m8s
2024-12-09 21:48:50 +01:00
retoor 016135cf8b Added pycache to .gitignore. 2024-12-09 21:43:10 +01:00
retoor 136124c0ae Deleted pycache. 2024-12-09 21:42:42 +01:00
bot 320d1bae79 Update export statistics 2024-12-02 13:28:28 +00:00
retoor f95b9603b1 Build trigger.
Build Ragnar anti spam bot / Build (push) Successful in 1m8s
2024-12-02 14:27:10 +01:00
bot f54f0d0f1b Update export statistics 2024-12-02 13:09:42 +00:00
retoor c4e714b3ef Added job status.
Build Ragnar anti spam bot / Build (push) Failing after 1m14s
2024-12-02 14:08:19 +01:00
bot 40cc62f511 Update export statistics 2024-12-02 12:11:26 +00:00
retoor c4d44e741a Fixed caching bug.
Build Ragnar anti spam bot / Build (push) Successful in 1m24s
2024-12-02 13:09:55 +01:00
bot 75f6ee13c5 Update export statistics 2024-12-01 08:02:59 +00:00
retoor 516f971530 Style fixes.
Build Ragnar anti spam bot / Build (push) Successful in 56s
2024-12-01 09:01:57 +01:00
bot c68e3b743c Update export statistics 2024-11-30 17:19:21 +00:00
retoor 0045264250 Added ragnar check.
Build Ragnar anti spam bot / Build (push) Successful in 56s
2024-11-30 18:18:03 +01:00
retoor 2f57178a51 Added sus content checker for comments 2024-11-30 18:02:25 +01:00
retoor dc7054581d Added words
Build Ragnar anti spam bot / Build (push) Successful in 55s
2024-11-29 21:13:53 +01:00
bot ef92a9feb0 Update export statistics 2024-11-29 13:43:58 +00:00
retoor 33375d1de3 Update word list.
Build Ragnar anti spam bot / Build (push) Successful in 59s
2024-11-29 14:41:50 +01:00
retoor 5280789351 Update word list. 2024-11-29 14:40:26 +01:00
retoor f7522ddeac Update word list.
Build Ragnar anti spam bot / Build (push) Successful in 1m1s
2024-11-29 14:36:22 +01:00
bot 66bf7aa9ba Update export statistics 2024-11-29 13:35:08 +00:00
retoor 34e519ae06 Update word list.
Build Ragnar anti spam bot / Build (push) Successful in 1m8s
2024-11-29 14:33:49 +01:00
bot 3080e87d88 Update export statistics 2024-11-28 10:44:30 +00:00
retoor 6f856ad857 Added some tests
Build Ragnar anti spam bot / Build (push) Successful in 1m1s
2024-11-28 11:43:23 +01:00
bot 4420b3a2d2 Update export statistics 2024-11-28 10:39:40 +00:00
retoor 5cd0c3c8ea Changed message.
Build Ragnar anti spam bot / Build (push) Successful in 1m2s
2024-11-28 11:38:29 +01:00
bot 8ca2e2a85a Update export statistics 2024-11-28 10:34:41 +00:00
retoor b7c19293b6 Added regex for web sits
Build Ragnar anti spam bot / Build (push) Successful in 1m7s
2024-11-28 11:33:27 +01:00
bot 74b1f31aa5 Update export statistics 2024-11-28 03:31:28 +00:00
retoor 072dd2b5f6 Added reason
Build Ragnar anti spam bot / Build (push) Successful in 1m6s
2024-11-28 04:30:15 +01:00
bot c3f755c989 Update export statistics 2024-11-28 03:09:00 +00:00
retoor a7389f008b Changed string to int.
Build Ragnar anti spam bot / Build (push) Successful in 54s
2024-11-28 04:08:00 +01:00
bot b13a233540 Update export statistics 2024-11-27 23:36:25 +00:00
retoor 252e99d811 Plat3 applied.
Build Ragnar anti spam bot / Build (push) Successful in 58s
2024-11-28 00:35:20 +01:00
bot 282b41c7e2 Update export statistics 2024-11-27 20:00:56 +00:00
retoor ce2e5519b0 Applied json.loads.
Build Ragnar anti spam bot / Build (push) Successful in 1m13s
2024-11-27 20:59:29 +01:00
bot 77c57ae2af Update export statistics 2024-11-27 19:37:19 +00:00
retoor ad886372f6 Vote -1 string.
Build Ragnar anti spam bot / Build (push) Successful in 55s
2024-11-27 20:36:17 +01:00
bot d3180b43c2 Update export statistics 2024-11-27 19:33:47 +00:00
retoor 4da1385dc5 Vote -1 string.
Build Ragnar anti spam bot / Build (push) Successful in 1m1s
2024-11-27 20:32:36 +01:00
bot b04bbd4514 Update export statistics 2024-11-27 16:53:45 +00:00
retoor e504d2cd0b Added @retoor mention.
Build Ragnar anti spam bot / Build (push) Successful in 50s
2024-11-27 17:52:42 +01:00
bot bc2165c402 Update export statistics 2024-11-27 16:18:34 +00:00
retoor 23efe6b7b9 Changed message
Build Ragnar anti spam bot / Build (push) Successful in 58s
2024-11-27 17:17:28 +01:00
bot 067bc28720 Update export statistics 2024-11-27 16:03:31 +00:00
retoor 6970401d14 Remove of magic number
Build Ragnar anti spam bot / Build (push) Successful in 59s
2024-11-27 17:02:18 +01:00
bot fdf115b4e1 Update export statistics 2024-11-27 15:56:41 +00:00
retoor 0482cfc0ec Added words and downvote
Build Ragnar anti spam bot / Build (push) Successful in 1m1s
2024-11-27 16:55:29 +01:00
bot 720ffc93ce Update export statistics 2024-11-27 15:38:57 +00:00
retoor d0d2db1136 added words
Build Ragnar anti spam bot / Build (push) Successful in 57s
2024-11-27 16:37:33 +01:00
bot a6c626cd08 Update export statistics 2024-11-27 14:44:05 +00:00
retoor ac851d76c3 Added logging and rant_history
Build Ragnar anti spam bot / Build (push) Successful in 1m2s
2024-11-27 11:46:02 +01:00
retoor dba78e616c Added decent logging 2024-11-27 11:28:05 +01:00
retoor 8b4d553772 Added tests
Build Ragnar anti spam bot / Build (push) Successful in 57s
2024-11-27 10:56:37 +01:00
retoor 42eca170a6 Added unit test and regex
Build Ragnar anti spam bot / Build (push) Failing after 1m1s
2024-11-27 10:54:27 +01:00
retoor c48bf54dc1 Initial commit
Build Ragnar anti spam bot / Build (push) Successful in 1m31s
2024-11-27 02:59:42 +01:00
18 changed files with 108 additions and 297 deletions
-2
View File
@@ -2,6 +2,4 @@ config.py
.venv .venv
.history .history
__pycache__/ __pycache__/
errors.log
ragnar.log
.build-trigger-2024-12-02 14:26 .build-trigger-2024-12-02 14:26
+1 -2
View File
@@ -1,6 +1,5 @@
ENV=./.venv/bin/activate ENV=./.venv/bin/activate
PYTHON=./.venv/bin/python PYTHON=./.venv/bin/python
BIN=./.venv/bin
all: ensure_env format build install test all: ensure_env format build install test
format: format:
@@ -18,7 +17,7 @@ install:
$(PYTHON) -m pip install -e . $(PYTHON) -m pip install -e .
run: run:
$(BIN)/ragnar.run $(PYTHON) -m ragnar.run
test: test:
$(PYTHON) -m unittest ragnar.tests $(PYTHON) -m unittest ragnar.tests
+19 -78
View File
@@ -1,87 +1,28 @@
# Ragnar Bot: Automated Moderation System for Devrant.io # Ragnar
## Overview This is an anti spam bot network. It is named after the viking for no obvious reason.
Ragnar Bot is an automated system designed to interact with the **Devrant.io API** for community moderation. It detects spam, flags inappropriate content, and takes corrective actions such as downvoting and commenting. The system is scalable, customizable, and supports concurrent operations for multiple users.
--- I'm not happy about the quality of the source and it is not a representation of my usual work. If I would've spend more efford there would be some types and I've would use aiohttp and would've used context managers for example. Despite the source lacking a certain quality, the bots work great and are made not to be annoying to the server by not connecting all at once and caching certain things like user profile / user id and if a reand already is flaged for example to not annoy the server.
## Features The bots have user name no-spam[1-4] but flag under a Russian girl name, also for no obvious reason. I liked it more than some technical name. Will probably rename the bots later. Could be that devRants prevents me to do that within a half year. It doesn't matter much, if the bots do a good job, we will barely see them.
### API Integration I expect this project tomorrow to have deployed fully functional on a server.
- **User Authentication**: Secure login with credentials.
- **Profile Retrieval**: Access user profile data.
- **Content Search**: Find posts matching specific keywords or patterns.
- **Comments Management**: Post and fetch comments on rants.
- **Voting System**: Upvote or downvote rants programmatically.
- **Fetch Rants**: Retrieve and sort recent rants for analysis.
### Spam Detection ## In progress
- **Keyword Triggers**: Detect spam using predefined keywords like `crypto`, `bitcoin`, and more.
- **Regex Matching**: Identify suspicious patterns in text, such as URLs or phone numbers.
- **Heuristic Checks**: Evaluate user profiles and comments for unusual behavior.
### Automation The bots work perfect in sense that they're doing what they're programmed to do.
- **Flagging Spam**: Automatically downvote and comment on posts flagged as spam. But the programming is not finished yet:
- **Concurrent Execution**: Operates multiple bots simultaneously using multithreading. - the criteria can be better, tips how to optimize are very welcome.
- **Customizable Triggers**: Adjust detection patterns to fit evolving spam trends. - at this moment, they can only flag, useless, but we will have indication of future content to be cancelled. Every spam message should have a flag. If not, contact @retoor.
- the downvote function doesn't work because I couldn't figure out what value I had to post. Who knows it? After this, it's kinda done.
- a decent deployment on my server. Now it runs on my laptop because it's not done yet and it got late.
### Logging & Caching ## How they work
- **Logging**: Outputs activity logs to both the console and a file for debugging and monitoring. One process starts four bots named no-spam[1-4]. These bots look at new rants.
- **Caching**: Uses a custom caching system to optimize performance and reduce redundant operations.
---
## How It Works
### Components
1. **API**:
Handles all interactions with the Devrant.io platform, including user authentication, content retrieval, and posting actions.
2. **Bot**:
Implements moderation logic:
- Identifies suspicious content.
- Posts comments warning users about flagged content.
- Maintains a history of checked rants to avoid redundant processing.
3. **CLI**:
Command-line interface to configure and execute the bot. Accepts user credentials and runs bots for multiple users simultaneously.
4. **Victoria Integration**:
Fetches user-related data from a remote service (`victoria.molodetz.nl`) for enhanced operations.
### Workflow
1. The bot authenticates using the provided username and password.
2. It retrieves and evaluates recent rants for spam indicators.
3. If spam is detected:
- Posts a predefined warning comment.
- Downvotes the rant.
4. Maintains logs and runs continuously to monitor new rants.
---
## Installation & Usage
1. **Setup**:
Clone the repository and ensure all dependencies are installed.
2. **Run the Bot**:
Execute the bot via the CLI:
```bash
python cli.py -u <username> -p <password>
---
## Fan art
This is some fan art made by Buffon, a contributor of this project:
![Image generated by Buffon](buffon.jpg)
Another one:
![Image generated by Buffon](buffon2.jpg)
Third one, the legendary bot war of 2024 ended in peace.
![Image generated by Buffon](buffon3.jpg)
If there is a new rant:
1. check if user has more than five posts. If so, it will not be seen as spam.
2. it will check certain keywords like hacker / money crypto related if so continue to step 3.
3. user will be informed by the bots that his rant is flagged and what to do about it.
4. rant will be downvoted by the four bots making it disappear.
-5
View File
@@ -1,5 +0,0 @@
2024-12-17 13:06:42,285 - __main__ - DEBUG - This is a debug message
2024-12-17 13:06:42,286 - __main__ - INFO - This is an info message
2024-12-17 13:06:42,286 - __main__ - WARNING - This is a warning message
2024-12-17 13:06:42,286 - __main__ - ERROR - This is an error message
2024-12-17 13:06:42,286 - __main__ - CRITICAL - This is a critical message
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
-29
View File
@@ -1,29 +0,0 @@
import logging
# Create or get the root logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) # Set the logging level
# Create a file handler
file_handler = logging.FileHandler("app.log")
file_handler.setLevel(logging.DEBUG) # Set the level for this handler
# Create a console handler (optional, for logging to the console too)
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
# Create a logging format
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter)
console_handler.setFormatter(formatter)
# Add the handlers to the logger
logger.addHandler(file_handler)
logger.addHandler(console_handler)
# Log some messages
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
+20 -79
View File
@@ -1,4 +1,4 @@
Metadata-Version: 2.4 Metadata-Version: 2.1
Name: Ragnar Name: Ragnar
Version: 1.3.37 Version: 1.3.37
Summary: Anti spam bot for dR Summary: Anti spam bot for dR
@@ -9,90 +9,31 @@ Requires-Python: >=3.7
Description-Content-Type: text/markdown Description-Content-Type: text/markdown
Requires-Dist: requests==2.32.3 Requires-Dist: requests==2.32.3
# Ragnar Bot: Automated Moderation System for Devrant.io # Ragnar
## Overview This is an anti spam bot network. It is named after the viking for no obvious reason.
Ragnar Bot is an automated system designed to interact with the **Devrant.io API** for community moderation. It detects spam, flags inappropriate content, and takes corrective actions such as downvoting and commenting. The system is scalable, customizable, and supports concurrent operations for multiple users.
--- I'm not happy about the quality of the source and it is not a representation of my usual work. If I would've spend more efford there would be some types and I've would use aiohttp and would've used context managers for example. Despite the source lacking a certain quality, the bots work great and are made not to be annoying to the server by not connecting all at once and caching certain things like user profile / user id and if a reand already is flaged for example to not annoy the server.
## Features The bots have user name no-spam[1-4] but flag under a Russian girl name, also for no obvious reason. I liked it more than some technical name. Will probably rename the bots later. Could be that devRants prevents me to do that within a half year. It doesn't matter much, if the bots do a good job, we will barely see them.
### API Integration I expect this project tomorrow to have deployed fully functional on a server.
- **User Authentication**: Secure login with credentials.
- **Profile Retrieval**: Access user profile data.
- **Content Search**: Find posts matching specific keywords or patterns.
- **Comments Management**: Post and fetch comments on rants.
- **Voting System**: Upvote or downvote rants programmatically.
- **Fetch Rants**: Retrieve and sort recent rants for analysis.
### Spam Detection ## In progress
- **Keyword Triggers**: Detect spam using predefined keywords like `crypto`, `bitcoin`, and more.
- **Regex Matching**: Identify suspicious patterns in text, such as URLs or phone numbers.
- **Heuristic Checks**: Evaluate user profiles and comments for unusual behavior.
### Automation The bots work perfect in sense that they're doing what they're programmed to do.
- **Flagging Spam**: Automatically downvote and comment on posts flagged as spam. But the programming is not finished yet:
- **Concurrent Execution**: Operates multiple bots simultaneously using multithreading. - the criteria can be better, tips how to optimize are very welcome.
- **Customizable Triggers**: Adjust detection patterns to fit evolving spam trends. - at this moment, they can only flag, useless, but we will have indication of future content to be cancelled. Every spam message should have a flag. If not, contact @retoor.
- the downvote function doesn't work because I couldn't figure out what value I had to post. Who knows it? After this, it's kinda done.
- a decent deployment on my server. Now it runs on my laptop because it's not done yet and it got late.
### Logging & Caching ## How they work
- **Logging**: Outputs activity logs to both the console and a file for debugging and monitoring. One process starts four bots named no-spam[1-4]. These bots look at new rants.
- **Caching**: Uses a custom caching system to optimize performance and reduce redundant operations.
---
## How It Works
### Components
1. **API**:
Handles all interactions with the Devrant.io platform, including user authentication, content retrieval, and posting actions.
2. **Bot**:
Implements moderation logic:
- Identifies suspicious content.
- Posts comments warning users about flagged content.
- Maintains a history of checked rants to avoid redundant processing.
3. **CLI**:
Command-line interface to configure and execute the bot. Accepts user credentials and runs bots for multiple users simultaneously.
4. **Victoria Integration**:
Fetches user-related data from a remote service (`victoria.molodetz.nl`) for enhanced operations.
### Workflow
1. The bot authenticates using the provided username and password.
2. It retrieves and evaluates recent rants for spam indicators.
3. If spam is detected:
- Posts a predefined warning comment.
- Downvotes the rant.
4. Maintains logs and runs continuously to monitor new rants.
---
## Installation & Usage
1. **Setup**:
Clone the repository and ensure all dependencies are installed.
2. **Run the Bot**:
Execute the bot via the CLI:
```bash
python cli.py -u <username> -p <password>
---
## Fan art
This is some fan art made by Buffon, a contributor of this project:
![Image generated by Buffon](buffon.jpg)
Another one:
![Image generated by Buffon](buffon2.jpg)
Third one, the legendary bot war of 2024 ended in peace.
![Image generated by Buffon](buffon3.jpg)
If there is a new rant:
1. check if user has more than five posts. If so, it will not be seen as spam.
2. it will check certain keywords like hacker / money crypto related if so continue to step 3.
3. user will be informed by the bots that his rant is flagged and what to do about it.
4. rant will be downvoted by the four bots making it disappear.
-1
View File
@@ -13,6 +13,5 @@ src/ragnar/api.py
src/ragnar/bot.py src/ragnar/bot.py
src/ragnar/cache.py src/ragnar/cache.py
src/ragnar/cli.py src/ragnar/cli.py
src/ragnar/victoria.py
src/ragnar/tests/__init__.py src/ragnar/tests/__init__.py
src/ragnar/tests/bot.py src/ragnar/tests/bot.py
+3 -4
View File
@@ -1,13 +1,12 @@
import logging import logging
import sys import sys
file_handler = logging.FileHandler("ragnar.log")
file_handler.setLevel(logging.DEBUG)
logging.basicConfig( logging.basicConfig(
level=logging.DEBUG, level=logging.DEBUG,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[logging.StreamHandler(sys.stdout), file_handler], handlers=[
logging.StreamHandler(sys.stdout),
],
) )
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
+20 -80
View File
@@ -1,23 +1,22 @@
import json
import random
import re import re
import time import time
from ragnar import log from ragnar import log
from ragnar.api import Api from ragnar.api import Api
from ragnar.cache import method_cache from ragnar.cache import method_cache
from ragnar.victoria import vic
class Bot: class Bot:
rant_history = []
def __init__(self, username, password): def __init__(self, username, password):
self.username = username self.username = username
self.password = password self.password = password
self.name = self.username.split("@")[0] self.name = self.username.split("@")[0]
self.rant_history = []
self.amount_of_rants_to_check = 30 self.amount_of_rants_to_check = 30
self.sus_users = vic.get_spammers() self.sus_users = ["Buffon"]
self.names = { self.names = {
"no-spam": "Anna", "no-spam": "Anna",
"no-spam1": "Ira", "no-spam1": "Ira",
@@ -26,7 +25,7 @@ class Bot:
"no-spam4": "Vira", "no-spam4": "Vira",
} }
self.name = self.names.get(self.name, self.username.split("@")[0]) self.name = self.names.get(self.name, self.username.split("@")[0])
self.mark_text = f"I am {self.name} and downvoted this post because I consider it spam. Your message will be removed from this community site due too much downvotes. See my profile for more information. Read my source code mentioned on my profile to see what you did wrong. Should be no problem for a developer.\n\nHave a nice day!\n\n\nIf your post is not spam, please mention @retoor." self.mark_text = f"I am {self.name} and downvoted this post because post is considered spam. Your message will be removed from this community site due too much downvotes. See my profile for more information. Read my source code mentioned on my profile to see what you did wrong. Should be no problem for a developer.\n\nHave a nice day!\n\n\nIf the post is not spam, please mention @retoor in the comments of this rant.\n\n@ other ranters downvoting is not needed anymore. Enough bots. It will be deleted automatically, but can take a while. I configured it to eat less resources of server. Still it's important to mention ragnar if a spam falls trough so it's in the administration."
self.auth = None self.auth = None
self.triggers = [ self.triggers = [
"$", "$",
@@ -46,10 +45,7 @@ class Bot:
"carat", "carat",
"carats", "carats",
"leading", "leading",
"cheating", "helping",
"spouse",
"spy",
# "helping",
"unqiue", "unqiue",
"@ragnar", "@ragnar",
"brides", "brides",
@@ -60,7 +56,7 @@ class Bot:
self.api = Api(username=self.username, password=self.password) self.api = Api(username=self.username, password=self.password)
def rsleepii(self): def rsleepii(self):
time.sleep(1) time.sleep(random.randint(1, 3))
@method_cache @method_cache
def login(self): def login(self):
@@ -74,21 +70,6 @@ class Bot:
def clean_rant_text(self, rant_text): def clean_rant_text(self, rant_text):
return rant_text.replace(" ", "").lower() return rant_text.replace(" ", "").lower()
def get_mentions(self, rant_text):
return re.findall(r"@\w+", rant_text)
def is_comment_deletable(self, rant_id, username):
rant = self.api.get_rant(rant_id)
for comment in rant.get("comments", []):
print("Checking if sus comment: ", comment["body"])
if (
comment.get("user_username") == username
and comment.get("user_score") <= 10
):
vic.register_spammer(comment["user_username"])
return True
return False
@method_cache @method_cache
def is_sus_content(self, content): def is_sus_content(self, content):
clean_text = self.clean_rant_text(content) clean_text = self.clean_rant_text(content)
@@ -100,25 +81,6 @@ class Bot:
log.info(f"Regex trigger {regex} matched!") log.info(f"Regex trigger {regex} matched!")
return True return True
elif trigger in clean_text: elif trigger in clean_text:
if trigger == "ragnar":
mentions = self.get_mentions(content)
for mention in mentions:
if mention == "@ragnar":
continue
username = mention.strip("@")
if self.is_comment_deletable(username):
vic.register_spammer(mention.strip("@"))
self.api.post_comment(
rant_id,
f"User {username} is sucessfully registered as spammer.",
)
else:
self.api.post_comment(
rant_id,
f"Can't register user {username} as spammer. User is trusted.",
)
if len(mentions) > 1:
return False
log.info(f"Trigger {trigger} matched!") log.info(f"Trigger {trigger} matched!")
return True return True
return False return False
@@ -152,30 +114,16 @@ class Bot:
def is_comments_sus(self, rant_id): def is_comments_sus(self, rant_id):
log.info(f"Checking if comments are sus of rant {rant_id}.") log.info(f"Checking if comments are sus of rant {rant_id}.")
self.rsleepii()
rant = self.api.get_rant(rant_id) rant = self.api.get_rant(rant_id)
for comment in rant.get("comments", []): for comment in rant.get("comments", []):
for spammer in self.sus_users:
if comment["user_username"] == spammer:
vic.downvote_comment(comment["id"])
return False
print("Checking if sus comment: ", comment["body"]) print("Checking if sus comment: ", comment["body"])
if "@ragnar" in comment.get("body", "").lower():
print("Ragnar is mentioned, so flagging as sus comment.")
return True
if comment["user_score"] >= 5:
print("User has reputation >= 5 so not sus.")
continue
if self.is_sus_content(comment.get("body", "")): if self.is_sus_content(comment.get("body", "")):
return True return True
return False return False
def mark_as_sus(self, rant, is_flagged_by_ai): def mark_as_sus(self, rant):
mark_text = self.mark_text self.rsleepii()
if is_flagged_by_ai: self.api.post_comment(rant["id"], self.mark_text)
mark_text += "\n* Flagged by AI."
self.api.post_comment(rant["id"], mark_text)
def fight(self): def fight(self):
self.rsleepii() self.rsleepii()
@@ -184,7 +132,7 @@ class Bot:
if rant["id"] in self.rant_history: if rant["id"] in self.rant_history:
log.debug("{}: Already checked rant {}.".format(self.name, rant["id"])) log.debug("{}: Already checked rant {}.".format(self.name, rant["id"]))
continue continue
flagged_by_id = False
if not self.is_user_sus(rant["user_username"]): if not self.is_user_sus(rant["user_username"]):
log.info( log.info(
"{}: User {} is trusted.".format(self.name, rant["user_username"]) "{}: User {} is trusted.".format(self.name, rant["user_username"])
@@ -197,24 +145,17 @@ class Bot:
elif rant["user_username"] in self.sus_users: elif rant["user_username"] in self.sus_users:
pass pass
elif not self.is_sus_rant(rant["id"], rant["text"]): elif not self.is_sus_rant(rant["id"], rant["text"]):
if not self.is_user_sus(rant["user_username"]):
continue
log.info( log.info(
"{}: Rant by {} is not sus by traditional method..".format( "{}: Rant by {} is not sus.".format(
self.name, rant["user_username"] self.name, rant["user_username"]
) )
) )
if vic.is_spam(rant["text"]) <= 5: continue
self.rant_history.append(rant["id"]) if self.is_flagged_as_sus(rant["id"], rant.get("num_comments")):
continue self.rant_history.append(rant["id"])
else: continue
log.info(
"{}: Rant by {} is sus according to AI.".format(
self.name, rant["user_username"]
)
)
log.warning( log.warning(
"{}: Rant by {} is not flagged as sus yet but should be.".format( "{}: Rant is not {} flagged as sus yet.".format(
self.name, rant["user_username"] self.name, rant["user_username"]
) )
) )
@@ -223,11 +164,10 @@ class Bot:
self.name, rant["user_username"] self.name, rant["user_username"]
) )
) )
self.mark_as_sus(rant, flagged_by_id) self.mark_as_sus(rant)
self.down_vote_rant(rant) self.down_vote_rant(rant)
self.rant_history.append(rant["id"]) self.rant_history.append(rant["id"])
def down_vote_rant(self, rant): def down_vote_rant(self, rant):
vic.dr_downvote_rant(rant["id"], 5) log.warning("Downvoting rant by {}.".format(rant["user_username"]))
log.warning("Downvoting rant by {} for 5 times.".format(rant["user_username"])) log.debug(json.loads(self.api.post_rant_vote(rant["id"], -1)))
log.debug("Vote result: ".format(self.api.post_rant_vote(rant["id"], -1)))
+45 -13
View File
@@ -1,5 +1,7 @@
import argparse import argparse
import random
import time import time
from concurrent.futures import ThreadPoolExecutor as Executor
from ragnar import log from ragnar import log
from ragnar.bot import Bot from ragnar.bot import Bot
@@ -14,23 +16,53 @@ def parse_args():
return parser.parse_args() return parser.parse_args()
def bot_task(username, password):
log.info(f"Created new bot runniner. Username: {username}")
time.sleep(random.randint(1, 20))
while True:
time.sleep(random.randint(1, 120))
bot = Bot(username=username, password=password)
bot.login()
try:
bot.fight()
except Exception as ex:
print(ex)
def main(): def main():
args = parse_args() args = parse_args()
usernames = ["no-spam1", "no-spam2", "no-spam3", "no-spam4"] usernames = [
# "no-spam1",
# "no-spam2",
# "no-spam3",
# "no-spam4",
# "no-spam",
"no-spam2353",
"no-spam2351",
"no-spam2350",
"no-spam2349",
"JamesMedina",
"MichelleWeeks",
"JaredRuiz",
"LoriMcgee",
"AmandaFloyd",
"tcpip",
"tcpudp",
"JoseRodriguez",
"CaseyHernandez",
"ToddHarris",
"AnneRose",
"GregoryBowman",
"LeahVasquez",
"JamesMedina"
]
while True: with Executor(len(usernames) + 1) as executor:
for username in usernames: for username in usernames:
time_start = time.time() executor.submit(bot_task, f"{username}@molodetz.nl", args.password)
try: executor.shutdown(wait=True)
log.info(f"Created new bot runner. Username: {username}")
bot = Bot(username=username, password=args.password)
bot.login()
bot.fight()
except Exception as ex:
log.critical(ex, exc_info=True)
time.sleep(1)
time_duration = time.time() - time_start
log.info(f"Bot {username} finished in {time_duration} seconds.")
def run(): def run():
-3
View File
@@ -1,3 +0,0 @@
from xmlrpc.client import ServerProxy
vic = ServerProxy("https://victoria.molodetz.nl/rpc")
-1
View File
@@ -1 +0,0 @@
aaltink*132