Skip to main content

Tutorials

Step-by-step guides for common RedHarmony tasks.

Creating Your First Persona

Basic Persona Setup

  1. Open accounts.json:
[
{
"subreddits": ["python", "learnpython"],
"prompt": "You are a helpful Python developer..."
}
]
  1. Define personality traits:
{
"prompt": "You are a helpful Python developer with 5 years of experience. You enjoy explaining complex concepts in simple terms. Your communication style is friendly and encouraging, often using code examples to illustrate points..."
}
  1. Test your persona:
python main.py --test-persona 0

Advanced Persona Configuration

Create a more complex persona:

{
"subreddits": ["python", "learnpython", "programming"],
"prompt": "You are a senior Python developer...",
"interaction_style": "technical",
"knowledge_areas": ["python", "algorithms", "data_structures"],
"response_patterns": {
"questions": "detailed_with_examples",
"discussions": "analytical",
"help_requests": "step_by_step"
}
}

Customizing Rate Limits

  1. Open main.py
  2. Locate the rate limit section:
daily_post_limit = 20
daily_comment_limit = 100
hourly_post_limit = 2
hourly_comment_limit = 5
  1. Adjust values based on your needs:
# Example for lower frequency
daily_post_limit = 10
daily_comment_limit = 50
hourly_post_limit = 1
hourly_comment_limit = 3

Setting Up Multiple Subreddits

  1. Identify target subreddits
  2. Update accounts.json:
[
{
"subreddits": [
"python",
"learnpython",
"djangolearning",
"flask"
],
"prompt": "You are a Python web developer..."
}
]
  1. Test subreddit access:
from utils.helper import subreddit_valid
for subreddit in account["subreddits"]:
if not subreddit_valid(reddit, subreddit):
print(f"Cannot access: {subreddit}")

Implementing Custom Vote Behavior

  1. Create a voting strategy:
# utils/vote.py
def custom_vote_strategy(content_type, score):
if content_type == "post":
if score < 0:
return "up"
return "none"
elif content_type == "comment":
if score < -2:
return "up"
return "none"
  1. Integrate with voting system:
def vote_post(post):
vote_action = custom_vote_strategy("post", post.score)
if vote_action == "up":
post.upvote()
elif vote_action == "down":
post.downvote()

Monitoring and Analytics

  1. Create a monitoring script:
# monitor.py
from utils.database import get_db_connection

def analyze_activity():
conn = get_db_connection()
cursor = conn.cursor()

# Get post statistics
cursor.execute("""
SELECT
COUNT(*) as post_count,
AVG(score) as avg_score
FROM posts
WHERE date(timestamp) = date('now')
""")

# Print results
results = cursor.fetchone()
print(f"Today's Stats:")
print(f"Posts: {results[0]}")
print(f"Average Score: {results[1]}")
  1. Run monitoring:
python monitor.py