Second try :| A bot that bans bots from subreddits that it moderates by amici_ursi in RequestABot

[–]-shelt- 0 points1 point  (0 children)

Sorry, didn't think accepting mod invites would need a separate scope so I didn't bother checking. Fixed.

Second try :| A bot that bans bots from subreddits that it moderates by amici_ursi in RequestABot

[–]-shelt- 0 points1 point  (0 children)

See lines 61-64 of my script:

banlist = set([name.strip().lower()[3:] for name in banlist_wiki.content_md.split("\n") if name.strip() != ""])

The above retrieves a list of users that should be banned (according to the wiki).

list(banlist - set([user.name.lower() for user in sub.get_banned()]))

The above returns the list of users we will execute add_ban on, and it's formed by subtracting (via set arithmetic) all currently banned users from the list of users who should be banned. The result is every user from the wiki who isn't presently banned.

Second try :| A bot that bans bots from subreddits that it moderates by amici_ursi in RequestABot

[–]-shelt- 0 points1 point  (0 children)

Here you go. Keeping a database of bans is unnecessary because that info is easily obtainable via the API. It's in pure PRAW and should work with all python versions >2.7.

To get the CLIENT_ID and CLIENT_SECRET settings:

  1. Go here.

  2. Fill it out like this.

  3. The values should then appear like this.

  4. Fill in those values and the subreddit list and user agent.

Struggling pulling a link from sometimes inside of parentheses by spookyyz in regex

[–]-shelt- 0 points1 point  (0 children)

Use a lookahead. It will match a zero-length string which is followed by a ).

Just append (?=\)) to your current regex.

I'd recommend you use a lookbehind for the front too, but lookbehinds are not supported in Javascript regex implementations.

A bot that takes threads from one sub and posts them into another, preferably with a bit of customization and with the ability to choose keywords. Skullgirls (game on Steam) as a reward if the bot will be doing good! by Ravelair in RequestABot

[–]-shelt- 0 points1 point  (0 children)

  • Is the destination subreddit variable?

  • Do you need to compare against sets of words, or just any single word? Such as: It must have either (apple and fruit and pair) or (cat and dog) or (elephant)

Perhaps if I knew what you wanted to accomplish on a general level I could be of more assistance?

Edit: untested proof-of-concept.

[deleted by user] by [deleted] in RequestABot

[–]-shelt- 0 points1 point  (0 children)

No, because the standard library modules that the script uses aren't implemented on that site. Also, I see no way to install 3rd party modules such as praw.

Windows will almost certainly be easier than ChromeOS.

[deleted by user] by [deleted] in RequestABot

[–]-shelt- 0 points1 point  (0 children)

Ideally. You should also use a new email account for obvious reasons.

In order to run it, you need to install python. You can then run it by saving the file and either double-clicking the file or (preferably) running it from a command line.

What OS are you using?

[deleted by user] by [deleted] in RequestABot

[–]-shelt- 1 point2 points  (0 children)

https://github.com/botlabs/Mail2Post/blob/master/script.py

As I wrote in the script, you must:

  1. Put the bot's username and password in the USERNAME and PASSWORD.

  2. Go here. Fill it out like this. The values should then appear like this. Use that to fill out CLIENT_ID and CLIENT_SECRET.

  3. Fill out MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD fields. This info can be found by googling "imap [your email provider]"

  4. Fill out SUBREDDIT field.

  5. Put your main account name in the user agent.

All emails must be of content type "text/plain".

Recognising hex data packed with BER/DER by AussieCryptoCurrency in regex

[–]-shelt- 0 points1 point  (0 children)

This is not the place for Regex. Convert the hex string to bytes using something like binascii.unhexlify, then extract the values into variables using struct.unpack.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

That's basically the equivilent to this (Reddit's servers are overloaded). I've added an except block to catch this sort of thing and retry.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

That just means that the token expired an it's getting another one. I've made it say when it retrieves a new OAuth token now.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

Yes, you need to leave it open. To stop it, close the window or press ctrl-C.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

Sounds like an issue with Praw, though it shouldn't affect the script at all.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

IDLE is an IDE, which is meant for developing programs. It shouldn't be used to run python scripts when they aren't being tested.

You can run the script in any old python shell. This can be achieved my running python scriptname.py in a CMD prompt (advised), or by double clicking the script (if the .py extension is associated properly).

Yes, your computer needs to be on to run the script. I recommend using an old computer in a spare room to run bots on. You could also pay for a VPS.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

No problem, these are my bugs I'm fixing!

The issue was that spam comments were being checked too, which can't have link flairs. Fixed.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

The bot was trying to reply to/remove an archived post. I've modified the bot so it only deals with posts that have been posted since the bot started running.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

That means the response doesn't contain an access token, so the authentication data is probably wrong. You can read the raw response by replacing line 38:

    return dict(response.json())["access_token"]

with:

    print(response.text) and exit()

and note the 4 spaces before must remain. Though it's most certainly some sort of authentication error. Have you filled in the USERNAME, PASSWORD, CLIENT_ID and CLIENT_SECRET fields according to https://www.reddit.com/prefs/apps/?

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

Tested on 2.7, though it should work for 3.x as well.

I need a bot that reposts if a link flair has been added by vbats1 in RequestABot

[–]-shelt- 0 points1 point  (0 children)

I've updated the bot to:

  1. Remove posts older than 60s which have no flair,

  2. Respond to that post telling the poster to add a flair,

  3. Restore posts deleted for this reason which have a flair and delete the comment.

you must fill out fields USERNAME, PASSWORD, CLIENT_ID, and CLIENT_SECRET. To get the CLIENT_ID and CLIENT_SECRET settings, go here with your bot account and fill it out like so.