English | 简体中文
A QQ group membership plugin for Alliance Auth. Members bind their QQ number on AA's Services page. A QQ bot (Koishi, a separate project) asks AA's API who may join and stay in each group.
This is a complete rewrite of QQMonitor. No code is shared with it and its bindings are not imported, so everyone binds again.
- Members already in a group: enter your QQ number, no code needed (during the first 30 days after the group is added; configurable)
- New members: get a one-time code and put it in the QQ join request
- QQ managers handle groups, bindings and conflicts on the "QQ Admin" page in the sidebar
- Alliance Auth 5.2, 5.3, 5.4 or 5.5 (each is tested)
- Python 3.10+
Run everything inside AA's virtual environment, in the myauth directory.
- Install the plugin:
pip install git+https://github.com/yilifaer/aa-qqbot-plugin.git@v1.0.1- Generate a secret for the bot. Keep the output; you need it in the next step and for the bot:
python -c "import secrets; print(secrets.token_urlsafe(48))"- Add this to the end of
local.py, and replaceyour-secretwith the secret from step 2:
from celery.schedules import crontab
INSTALLED_APPS += ["qqbot"]
APPS_WITH_PUBLIC_VIEWS += ["qqbot"] # required by the bot API; append, do not overwrite
QQBOT_API_KEYS = {
"koishi-1": "your-secret",
}
CELERYBEAT_SCHEDULE["qqbot_reconcile"] = {
"task": "qqbot.tasks.reconcile",
"schedule": crontab(minute="17", hour="4"),
}- Check the configuration, then migrate:
python manage.py check
python manage.py migrateThe configuration is fine when check prints no messages starting with qqbot..
- Restart AA:
sudo supervisorctl restart myauth:- In the Django admin, give the two permissions. The picker box is narrow, so search for each one separately:
- Search
QQ binding: memberand add it to the Member state (codenameqqbot.basic_access). - Create a group for your QQ managers (e.g. "QQ Managers"), search
QQ binding: managerand add it to that group (codenameqqbot.manage), then add the manager accounts to the group under Users.
- Search
After step 6, members see a card titled "QQ binding" on the Services page. QQ managers get a "QQ Admin" entry in the sidebar, where they add the QQ groups to manage.
pip install --upgrade --force-reinstall --no-deps git+https://github.com/yilifaer/aa-qqbot-plugin.git@v1.0.1
python manage.py migrateThen restart AA. For a newer release, replace v1.0.1 with its tag; CHANGELOG.md lists the versions.
Stop AA, then run (this deletes all bindings and the audit log):
python manage.py migrate qqbot zero
python manage.py shell -c "from django_celery_beat.models import PeriodicTask; PeriodicTask.objects.filter(name='qqbot_reconcile').delete()"Remove the lines you added to local.py, then run this. It deletes only this plugin's 9 content types and 2 permissions:
pip uninstall -y aa-qqbot
python manage.py shell -c "from django.contrib.contenttypes.models import ContentType; print(ContentType.objects.filter(app_label='qqbot').delete())"Do not use python manage.py remove_stale_contenttypes --include-stale-apps instead: it also deletes the permissions left behind by every other plugin ever uninstalled from this AA.
Start AA.
- Bot integration: API.md; read KOISHI_START.md before writing the Koishi plugin (both in Chinese). The bot needs the API URL (
https://your-aa-site/qqbot/api/v1/), the key id and the secret. - Step-by-step guide and troubleshooting (Chinese): docs/GUIDE.md
- If this site ran 0.x of this plugin: before step 3, remove the old
"qqbot",QQBOT_GROUP_CHATandQQBOT_PING_GROUPfromlocal.py. Old bindings are not imported; everyone binds again. NameError: name 'APPS_WITH_PUBLIC_VIEWS' is not defined: yourlocal.pyis older than the AA 5 template. Add this line above the block from step 3:APPS_WITH_PUBLIC_VIEWS = []
- On AA 5.2/5.3, if every page fails with an error mentioning
sri_static, run this and restart:pip install "django-sri<1" - On AA 5.2–5.4, if AA stops starting with
ModuleNotFoundError: No module named 'httpx'(pip upgradeddjango-esito 10.x, which only AA 5.5 supports), run this and restart, or upgrade AA to 5.5:pip install "django-esi<10" - Superusers do not get group access automatically; their card then says so. Test with a normal member account.
- Language: the QQ binding card and the QQ Admin pages are in Chinese for users whose AA language is Chinese, and in English for everyone else. Members who never picked a language get their browser's language; anyone can pick a language in AA's language menu (AA remembers it). The default group rules text is in Chinese; edit it under QQ Admin → Settings.
MIT
