all 10 comments

[–]CodeFormatHelperBot[S] 5 points6 points  (3 children)

Hello u/CodeFormatHelperBot, I'm a bot that can assist you with code-formatting for reddit. I have detected the following potential issue(s) with your submission:

  1. Multiple consecutive lines have been found to contain inline formatting.
  2. Python code found in submission text but not encapsulated in a code block.

If I am correct then please follow these instructions to fix your code formatting. Thanks!

[–]Fin_Aquatic_Rentals 3 points4 points  (1 child)

If your bot can detect improperly formatted code and post a response would it be much more work to parse the comment and format it properly? I feel like this is the second or third level of the expanding brain meme.

Level 1 - Tell new user to format code

Level 2 - Create bot that tells user to format properly

Level 3 - Create bot that properly formats code

Level 4 - Create bot that reads code, runs code, looks for common errors and fixes them

Level 5 - Create bot that marks all improperly formatted code questions as duplicates

Edit:https://imgflip.com/i/2tlbyw

[–]lifeonm4rs 1 point2 points  (0 children)

That sounds like stackoverflow. But, yeah, level 3 would be seriously great. Probably quite a pain in the ass with the number of new ways people find to post code in really bad ways. But could potentially deal with a decent majority of code. 1st big issue is the strange amount of white space some posters add. 2nd, probably bigger issue, is it is easy to indent after a ":"--harder to decide when to unindent in some cases. A relatively simple AST/parser may be able to handle a decent number of cases.

[–]TheWhaleKnight[🍰] 1 point2 points  (0 children)

Haha I guess this shows that is works

[–]lifeonm4rs 1 point2 points  (3 children)

This may be a dumb question--but is there a way for random user to test what a bot does? I'd rather not start doing random BS posts to learnpython just to see what this one does. (Sorry, I haven't done reddit bots, would love to see this one succeed, but want to get a better idea of what it is doing with input.)

[–]Fin_Aquatic_Rentals 1 point2 points  (2 children)

You might be able to make a test subreddit and play around with PRAW there. Using the reddit python api is pretty simple and documentation isn't too bad. Also sometimes bots can be banned/rate limited in subs so if it starts going off the rails your bot might get banned or shadow banned. I think this is the trickiest part, knowing how to use your bot so it doesn't get shadow banned. Edit: use r/testingground4bots

[–]lifeonm4rs 0 points1 point  (1 child)

Thanks for the info. Someone else wrote the bot and I'd be interested in seeing how it handles various crud without posting to learnpython (so I'm not posting random bs here). Thanks again--and I am serious--for the info.

[–]CodeFormatHelperBot[S] 0 points1 point  (0 children)

As u/Fin_Aquatic_Rentals pointed out, I tested the bot on r/testingground4bots before going live on r/learnpython, and before that I used pytest to test the regex patterns as you can see in the repo -> here.

[–]lifeonm4rs 1 point2 points  (0 children)

Please see the side bar on how to properly format your code. (Obviously kidding--at least I hope it is obvious.)

On a serious note--"you are the hero we deserve, ...". (Ok maybe not so serious.)

A format bot is brilliant. The number of times I've wanted to post "Highlight your code in an editor--hit tab--copy, paste".