mewhrzad / marzpy

A Python library that helps you easily use Marzban's API panel
MIT License
98 stars 27 forks source link

error create user #13

Closed LixCp closed 7 months ago

LixCp commented 7 months ago

panel = Marzban('user'pass'.', 'https://....') mytoken = await panel.get_token() print(mytoken) try: new_user = User( username="Mewhrzad", proxies={ "vmess": {"id": "35e7e39c-7d5c-1f4b-8b71-508e4f37ff53"}, }, inbounds={"vmess": ["VMess TCP"]}, expire=0, data_limit=0, data_limit_reset_strategy="no_reset", ) result = await panel.add_user(user=new_user, token=mytoken) # return new User object print(result.username) except Exception as ex: print(ex)

return : module aiohttp has no attribute exceptions

mewhrzad commented 7 months ago

try to update marzpy to 0.0.5 (pip install marzpy --upgrade)

from marzpy.api.user import User
from marzpy import Marzban
import asyncio

async def main():
    panel = Marzban("username","password","https://example.com")
    token = await panel.get_token()
    new_user = User(
        username="Mewhrzad",
        proxies={
            "vmess": {"id": "35e7e39c-7d5c-1f4b-8b71-508e4f37ff53"},
        },
        inbounds={"vmess": ["VMess TCP"]},
        expire=0,
        data_limit=0,
        data_limit_reset_strategy="no_reset",
        status="active"
    )
    result = await panel.add_user(user=new_user, token=token)
    print(result)

asyncio.run(main())