Разработано приложение
This commit is contained in:
1
app/__init__.py
Normal file
1
app/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .main import set_online
|
41
app/main.py
Normal file
41
app/main.py
Normal file
@ -0,0 +1,41 @@
|
||||
import json
|
||||
import logging
|
||||
import traceback
|
||||
from urllib.parse import ParseResult, urlparse, urlencode
|
||||
|
||||
import aiohttp
|
||||
|
||||
import config
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.ERROR,
|
||||
)
|
||||
logger = logging.getLogger()
|
||||
|
||||
set_online_url = urlparse('https://api.vk.com/method/account.setOnline')
|
||||
|
||||
|
||||
async def set_online():
|
||||
try:
|
||||
query = {
|
||||
'access_token': config.VK.access_token,
|
||||
'voip': '0',
|
||||
'v': '5.154',
|
||||
}
|
||||
url = ParseResult(
|
||||
scheme=set_online_url.scheme,
|
||||
netloc=set_online_url.hostname,
|
||||
path=set_online_url.path,
|
||||
params=set_online_url.params,
|
||||
query=urlencode(query),
|
||||
fragment=set_online_url.fragment,
|
||||
)
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url.geturl()) as response:
|
||||
assert response.status == 200
|
||||
assert json.loads(await response.read()).get('response') == 1
|
||||
except AssertionError:
|
||||
logger.error(traceback.format_exc())
|
||||
except Exception:
|
||||
logger.critical(traceback.format_exc())
|
Reference in New Issue
Block a user