osome-iu / botometer-python

A Python API for Botometer by OSoMe
https://botometer.osome.iu.edu
MIT License
371 stars 59 forks source link

Requested user is customer_key account when using SubProcess #78

Closed Civel-1 closed 1 month ago

Civel-1 commented 1 year ago

Hello, My problem is pretty simple, everytime I call botometer inside a SubProcess, botometer won't use the user_name (screen_name) provided but will pick the one associated with the customer key account.

I managed to reproduce the problem on a second computer, on PyCharm and console, so I believe there might be a bug. Here are the way of reproducting it.

Env : Python 3.7.9 botometer 1.6.1 tweepy 3.10.0

subprocess.py

import json
import os
import subprocess
import argparse
import re

p = subprocess.Popen(["venv/Scripts/python", "botometer.py", "-s \"realDonaldTrump\""], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

output, err = p.communicate()
p.kill()
output = str(output)
print(output)

botometer.py

import botometer
from config import consumer_key, consumer_secret, access_token, access_token_secret
import argparse
import re

# Authenticate
rapidapi_key = 'xxxxx'
twitter_app_auth = {
    'consumer_key': consumer_key,
    'consumer_secret': consumer_secret,
    'access_token': access_token,
    'access_token_secret': access_token_secret,
  }
bom = botometer.Botometer(wait_on_ratelimit=True,
                          rapidapi_key=rapidapi_key,
                          **twitter_app_auth)
def fake_followers(screen_name):
    result = bom.check_account('@' + str(screen_name))
    return result['user']['user_data']['screen_name']

# Add arguments
parser = argparse.ArgumentParser(description="Bot detector")
parser.add_argument("-s", "--screen_name", dest="screen_name", help='screen_name of the user to be analyzed',
                    required=False)
args = parser.parse_args()
print(fake_followers(args.screen_name))

How to replicate :

Feel free to ask for clarifications or more informations. Have a nice day and thank you for this amazing tool !