pyFlarum Bulk Discussions

A pyFlarum script that allows you to automatically create discussions from markdown text files in a directory.

Usage

https://github.com/cwkevo/pyflarum-bulk-discussions

Download/clone the repository. cd into repository root.

Put your text files you'd wish to create as discussions in /discussions.
The file name (without extension) will be used as the title of the discussion. The file contents will be used as the body of the discussion. Markdown format is supported.

python -m bulk_discussions -f <your forum URL> -u <your account username> -p <account password>

Example:

python -m bulk_discussions -f https://flarum.example.com -u admin -p cooladmin123

Disclaimer

By absolutely no means I support any malicious use of this script in order to create unwanted content/spam.
I made this script as an option to solve a problem described in this discussion, and I am not responsible for any damage caused by this script. You are solely responsible for your own actions.

If you feel that you are a victim of the inproper use of this tool, you can block the pyflarum user agent at the server where your Flarum instance is hosted on, which will effectively block all traffic made by this script.

9 months later

SKevo Hello, Hello, sorry. I was troubled by some work, which made me forget this post.
Luckily, I recalled it (it's not something to be proud of)
My local device is windows. After downloading the pyflarum-bulk-discussions you provided, I created some test markdown files in the discussions folder, and then executed the following code in powershell, but there was no change in my forum and no new posts were created.
The following is the command I changed. I confirm that the relevant fields I filled in are correct. Due to privacy, I have replaced the URL, user name and password with the relevant URL and user of the forum

python -m bulk_discussions -f https://test.flarum.org/ -u testuser -p testpassword
    Merged 1 post from [Python script] Publish discussions from text files in a folder automatically.
    GreXXL changed the title to pyFlarum Bulk Discussions .

    SKevo could you check what's the output of that command, please?

    I don't understand. The powershell terminal I use
    This is my situation.
    Picture
    And then this is the output tab, and he doesn't have any logs.
    Picture2

      21 days later

      JerryYang I later tried to write the account and url into the code and ran successfully
      I will add this code

          parser = ArgumentParser()
          parser.add_argument('--forum_url', '--url', '-f', help='Forum URL to create discussions for.', required=True)
          parser.add_argument('--username', '-u', help='Username to log into.', required=True)
          parser.add_argument('--password', '-p', help='Password for the user.', required=True)
          args = parser.parse_args()
      
              USER = FlarumUser(forum_url=args.forum_url, username_or_email=args.username, password=args.password)

      Change to

          FORUM_URL = "https://test.org/"
          USERNAME = "testuser"
          PASSWORD = "testpassword"
      
              USER = FlarumUser(forum_url=FORUM_URL, username_or_email=USERNAME, password=PASSWORD)