Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit5101eb9

Browse files
author
PokestarFan
committed
Update with final product
1 parentca0f7e7 commit5101eb9

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

‎.gitignore‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,11 @@ ENV/
102102

103103
#my login
104104
login.py
105+
106+
#pycharm
107+
.idea/
108+
109+
#files used by program
110+
blockusers.txt
111+
posts_written_to.txt
112+
writes.txt

‎.idea/vcs.xml‎

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎duplicate.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
importre
2+
importpraw
3+
fromloginimportreddit
4+
5+
defaction():
6+
forsub_idinreddit.subreddit('all').stream.submissions():
7+
blockeduser=0
8+
item_written_to=0
9+
foriteminreddit.inbox.unread(limit=None):
10+
ifstr(item.subject)=='Remove me from posts':
11+
body=str(item.body)
12+
yes=re.search('\/u\/[a-zA-Z0-9]+',body)
13+
username=yes.group(0)
14+
ifstr(item.author)==username:
15+
withopen('blockedusers.txt','a')asfile:
16+
newstring=username.replace(r'/u/','')
17+
file.write(newstring)
18+
withopen('posts_written_to.txt','r')aswritefile:
19+
forid_to_useinwritefile.readlines():
20+
ifitem_written_to==0:
21+
ifsub_id==id_to_use:
22+
item_written_to=1
23+
duplicates= []
24+
submission=praw.models.Submission(reddit,id=sub_id)
25+
withopen('blockusers.txt','r')asnewfile:
26+
forlineinnewfile.readlines():
27+
ifsubmission.author==lineandblockeduser==0:
28+
pass
29+
else:
30+
blockeduser=1
31+
ifblockeduser==0anditem_written_to==0:
32+
forduplicateinsubmission.duplicates():
33+
dup_sub=praw.models.Submission(reddit,id=duplicate)
34+
duplicates.append({'title':str(dup_sub.title),'subreddit':str(dup_sub.subreddit),'link':str(
35+
dup_sub.shortlink)})
36+
iflen(duplicates)>0:
37+
message='Here is a list of threads in other subreddits about the same content:\n'
38+
fordupinduplicates:
39+
message=str(message+'\n # [{}]({}) on /r/{}').format(dup['title'],dup['link'],dup['subreddit'])
40+
message=message+'\n\n ----\n\n ^^I^^am^^a^^bot^^[FAQ](https://www.reddit.com/r/DuplicatesBot/wiki/index)-[Code](https://github.com/PokestarFan/DuplicateBot-[Bugs](https://www.reddit.com/r/DuplicatesBot/comments/6ypgmx/bugs_and_problems/)-[Suggestions](https://www.reddit.com/r/DuplicatesBot/comments/6ypg85/suggestion_for_duplicatesbot/)-[How to block](https://www.reddit.com/r/DuplicatesBot/wiki/index#wiki_block_bot_from_tagging_on_your_posts'
41+
try:
42+
submission.reply(message)
43+
withopen('writes.log','a')aslogfile:
44+
logfile.write('Replied to submission id {}'.format(sub_id))
45+
print('Replied to submission id {}'.format(sub_id))
46+
withopen('posts_written_to.txt','a')aswritefile2:
47+
writefile2.write(sub_id)
48+
except(UnboundLocalError):
49+
pass
50+
51+
52+
if__name__=='__main__':
53+
action()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp