This is the repository for DARMA: Dialogue Agent for Reducing Malicious Acts, a team from the Information Sciences Institute, University of Southern California for the AIE Civil Sanctuary project.
DARMA is currently set up with 4 main modular components:
- Translator: necessary for making DARMA applicable for all languages
- Moderation classifier: any triggers that assist moderation strategy
- Moderation strategy: based on triggers from the moderation classifier, determine the moderation strategy
- Response generator: generate responses to be used for moderation
git clone [email protected]:wise-east/isi_darma.git
conda create -n darma python=3.7
cd isi_darma
pip install -r requirements.txt
pip install -e .
export CRED_FP="<your path to creds.yaml file>"
Important: Step 5 is important for being able to use the reddit client. Refer to the reddit client section
You can find a basic implementation of DARMA bot in src/basic_bot.py
.
By executing python src/basic_bot.py
and keeping it running, you will be running a bot that responds to all comments, except for its own, in the subreddit r/darma_test
. It is currently set up to respond to all existing comments using SpolinBot without keeping track of which ones it already responded to. It has the following flow for the time being:
- Detect language of incoming comment
- Translate comment to English
- Determine whether moderation is needed.
- If needed, determine the moderation strategy
- If moderation strategy is to respond, generate a response.
- Translate generated response back to source language.
First, clone this repo and then create your own branch.
git checkout -b <your branch name>
<make code updates>
git add .
git commit -m '<your updates>'
Before making any code changes, make sure to regularly check whether there have been updates to the main
branch and keep your code up to date.
git checkout main # checkout to the main branch
git pull origin main # make sure that your main branch is up to date
git checkout <your branch> # checkout to your branch
git rebase main # make sure that your branch is building on top of all the updates in the main branch
You may have to resolve conflicts on merging with the last command. it might not be desirable to merge yet if there are conflicts, so if in doubt, please ask.
After making updates, make sure to first rebase with the main
branch before you make any pushes and pull requests. Follow the same steps as above.
To use the Reddit API, you need the following parameters:
reddit = praw.Reddit(
user_agent="",
client_id="",
client_secret="",
username="",
password=""
)
user_agent
can be anything, but the recommended format is<platform>:<app ID>:<version string> (by u/<Reddit username>)
- You can find the
client_id
,client_secret
in https://www.reddit.com/prefs/apps/. - The username and password is the reddit account's username and password.
- All the relevant information is loaded from a
creds.yaml
file. Ask Justin for this file if you would like to test with darma bot or provide your own credentials to test your own bot. creds.yaml
file should have the format:
username:
password:
client_secret:
client_id:
Here are the list of references used for developing this bot.
- How To Make A Reddit Bot?
- https://www.reddit.com/r/redditdev/comments/fj06x8/comment_reply_bot_using_praw/
- https://github.com/toddrob99/MLB-StatBot/blob/master/statbot/main.py
- Reddit Moderator Guide
- Bobby-b-bot: easiest code base to use as starting point for bot that replies to comments.
MIT License