Giter VIP home page Giter VIP logo

doctoctoc / doctoctocbot Goto Github PK

View Code? Open in Web Editor NEW
9.0 5.0 5.0 22.17 MB

Mastodon & Twitter retweet bot with collective moderation of retweeted accounts through Quick Replies DMs

Home Page: https://doctoctoc.net

License: Mozilla Public License 2.0

Python 50.42% HTML 11.47% JavaScript 20.81% CSS 14.49% Shell 0.16% Dockerfile 0.07% SCSS 0.69% Svelte 1.88% TypeScript 0.02%
mastodon mastodon-bot twitter-bot

doctoctocbot's People

Contributors

dependabot[bot] avatar jeromecc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

doctoctocbot's Issues

follow members

Bots should follow verified users who are members or potential members.

bad definition of top & help statuses lists

top_statusid_lst(hourdelta) & help_statusid_lst(hourdelta) do not take into account human moderation & they exclude questions spread in a thread if the hashtag is not present in the root status.

Needs rewriting.

QuerySet' object has no attribute 'remove

File "/code/src/bot/onstatus.py", line 29, in get_status_communities
for c in Community.objects.filter(active=True).remove(community):
AttributeError: 'QuerySet' object has no attribute 'remove'

2021-02-10 11:04:13,055 - celery.app.trace - ERROR - Task moderation.tasks.poll_moderation_dm[927b139b-93d4-4495-a12a-13c918bb6e57] raised unexpected: AttributeError("'QuerySet' object has no attribute 'remove'")
Traceback (most recent call last):
File "/code/src/bot/onstatus.py", line 63, in triage_status
tweetdj = Tweetdj.objects.get(statusid=status_id)
File "/usr/local/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 406, in get
raise self.model.DoesNotExist(
conversation.models.Tweetdj.DoesNotExist: Tweetdj matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/celery/app/trace.py", line 385, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/celery/app/trace.py", line 650, in protected_call
return self.run(*args, **kwargs)
File "/code/src/moderation/tasks.py", line 301, in poll_moderation_dm
process_cat_mi(cat_mi, moderated_su_mi, moderator_su_mi, mod_mi)
File "/code/src/moderation/tasks.py", line 355, in process_cat_mi
triage_status(status_id, community)
File "/code/src/bot/onstatus.py", line 68, in triage_status
status = get_status_communities(status_id, community)
File "/code/src/bot/onstatus.py", line 29, in get_status_communities
for c in Community.objects.filter(active=True).remove(community):
AttributeError: 'QuerySet' object has no attribute 'remove'

bug in hashtag normalization

status containing both tracked hashtags (doctocotc & docstoctoc) show up as having only one or the other.
hashtag retained seems to be the last one occurring in the tweet:

"doctoctoc ... docstoctoc" -> docstoctoc

"docstoctoc ... doctoctoc" -> doctoctoc

Consolidate configuration [refactoring]

• Currently some modules of the project contain hard coded constant variables that should be shared across the different modules and that are, for some, already present in the configuration file. For example the 'addtolist' module contain a hard coded 'bot_id' variable.
• Currently several modules implement their own way to load the configuration file, instead they should all use the 'getConfig' method of the 'cfg' module. For example in the 'addtolist' module on line 14 to 16.
• It seems there was a move to use json based configuration file, maybe that should be reconsidered (see footnotes 1 & 2) ?

  1. https://softwareengineering.stackexchange.com/questions/351126/how-bad-of-an-idea-is-it-to-use-python-files-as-configuration-files
  2. https://revelry.co/json-configuration-file-format

Error when trying to sign in with Twitter if already authenticated as classic Django user

AuthAlreadyAssociated at /oauth/complete/twitter/

Environment:

Request Method: GET
Request URL: http://localhost:XXXX/oauth/complete/twitter/?redirect_state=xxx&oauth_token=xxx&oauth_verifier=xxx

Django Version: 2.0.13
Python Version: 3.7.2
Installed Applications:
['users',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
'rest_framework',
'doctocnet',
'landing',
'social_django',
'moderation',
'conversation',
'bot',
'dm',
'charts',
'display',
'timeline',
'crispy_forms',
'paypal.standard.ipn',
'crowdfunding',
'registration',
'django_countries',
'customer',
'debug_toolbar',
'status',
'django_extensions']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware']

Traceback:

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_django/utils.py" in wrapper
49. return func(request, backend, *args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_django/views.py" in complete
33. *args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/actions.py" in do_complete
43. user = backend.complete(user=user, *args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/backends/base.py" in complete
40. return self.auth_complete(*args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/utils.py" in wrapper
259. return func(*args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/backends/oauth.py" in auth_complete
184. return self.do_auth(access_token, *args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/utils.py" in wrapper
259. return func(*args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/backends/oauth.py" in do_auth
195. return self.strategy.authenticate(*args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_django/strategy.py" in authenticate
107. return authenticate(*args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/django/contrib/auth/init.py" in authenticate
70. user = _authenticate_with_backend(backend, backend_path, request, credentials)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/django/contrib/auth/init.py" in _authenticate_with_backend
116. return backend.authenticate(*args, **credentials)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/backends/base.py" in authenticate
80. return self.pipeline(pipeline, *args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/backends/base.py" in pipeline
83. out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs)

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/backends/base.py" in run_pipeline
113. result = func(*args, **out) or {}

File "/home/elkcloner/.virtualenvs/doctoctocbot/lib/python3.7/site-packages/social_core/pipeline/social_auth.py" in social_user
23. raise AuthAlreadyAssociated(backend, msg)

Exception Type: AuthAlreadyAssociated at /oauth/complete/twitter/
Exception Value: This account is already in use.

python3-psycopg2 dependency: pip or package?

I run the bot on Debian Stretch. I got a warning following the introduction of the last pieces of code that depend on sqlalchemy:

/home/xxx/.local/lib/python3.5/site-packages/psycopg2/init.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
""")

Question:

Should I use

  • Debian package python3-psycopg2
  • pip3 install psycopg2
  • pip3 install psycopg2-binary

I guess this psycopg2 dependency comes from the use of JSONB type in model/model.py:
from sqlalchemy.dialects.postgresql import JSONB

Any idea @natolh?

users.utils.follower_level and rate limit

function users.utils.follower_level is used to determine the API access on the home page
how do we deal with rate limit?
now in the event of a rate limit, the gunicorn thread is paused and times out... :(
we need to used cached value of update_social_ids and update asynchronously in a celery task

update twitter username before sending moderation

users are added to database some time before we create a moderation
their username can change
then the moderation DM contains the old @, which cannot be clicked
moderation is not possible

fix: update profile systematically before each moderation request

question detection

Look for question mark in the whole thread, not only in the first tweet.

follow a thread

web app: "follow thread" option to be notified of answers

switch to latest pip version

in Docker image pip is pinned to RUN pip install pip==21.0.1
because of an old bug with packges compatibility

we should try to use the lastest version of pip

Implement a user database

Implementing a user database to store bot's contributors will allow :

  • Exceed the 5.000 members limit of Twitter lists (Twitter lists are used to keep track of contributors).
  • Allow to store more information about each user locally (currently the retweet script access only the contributors Twitter ID via a text file).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.