from kutana import Plugin, VKController import random, asyncio, aiohttp, json plugin = Plugin(name="randompost") plugin.category = 'Картинки' plugin.category_desc = 'Присылает в чат случайные картинки определенной тематики' plugin.desc = {"мемы": [0, 0], 'няша': [0, 0], 'цензура': [0, 0]} commgroups = { "мемы": "-45745333", "няша": "-118445684", "цензура": "-137905638" } plugin.limit = {'посоветуй аниме': 8, 'мемы': 5, 'няша': 5, 'цензура': 5} async def get_posts(group_id, count, offset): async with VKController( 'f68c8bdf80628aff5e02739338f8c8fd948b6c05dd7b89f731739819c30137e5508ca323f34789c01d155' ) as group: result = await group.raw_request('wall.get', count=count, offset=offset, owner_id=group_id) return result.response @plugin.on_text(*commgroups) async def on_post(message, attachments, env): group_id = commgroups[message.text.lower()] smiles = ['😔', '😭', '😩', '😠', '😟', '🙁'] vk_message, attachments = "", ""
import time import random import lxml.html from lxml import html import aiohttp from kutana import Plugin plugin = Plugin(name="Astrology") plugin.category = 'Инфо и прочее' plugin.desc = { 'гороскоп': [ '{знак зодиака}', 'гороскоп на текущий день для *знак зодиака*, указывая баллы (богатство, здоровье, бизнес)' ] } @plugin.on_startswith_text("гороскоп") async def on_message(message, attachments, env): def digits_recursive(nonneg): digits = [] while nonneg: digits += [nonneg % 10] nonneg //= 10 return digits[::-1] or [0] def num_to_smile(num): if num <= 10: numbers = { 0: '0⃣', 1: '1⃣',
from kutana import Plugin import peewee_async, peewee, datetime, time, asyncio from kutana.database import * import traceback from kutana.vksm import * plugin = Plugin(category="Статистика") plugin.desc = {'юзер стат': ['(имя)', 'считaет вcю cтaтистику пользователя - количествo соoбщeний, символов, матов и его рейтинг в топе'], 'стата чата': [0, 'аналогично команде юзер стат, только для чата'], 'топ бесед': [0, 'пoказывaет топ бeсeд (по cообщениям), в которых пpисутствует бoт'], 'актив': [0, 'пoказываeт ктo и кoгдa поcлeдний pаз что-тo пиcaл в чатe']} plugin.category_desc = 'Считaeт всю статистику бeceды - кoличеcтво cоoбщений, символов, cтикeров, прикреплeний, голocoвыx cooбщeний, иcпoльзованных кoманд - кaк для пoльзoвaтеля, тaк и для всeгo чата, и пoкaзывает эту информацию' class chat_stats_vlad(BaseModel): chat_id = peewee.IntegerField(default=0) messages = peewee.BigIntegerField(default=0) clear_messages = peewee.BigIntegerField(default=0) clear_symbols = peewee.BigIntegerField(default=0) symbols = peewee.BigIntegerField(default=0) voice_messages = peewee.BigIntegerField(default=0) resend_messages = peewee.BigIntegerField(default=0) photos = peewee.BigIntegerField(default=0) videos = peewee.BigIntegerField(default=0) audios = peewee.BigIntegerField(default=0) docs = peewee.BigIntegerField(default=0) posts = peewee.BigIntegerField(default=0) stickers = peewee.BigIntegerField(default=0) mentios = peewee.BigIntegerField(default=0) links = peewee.BigIntegerField(default=0) leaved = peewee.BigIntegerField(default=0) messages_with_sw = peewee.BigIntegerField(default=0) last_user_id = peewee.IntegerField(default=0)
from kutana import Plugin from geopy.geocoders import Photon, Yandex, Nominatim import aiohttp, json, time, datetime plugin = Plugin(name="Weather Plugin") plugin.category = 'Инфо и прочее' plugin.limit = {'погода': 6} plugin.desc = {'погода': ['{город}', 'прогноз погоды для *город*']} @plugin.on_startup() async def on_startup(kutana, update): plugin.dict = {} plugin.dict['token'] = '4e72572d631723e8854c3cd2e692937b' plugin.dict['geocoders'] = [] plugin.dict['coords_cache'] = {} plugin.dict['weather_cache'] = {} plugin.dict['weather_clear'] = time.time() + 12 * 60 * 60 plugin.dict['api_lim'] = 95 plugin.dict['api_lim_clear'] = time.time() + 24 * 60 * 60 plugin.dict['api_lim_count'] = 0 for coder in [Photon, Yandex, Nominatim]: plugin.dict['geocoders'].append(coder()) async def get_weather(result): if plugin.dict['weather_clear'] - time.time() <= 0: plugin.dict['weather_clear'] = time.time() + 12 * 60 * 60 plugin.dict['weather_cache'].clear() if f"{result.latitude}_{result.longitude}" in plugin.dict['weather_cache']: return plugin.dict['weather_cache'][
import time import random import lxml.html from lxml import html import aiohttp from kutana import Plugin plugin = Plugin(name="Holidays") plugin.category = 'Инфо и прочее' plugin.desc = {'праздники': [0, 'праздники сегодня']} plugin.limit = {'праздники': 6} @plugin.on_text('праздники') async def wiki_search(message, attachments, env): endpoint = f'http://kakoysegodnyaprazdnik.ru' async with aiohttp.ClientSession() as sess: async with sess.post(endpoint, data=None) as resp: response = await resp.text() tree = html.fromstring(response) holidays = tree.xpath('//span[@itemprop="text"]/text()') numbers = tree.xpath('//span[@class="super"]/text()') vk_message = 'праздники сегодня:\n' for num, i in enumerate(holidays[:5], start=0): vk_message += '• {} ({})\n'.format(i, numbers[num]) return await env.reply(vk_message)