async def get_random(self): anek = await aioget(self.url) text = anek.text[135:-523] fixed_anek = ast.literal_eval(f"'{text}'") anek_parsed = "\n\n--------------\n\n".join(json.loads(fixed_anek)) return anek_parsed.replace("<br>", "")
async def _get(self, params): self.params = {"format": "json", "action": "query"} self.params = {**self.params, **params} async with aiohttp.ClientSession() as session: async with session.get(self.url, params=self.params) as response: if not response.status == 200: return 404 return json.loads(await response.text())
def iq_callback(query): data = query.data if data.startswith('get-'): get_ex_callback(query) else: try: if json.loads(data)['t'] == 'u': edit_message_callback(query) except ValueError: pass
def edit_message_callback(query): data = json.loads(query.data)['e'] exchange_now = pb.get_exchange(data['c']) text = serialize_ex( exchange_now, get_exchange_diff(get_ex_from_iq_data(data), exchange_now)) + '\n' + get_edited_signature() if query.message: bot.edit_message_text(text, query.message.chat.id, query.message.message_id, reply_markup=get_update_keyboard(exchange_now), parse_mode='HTML') elif query.inline_message_id: bot.edit_message_text(text, inline_message_id=query.inline_message_id, reply_markup=get_update_keyboard(exchange_now), parse_mode='HTML')
async def navalny(message): res = await aioget("https://free.navalny.com/api/v1/maps/counters/") text = await res.text() await message.reply(json.loads(text)["persons"])