Compare commits
78
Commits
main
..
fc50e6cd4e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc50e6cd4e | ||
|
|
6dc231111f | ||
|
|
c6bb785e2c | ||
|
|
765193223d | ||
|
|
e8fa37cb47 | ||
|
|
dec68e4337 | ||
|
|
e0d471930b | ||
|
|
bc237f1aef | ||
|
|
9405fe728b | ||
|
|
46fa756d94 | ||
|
|
5c172c9da3 | ||
|
|
9930e62bf8 | ||
|
|
bd2c68118c | ||
|
|
3c0707be6b | ||
|
|
9dc785ba1b | ||
|
|
b73c7565ce | ||
|
|
9ea75329b3 | ||
|
|
6b3274dfd2 | ||
|
|
532a102719 | ||
|
|
ed0e2887d5 | ||
|
|
1abc5d38d1 | ||
|
|
fa3660754e | ||
|
|
ed83e642ad | ||
|
|
06c2f8ffd0 | ||
|
|
016135cf8b | ||
|
|
136124c0ae | ||
|
|
320d1bae79 | ||
|
|
f95b9603b1 | ||
|
|
f54f0d0f1b | ||
|
|
c4e714b3ef | ||
|
|
40cc62f511 | ||
|
|
c4d44e741a | ||
|
|
75f6ee13c5 | ||
|
|
516f971530 | ||
|
|
c68e3b743c | ||
|
|
0045264250 | ||
|
|
2f57178a51 | ||
|
|
dc7054581d | ||
|
|
ef92a9feb0 | ||
|
|
33375d1de3 | ||
|
|
5280789351 | ||
|
|
f7522ddeac | ||
|
|
66bf7aa9ba | ||
|
|
34e519ae06 | ||
|
|
3080e87d88 | ||
|
|
6f856ad857 | ||
|
|
4420b3a2d2 | ||
|
|
5cd0c3c8ea | ||
|
|
8ca2e2a85a | ||
|
|
b7c19293b6 | ||
|
|
74b1f31aa5 | ||
|
|
072dd2b5f6 | ||
|
|
c3f755c989 | ||
|
|
a7389f008b | ||
|
|
b13a233540 | ||
|
|
252e99d811 | ||
|
|
282b41c7e2 | ||
|
|
ce2e5519b0 | ||
|
|
77c57ae2af | ||
|
|
ad886372f6 | ||
|
|
d3180b43c2 | ||
|
|
4da1385dc5 | ||
|
|
b04bbd4514 | ||
|
|
e504d2cd0b | ||
|
|
bc2165c402 | ||
|
|
23efe6b7b9 | ||
|
|
067bc28720 | ||
|
|
6970401d14 | ||
|
|
fdf115b4e1 | ||
|
|
0482cfc0ec | ||
|
|
720ffc93ce | ||
|
|
d0d2db1136 | ||
|
|
a6c626cd08 | ||
|
|
ac851d76c3 | ||
|
|
dba78e616c | ||
|
|
8b4d553772 | ||
|
|
42eca170a6 | ||
|
|
c48bf54dc1 |
@@ -2,6 +2,4 @@ config.py
|
||||
.venv
|
||||
.history
|
||||
__pycache__/
|
||||
errors.log
|
||||
ragnar.log
|
||||
.build-trigger-2024-12-02 14:26
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
ENV=./.venv/bin/activate
|
||||
PYTHON=./.venv/bin/python
|
||||
BIN=./.venv/bin
|
||||
all: ensure_env format build install test
|
||||
|
||||
format:
|
||||
@@ -18,7 +17,7 @@ install:
|
||||
$(PYTHON) -m pip install -e .
|
||||
|
||||
run:
|
||||
$(BIN)/ragnar.run
|
||||
$(PYTHON) -m ragnar.run
|
||||
|
||||
test:
|
||||
$(PYTHON) -m unittest ragnar.tests
|
||||
|
||||
@@ -1,87 +1,28 @@
|
||||
# Ragnar Bot: Automated Moderation System for Devrant.io
|
||||
# Ragnar
|
||||
|
||||
## Overview
|
||||
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.
|
||||
This is an anti spam bot network. It is named after the viking for no obvious reason.
|
||||
|
||||
---
|
||||
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
|
||||
- **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.
|
||||
I expect this project tomorrow to have deployed fully functional on a server.
|
||||
|
||||
### Spam Detection
|
||||
- **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.
|
||||
## In progress
|
||||
|
||||
### Automation
|
||||
- **Flagging Spam**: Automatically downvote and comment on posts flagged as spam.
|
||||
- **Concurrent Execution**: Operates multiple bots simultaneously using multithreading.
|
||||
- **Customizable Triggers**: Adjust detection patterns to fit evolving spam trends.
|
||||
The bots work perfect in sense that they're doing what they're programmed to do.
|
||||
But the programming is not finished yet:
|
||||
- the criteria can be better, tips how to optimize are very welcome.
|
||||
- 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
|
||||
- **Logging**: Outputs activity logs to both the console and a file for debugging and monitoring.
|
||||
- **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:
|
||||
|
||||

|
||||
|
||||
Another one:
|
||||
|
||||

|
||||
|
||||
Third one, the legendary bot war of 2024 ended in peace.
|
||||
|
||||

|
||||
## How they work
|
||||
One process starts four bots named no-spam[1-4]. These bots look at new rants.
|
||||
|
||||
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,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
Binary file not shown.
|
Before Width: | Height: | Size: 164 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 168 KiB |
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 131 KiB |
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
-29
@@ -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")
|
||||
@@ -1,4 +1,4 @@
|
||||
Metadata-Version: 2.4
|
||||
Metadata-Version: 2.1
|
||||
Name: Ragnar
|
||||
Version: 1.3.37
|
||||
Summary: Anti spam bot for dR
|
||||
@@ -9,90 +9,31 @@ Requires-Python: >=3.7
|
||||
Description-Content-Type: text/markdown
|
||||
Requires-Dist: requests==2.32.3
|
||||
|
||||
# Ragnar Bot: Automated Moderation System for Devrant.io
|
||||
# Ragnar
|
||||
|
||||
## Overview
|
||||
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.
|
||||
This is an anti spam bot network. It is named after the viking for no obvious reason.
|
||||
|
||||
---
|
||||
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
|
||||
- **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.
|
||||
I expect this project tomorrow to have deployed fully functional on a server.
|
||||
|
||||
### Spam Detection
|
||||
- **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.
|
||||
## In progress
|
||||
|
||||
### Automation
|
||||
- **Flagging Spam**: Automatically downvote and comment on posts flagged as spam.
|
||||
- **Concurrent Execution**: Operates multiple bots simultaneously using multithreading.
|
||||
- **Customizable Triggers**: Adjust detection patterns to fit evolving spam trends.
|
||||
The bots work perfect in sense that they're doing what they're programmed to do.
|
||||
But the programming is not finished yet:
|
||||
- the criteria can be better, tips how to optimize are very welcome.
|
||||
- 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
|
||||
- **Logging**: Outputs activity logs to both the console and a file for debugging and monitoring.
|
||||
- **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:
|
||||
|
||||

|
||||
|
||||
Another one:
|
||||
|
||||

|
||||
|
||||
Third one, the legendary bot war of 2024 ended in peace.
|
||||
|
||||

|
||||
## How they work
|
||||
One process starts four bots named no-spam[1-4]. These bots look at new rants.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -13,6 +13,5 @@ src/ragnar/api.py
|
||||
src/ragnar/bot.py
|
||||
src/ragnar/cache.py
|
||||
src/ragnar/cli.py
|
||||
src/ragnar/victoria.py
|
||||
src/ragnar/tests/__init__.py
|
||||
src/ragnar/tests/bot.py
|
||||
@@ -1,13 +1,12 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
file_handler = logging.FileHandler("ragnar.log")
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
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__)
|
||||
|
||||
+20
-80
@@ -1,23 +1,22 @@
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
import time
|
||||
|
||||
from ragnar import log
|
||||
from ragnar.api import Api
|
||||
from ragnar.cache import method_cache
|
||||
from ragnar.victoria import vic
|
||||
|
||||
|
||||
class Bot:
|
||||
|
||||
rant_history = []
|
||||
|
||||
def __init__(self, username, password):
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.name = self.username.split("@")[0]
|
||||
|
||||
self.rant_history = []
|
||||
self.amount_of_rants_to_check = 30
|
||||
self.sus_users = vic.get_spammers()
|
||||
self.sus_users = ["Buffon"]
|
||||
self.names = {
|
||||
"no-spam": "Anna",
|
||||
"no-spam1": "Ira",
|
||||
@@ -26,7 +25,7 @@ class Bot:
|
||||
"no-spam4": "Vira",
|
||||
}
|
||||
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.triggers = [
|
||||
"$",
|
||||
@@ -46,10 +45,7 @@ class Bot:
|
||||
"carat",
|
||||
"carats",
|
||||
"leading",
|
||||
"cheating",
|
||||
"spouse",
|
||||
"spy",
|
||||
# "helping",
|
||||
"helping",
|
||||
"unqiue",
|
||||
"@ragnar",
|
||||
"brides",
|
||||
@@ -60,7 +56,7 @@ class Bot:
|
||||
self.api = Api(username=self.username, password=self.password)
|
||||
|
||||
def rsleepii(self):
|
||||
time.sleep(1)
|
||||
time.sleep(random.randint(1, 3))
|
||||
|
||||
@method_cache
|
||||
def login(self):
|
||||
@@ -74,21 +70,6 @@ class Bot:
|
||||
def clean_rant_text(self, rant_text):
|
||||
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
|
||||
def is_sus_content(self, content):
|
||||
clean_text = self.clean_rant_text(content)
|
||||
@@ -100,25 +81,6 @@ class Bot:
|
||||
log.info(f"Regex trigger {regex} matched!")
|
||||
return True
|
||||
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!")
|
||||
return True
|
||||
return False
|
||||
@@ -152,30 +114,16 @@ class Bot:
|
||||
|
||||
def is_comments_sus(self, rant_id):
|
||||
log.info(f"Checking if comments are sus of rant {rant_id}.")
|
||||
self.rsleepii()
|
||||
rant = self.api.get_rant(rant_id)
|
||||
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"])
|
||||
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", "")):
|
||||
return True
|
||||
return False
|
||||
|
||||
def mark_as_sus(self, rant, is_flagged_by_ai):
|
||||
mark_text = self.mark_text
|
||||
if is_flagged_by_ai:
|
||||
mark_text += "\n* Flagged by AI."
|
||||
self.api.post_comment(rant["id"], mark_text)
|
||||
def mark_as_sus(self, rant):
|
||||
self.rsleepii()
|
||||
self.api.post_comment(rant["id"], self.mark_text)
|
||||
|
||||
def fight(self):
|
||||
self.rsleepii()
|
||||
@@ -184,7 +132,7 @@ class Bot:
|
||||
if rant["id"] in self.rant_history:
|
||||
log.debug("{}: Already checked rant {}.".format(self.name, rant["id"]))
|
||||
continue
|
||||
flagged_by_id = False
|
||||
|
||||
if not self.is_user_sus(rant["user_username"]):
|
||||
log.info(
|
||||
"{}: User {} is trusted.".format(self.name, rant["user_username"])
|
||||
@@ -197,24 +145,17 @@ class Bot:
|
||||
elif rant["user_username"] in self.sus_users:
|
||||
pass
|
||||
elif not self.is_sus_rant(rant["id"], rant["text"]):
|
||||
if not self.is_user_sus(rant["user_username"]):
|
||||
continue
|
||||
log.info(
|
||||
"{}: Rant by {} is not sus by traditional method..".format(
|
||||
"{}: Rant by {} is not sus.".format(
|
||||
self.name, rant["user_username"]
|
||||
)
|
||||
)
|
||||
if vic.is_spam(rant["text"]) <= 5:
|
||||
self.rant_history.append(rant["id"])
|
||||
continue
|
||||
else:
|
||||
log.info(
|
||||
"{}: Rant by {} is sus according to AI.".format(
|
||||
self.name, rant["user_username"]
|
||||
)
|
||||
)
|
||||
continue
|
||||
if self.is_flagged_as_sus(rant["id"], rant.get("num_comments")):
|
||||
self.rant_history.append(rant["id"])
|
||||
continue
|
||||
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"]
|
||||
)
|
||||
)
|
||||
@@ -223,11 +164,10 @@ class Bot:
|
||||
self.name, rant["user_username"]
|
||||
)
|
||||
)
|
||||
self.mark_as_sus(rant, flagged_by_id)
|
||||
self.mark_as_sus(rant)
|
||||
self.down_vote_rant(rant)
|
||||
self.rant_history.append(rant["id"])
|
||||
|
||||
def down_vote_rant(self, rant):
|
||||
vic.dr_downvote_rant(rant["id"], 5)
|
||||
log.warning("Downvoting rant by {} for 5 times.".format(rant["user_username"]))
|
||||
log.debug("Vote result: ".format(self.api.post_rant_vote(rant["id"], -1)))
|
||||
log.warning("Downvoting rant by {}.".format(rant["user_username"]))
|
||||
log.debug(json.loads(self.api.post_rant_vote(rant["id"], -1)))
|
||||
|
||||
+34
-14
@@ -1,5 +1,7 @@
|
||||
import argparse
|
||||
import random
|
||||
import time
|
||||
from concurrent.futures import ThreadPoolExecutor as Executor
|
||||
|
||||
from ragnar import log
|
||||
from ragnar.bot import Bot
|
||||
@@ -14,23 +16,41 @@ def 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))
|
||||
bot = Bot(username=username, password=password)
|
||||
bot.login()
|
||||
while True:
|
||||
time.sleep(random.randint(1, 20))
|
||||
try:
|
||||
bot.fight()
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
usernames = ["no-spam1", "no-spam2", "no-spam3", "no-spam4"]
|
||||
|
||||
while True:
|
||||
with Executor(500) as executor:
|
||||
usernames = [
|
||||
# "no-spam1",
|
||||
# "no-spam2",
|
||||
# "no-spam3",
|
||||
# "no-spam4",
|
||||
# "no-spam",
|
||||
"no-spam2353",
|
||||
"no-spam2351",
|
||||
"no-spam2350",
|
||||
"no-spam2349",
|
||||
"JamesMedina",
|
||||
"MichelleWeeks",
|
||||
"JaredRuiz",
|
||||
"LoriMcgee",
|
||||
"AmandaFloyd",
|
||||
]
|
||||
for username in usernames:
|
||||
time_start = time.time()
|
||||
try:
|
||||
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.")
|
||||
executor.submit(bot_task, f"{username}@molodetz.nl", args.password)
|
||||
executor.shutdown(wait=True)
|
||||
|
||||
|
||||
def run():
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
from xmlrpc.client import ServerProxy
|
||||
|
||||
vic = ServerProxy("https://victoria.molodetz.nl/rpc")
|
||||
Reference in New Issue
Block a user