This is the repository for u/PowerShell-Bot.
The purpose of the bot is to teach Redditors on r/PowerShell how to properly format code in their submissions using code blocks.
When the submission author fixes their submission the bot notices and modifies its comment reply accordingly.
Thanks to u/Ta11ow (vexx32) for the idea of saving u/Lee_Dailey some copy-pasting, and putting together the original regex to detect PowerShell code snippets.
The program requires Python 3.8+.
Configuration files from the current directory are required by the bot.
The program will also read and write to files in the current directory.
It is recommended that you create a dedicated project directory which includes
a symbolic link named powershell_bot
to the package source.
To view the bot program’s available command line parameters:
python -m powershell_bot --help
Use the run
sub-command to start the actual bot.
Configuration files are searched for in the current directory. These files are not shown in the repo and they should be created prior to running the bot.
-
powershell_bot.ini
Keys:
-
database_url
: The database URL for SQLAlchemy to connect to. -
username
: The name of the Reddit account this bot will run on. Case sensitive. The name is used as the section name to access credentials for in thepraw.ini
file. It must be an exact match to the section name in thepraw.ini
file and to the account name this bot will run on on Reddit.Also used for the online presence indicator feature.
-
password
: Password of the bot account. This is required for the online presence indicator feature. -
target_subreddit_name
: The subreddit name in which this bot will run on. Case insensitive. -
advanced_comment_replying_enabled
: Whether advanced comment replying is enabled.Value is a boolean: see the Python
configparser
module documentation for acceptable boolean string values.Normally, if the bot gets a comment that says “Good bot” then the bot will reply with “Good human”, but if the comment is something else then, if this option is enabled, advanced comment replying will happen. The code for this logic is not supplied in this repository, so if you intend to run this codebase yourself then you’ll need to implement this feature on your own if you want it. This can be done by writing a function named
get_advanced_comment_reply
in a module namedpowershell_bot_snapins.advanced_comment_replying
. See the codebase for hints.
-
-
praw.ini
Must contain a section name that matches the value of the
username
configuration in thepowershell_bot.ini
file. The credentials in this section are used to instantiate the RedditWarp client.