async def send_photo(event: vq.Event()): """ Handler to command `send_photo` """ path = pathlib.Path() / "tests" / "test_bot" / "assets" / "example.png" with open(path, "rb") as file: photo_bytes = file.read() photos = await vq.Photo.message( path, photo_bytes, pathlib.Path() / "tests" / "test_bot" / "assets" / "example2.jpg", pathlib.Path() / "tests" / "test_bot" / "assets" / "example2.jpg", pathlib.Path() / "tests" / "test_bot" / "assets" / "example2.jpg", path, await vq.Photo.download( "https://www.prikol.ru/wp-content/gallery/october-2019/prikol-25102019-001.jpg" ), pathlib.Path() / "tests" / "test_bot" / "assets" / "example2.jpg", pathlib.Path() / "tests" / "test_bot" / "assets" / "example2.jpg", pathlib.Path() / "tests" / "test_bot" / "assets" / "example2.jpg", peer_id=event.object.message.peer_id )() cache("send_photo") return vq.Message(attachment=photos)
async def annorep(rep: vq.RepliedUser("verificate")): """ Get rep user """ user = await vq.User(user_id=rep.id).get_info("verificate") assert user.info == rep.info cache("annorep") return config.ANSWER
async def annofwd(fwds: vq.FwdUsers("verificate")): """ Get fwd users """ user = await vq.User(user_id=fwds[0].id).get_info("verificate") assert user.info == fwds[0].info cache("annofwd") return config.ANSWER
def com_prefs(): """ Check working name and prefs in mix """ global TIMES TIMES *= 2 if TIMES == 1.0: cache("com_prefs") return config.ANSWER
async def usertool(api: vq.API): """ Handler to command `usertool` """ cache("usertool") user = await api.users.get(user_ids="1") user = user[0] vq_user = await vq.User(user_id=1).get_info() assert user == vq_user.info assert f"[id{user['id']}|{user['first_name']} {user['last_name']}]" == ( vq_user.mention("<fn> <ln>")) assert f"{user['first_name']} {user['last_name']}" == ( f"{vq_user:<info.first_name> <info.last_name>}") return config.ANSWER
def cmd_types(num: int, num_vq: vq.Integer(), word: vq.Word(), lit: vq.Literal("foo", "bar"), mention: vq.UserMention(), mentions: [vq.UserMention()], string: str, sender: vq.Sender()): """ Check types working """ assert num == 123 assert num_vq == 456 assert lit == "foo" assert isinstance(mention, vq.User) assert isinstance(mentions, list) assert string == "long string" assert isinstance(sender, vq.User) cache("cmd_types") return config.ANSWER
async def annotypes1(sender: vq.Sender("verificate"), event_brackets: vq.Event(), event: vq.Event, api: vq.API, client_info_brackets: vq.ClientInfo(), client_info: vq.ClientInfo): """ Annotypes """ assert client_info_brackets == client_info and isinstance( client_info, attrdict.AttrMap) assert api is vq.current.api assert event_brackets == event and isinstance(event, attrdict.AttrMap) user = await vq.User(user_id=sender.id).get_info("verificate") assert user.info == sender.info cache("annotypes1") return config.ANSWER
def cmd_insensetive(): """ Test insensetive """ cache("cmd_insensetive") return config.ANSWER
def custom_signal(some_arg=False): """ Handler to signal `custom_signal` """ if some_arg: cache("custom_signal")
def join_chat(): """ Handler to command `leave_chat` """ cache("join_chat") return config.ANSWER