Extract delimited sections from Google Docs to post in Discord thread

What are you trying to achieve?

I write short stories for my Discord users, and post them serialised on a daily schedule.
I do this manually, but it would be nice if I could automate this.

My process:
Write story (anywhere between 6 and 50 pages)
Go through the story and find the cut off points (roughly per page) and delimit those with a line of ‘=’
Every morning grab the next section and post it in the thread for that story, appending a tag (‘|| @readers ||’) so the people with that role get a notification
Go to yesterday’s post(s) and remove the tag

Caveats:
The posts sometimes exceed the maximum character count for a post, and need to be split. In that case both posts get the tag, so the next day two tags need to be removed
The posts contain italicised and/or bold text, these need to be translated to Discord markup (1, 2 or 3 asterisks on either side)

I realise this is a very complex scenario for a starter, and I don’t need everything in there to be in the first iteration, I’m absolutely happy to experiment, but the bigges issue is that there’s so many apps and modules, that I am completely lost…

I found the Google Docs module, YAY!

I already stumble at the next step: Splitting the content at the markers (“==========”) and putting it in an array, so I can then select the appropriate next block (I considered a few options for that, the easiest one: remove the markers and only take the section between the first and second marker, but I could also maintain a counter and increment that on every post…

I’m not asking for a complete solution, but if someone (or multiple people) could at least point me at the correct modules or tutorials…

Steps taken so far

Created a Make account, logged in, created a new scenario, added the Google Docs module, logged in and found the document.

Welcome to the Make community!

If you’re just looking to chunk text up into maximum character lengths without breaking up whole words, take a look at ✅ Resolved! Breaking up long text to correct nice looking chunks (with correct length)!

I think Discord is 2000 characters per message, so you can just put that into the first field.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

Thanks for your reply, but the toolbox doesn’t even come close to the functionality I am looking for.

The biggest problem I am facing is the Google Docs module itself… It doesn’t provide the document’s text in a format that can both be seached and modified to Discord’s MarkDown format, which is Ironic, as Google Docs itself literally offers a ‘download as MD’ option, which the module lacks…

It might help once all the other things are taken care off to split too-large posts…

If you want Markdown, simply download as HTML, then use the Markdown “HTML to Markdown” module —

Transforms HTML into Markdown.

For more information about the HTML to Markdown module and Markdown app, see the corresponding Integrations page and the Help Centre documentation.

Hope this helps! Let me know if there are any further questions or issues. P.S.: investing some effort into the tutorials in the Make Academy will save you lots of time and frustration using Make!

@samliew

Yeah, that’s what you’d expect, but that doesn’t work quite as it should either!

With what I have found so far, there is no reliable way to change Google Docs’ HTML (or other format) content into MD formatted text that can be used in Discord.
(I obviously did some more testing and trial since the OP)

So far I have wasted more time on this than I have spent manually copying, pasting and marking up the ‘episodes’ in Discord

I have just managed to get the MD format using a google drive API (which requires extensive additional set-up for authenticating with OAUTH2) and the regex parser to break it into the desired blocks…

Next steps in the prep part of the scenario should be more straight forward (I hope)

I now have the majority of it working… And your Chunk Text seemed to be exactly what I needed in case my individual ‘episodes’ exceed the message post maximum (2000 normal, 4000 Nitro)

I am trying to use your ‘Chunk Text’ tool, but it breaks a block up in many little chunks (the longest is 398 chars, but there’s a lot of chunks smaller than 100!) despite the Per Chunk value being set to 2000…

Is this a bug?


UPDATE:
I worked around it with a regex parser, because for me that suffices:

This is the final scenario:

Get the GDOC file in MD
Count the days since begin (to be able to filter for the correct bundle later on)
Round the days down to the integer value and assign it to DayCount
Break the file up into chunks based on the delimeter [ (.?)\=.?\n ]
== Filter based on Bundle.index==DayCount ==
Break today’s bundle up into chunks of max 1950 characters, on the farthest newline possible [ (.{1,1950}\n) ]
Add “\n|| <@&136xxxxxxxxxxxxxxx101> ||” so the special role gets pinged
Send into the correct thread

2 Likes

without knowing what the input is, it’s hard to say.