Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
shadowban-eu-backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
shadowban-eu-backend
Commits
19ec4bd3
Commit
19ec4bd3
authored
Jul 25, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'steve' of git.mycard.moe:nanahira/shadowban-eu-backend into steve
parents
c80a3172
6d5e363e
Pipeline
#22777
passed with stages
in 43 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
8 deletions
+13
-8
backend_requests.py
backend_requests.py
+13
-8
No files found.
backend_requests.py
View file @
19ec4bd3
...
...
@@ -32,8 +32,12 @@ privateKey = os.getenv('TWITTER_AUTH_KEY')
if
privateKey
:
twitterKeys
=
privateKey
.
split
(
" "
)
cookie
=
os
.
getenv
(
'COOKIE'
)
csrf
=
os
.
getenv
(
'CSRF'
)
cookies
=
[
os
.
getenv
(
'COOKIE'
)]
cookie_file
=
os
.
getenv
(
'COOKIE_FILE'
)
if
cookie_file
:
with
open
(
cookie_file
,
'r'
)
as
f
:
cookies
=
str
.
strip
(
f
.
read
())
.
split
(
"
\n
"
)
print
(
"Booting"
)
ENDPOINT
=
{
...
...
@@ -73,9 +77,10 @@ def getTwitterSession(useCookie):
twitter_b
=
OAuth2Session
()
twitter_b
.
headers
[
"Authorization"
]
=
"Bearer {}"
.
format
(
random
.
choice
(
twitterKeys
))
twitter_b
.
headers
[
'user-agent'
]
=
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
if
cookie
and
csrf
:
# and useCookie:
cookie
=
random
.
choice
(
cookies
)
if
cookie
:
# and useCookie:
twitter_b
.
headers
[
'cookie'
]
=
cookie
twitter_b
.
headers
[
'x-csrf-token'
]
=
c
srf
twitter_b
.
headers
[
'x-csrf-token'
]
=
c
ookie
.
split
(
"ct0="
)[
1
]
.
split
(
";"
)[
0
]
return
twitter_b
def
doSearch
(
screen_name
):
...
...
@@ -346,7 +351,7 @@ def searchban(screen_name):
print
(
"User ID of {}: {}"
.
format
(
screen_name
,
user_id
))
get_reply_vars
=
{
"count"
:
20
,
"userId"
:
user_id
,
"count"
:
20
0
,
"userId"
:
user_id
,
"includePromotedContent"
:
False
,
"withSuperFollowsUserFields"
:
False
,
"withBirdwatchPivots"
:
False
,
"withDownvotePerspective"
:
False
,
"withReactionsMetadata"
:
False
,
"withReactionsPerspective"
:
False
,
"withSuperFollowsTweetFields"
:
False
,
"withVoice"
:
False
,
"withV2Timeline"
:
False
,
...
...
@@ -374,7 +379,7 @@ def searchban(screen_name):
if
not
ghostban
:
# all checks done
break
if
ent
[
"entryId"
]
.
startswith
(
"tweet"
):
if
ent
[
"entryId"
]
.
startswith
(
"tweet"
)
and
"legacy"
in
ent
[
"content"
][
"itemContent"
][
"tweet_results"
][
"result"
]
:
tmp
=
ent
[
"content"
][
"itemContent"
][
"tweet_results"
][
"result"
][
"legacy"
]
if
"in_reply_to_status_id_str"
in
tmp
and
tmp
[
"in_reply_to_status_id_str"
]
not
in
checkedTweets
:
reply
=
tmp
...
...
@@ -414,7 +419,7 @@ def searchban(screen_name):
print
(
"Current entry of {} is: {}"
.
format
(
screen_name
,
ent
[
"entryId"
]))
if
ent
[
"entryId"
]
.
startswith
(
"conversationthread"
)
and
ghostban
:
for
item
in
ent
[
"content"
][
"items"
]:
if
"tweet_results"
in
item
[
"item"
][
"itemContent"
]
and
item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
][
"legacy"
][
"user_id_str"
]
==
user_id
:
if
"tweet_results"
in
item
[
"item"
][
"itemContent"
]
and
"legacy"
in
item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
]
and
item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
][
"legacy"
][
"user_id_str"
]
==
user_id
:
replyId
=
item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
][
"legacy"
][
"id_str"
]
returnjson
[
"tests"
][
"ghost"
]
=
{
"ban"
:
False
,
"tweet"
:
tweetId
,
"in_reply_to"
:
replyId
}
ghostban
=
False
...
...
@@ -437,7 +442,7 @@ def searchban(screen_name):
if
c_ent
[
"entryId"
]
.
startswith
(
"conversationthread"
):
print
(
"Checking more contents of {} by {}"
.
format
(
tweetId
,
screen_name
))
for
c_item
in
c_ent
[
"content"
][
"items"
]:
if
c_item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
][
"legacy"
][
"user_id_str"
]
==
user_id
:
if
"legacy"
in
c_item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
]
and
c_item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
][
"legacy"
][
"user_id_str"
]
==
user_id
:
replyId
=
c_item
[
"item"
][
"itemContent"
][
"tweet_results"
][
"result"
][
"legacy"
][
"id_str"
]
returnjson
[
"tests"
][
"more_replies"
]
=
{
"ban"
:
True
,
"in_reply_to"
:
replyId
,
"tweet"
:
tweetId
}
print
(
"{} is reply deboosted because of {} => {}."
.
format
(
screen_name
,
tweetId
,
replyId
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment