cromachina / fanbox-bot Goto Github PK
View Code? Open in Web Editor NEWA bot that I use to automate access control for my Fanbox Discord server
License: MIT License
A bot that I use to automate access control for my Fanbox Discord server
License: MIT License
Bot will be broken until I figure this out.
so got the bot working that's all fine and good however in testing we found that anyone can use the pixiv profile of anyone else in the server to gain a role, even if the actual owner already has a role. as the bot makes a database it's probably an easy fix to only allow one role per user id but I don't actually know, not good at programming.
Thank you for your patience, sorry for commenting on unrealated commit because I'm a github noob. I let my yml look like this:
plan_roles:
'348830': 1116399299308294246
allow_fallback: False
fallback_role: 1116399299308294246
But I still have the same error like before, the bot regconized the subcriber but it have some issue with the role.
discord.errors.NotFound: 404 Not Found (error code: 10011): Unknown Role
[2023-06-08 23:31:55,100][INFO] User: Pipisvoir#9893; Message: "!8591772"; Response: system_error
Hello @cromachina, thank you so much for creating this code!, I tried your code and of course I already modifying it to make sure I follow the instruction what it's needed to be modify but I dunno if this already work or not, I'm new to a programming stuff but it seems there's no slot for Discord Server ID, and how to make the BOT online ? is it using uptimerobot to make it online ? I hope I can get a reply soon, Thank you
I know you're already aware of this but after some researching this seems to have been picked up on by others using cookies to verify Fanbox/Pixiv accounts, potential fix here
Nandaka/PixivUtil2#1345
I must admit that I had to take a few moments to understand how the script works with subscriptions because I use it with my Discord server. After a few months of use, I understood that the script grants a full month's subscription to the user starting from the last transaction date + the days configured in the leeway_days
variable in order to make everything reasonable and fair for all users.
The problem is that Fanbox doesn't work this way, and doesn't consider the full month from the last transaction date. If a user pledges at the end of the month, he'll be charged at the beginning of the following month.
In reality, a subscription is only valid if there is a transaction during the current month or a few days at the beginning of the following month (while the Fanbox automatic system renews the user's subscription).
Is it possible to offer this option in this script? I've tried to modify the script so that it follows this logic, but I still have bugs.
I know that theoretically I should give the full month to a user who subscribes to my page, but unfortunately if a subscriber decides not to renew his subscription, he's got what he wanted. There's no need to offer them more time.
Source: https://fanbox.pixiv.help/hc/en-us/articles/360000664842-When-are-pledges-charged
running python3 main.py is giving this error, it deletes itself from the terminal and then pops back up over and over in a loop, from what I understand this means that the roleid should just be numbers but it is, it's
'FanboxPlanId': RoleId
formatted exactly like that spaces and all using the exact same format as the placeholder in the config file
First of all, thank you cromachina for this repo, it works great.
Some users don't seem to understand how this whole verification process works and end up messaging me anyway or just message the bot wrongly, and since you are adding Admin commands it would be cool if there was a command to add a user manually, something like !add-user <PIXIV_ID> <DISCORD_ID> (just an idea of course).
Hi,
I'd normally write this as a PR but I'm not really sure where you'll want to add this into your README and I also have a possible bug, but it might be my own error somewhere...
I experienced the issues this morning with an older version of the bot not verifying users anymore and updated everything, stepped through your instructions etc and was still getting denied and was wondering to myself why this was - then it dawned on me, I wasn't using a Linux distro but was using windows at the time.
The useragent for my browser had to then be updated as I was just using WSL to SSH in to my digitalocean droplet as per your instructions with the Network Config for Firefox and left it default as per the template (note the comment about not messing with it unless you know what you're doing) until I realized, this also had to change to properly authenticate.
I changed the line to as follows for my own case and everything began to authenticate properly. For how long, who knows - but it worked after an hour or two of not getting anywhere with it getting the bot back online - I've also confirmed a few authentications with this to ensure the bot is working, though it seems to be failing on role assignment and incorrectly responding to some commands... (see further down)
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0
I'd imagine if you're on a strange Linux distro or Mac or a SteamDeck (for whatever god forsaken reason you'd do this) you'll also need to change the above header - or, even if you just use a different browser... anyway... I'll let you figure out how to write it in the README as it tripped my up until I thought about it for a little bit...
Additionally, this is now also appearing in the log in the latest version - my droplet is quite dated, but, I doubt it's anything to do with that and more something to do with a change in the bot itself or Fanbox, here's the error frequenting the log as the bot started:
[2024-07-01 16:30:29,307][ERROR] 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "/root/fanbox-bot/main.py", line 377, in update_role_check_all_members_by_txn
await update_role_check_by_txn(member)
File "/root/fanbox-bot/main.py", line 367, in update_role_check_by_txn
role = role_from_supporting_plan(user_data)
File "/root/fanbox-bot/main.py", line 314, in role_from_supporting_plan
plan = user_data['supportingPlan']
TypeError: 'NoneType' object is not subscriptable
The bot is no longer assigning the roles it seems... but it keeping the record of the role in it's database. I suppose I have to look into this error or see what's going on with the bot? Unless this is a change in the API and the main script has to be updated also? From reading the error it seems to be a change in the data's structure or contents that is returned that's causing issues?
Here's an extract from my config.yml, I only use the one role on my server but have several plans so they all point to the same role. To me, all seems OK.
# Add plans IDs and their associated role IDs here.
# The plan ID number on the left hand side must be a string, like '12345', and not 12345
# To get your plan ID, go to https://www.fanbox.cc/manage/plans, then click edit on the plan.
# The plan ID will be in the address bar. Replace '12345' with your own plan ID.
# <ROLE_ID> must be a number, same as above.
# To get the role ID, turn on developer mode in Discord, go to your server settings, then Roles,
# then right click on the role and select "Copy Role ID"
plan_roles:
'290141': 1043542296932651078
'290142': 1043542296932651078
'290159': 1043542296932651078
'290333': 1043542296932651078
'290334': 1043542296932651078
'290336': 1043542296932651078
I should also note that when I'm running the following command, the bot just responds with "access granted" even though... it's... uh, not supposed to? lol
command ran:
!unbind-user-by-pixiv-id #number-of-the-user-here.
bot response:
Access granted. Please check the server for new channels!
So I'm guessing there's some issues right now with this...
Thanks for your work on this bot - it's a game changer.
Edit: Role assignment seems to be working, I've had a few users authenticate fine and I think had their role appended correctly... that error still flood's the log on boot though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.