Esempio n. 1
0
kbs = Keyboard()
kbs.add_text_button(text='На завтра', color=ButtonColor.PRIMARY)
kbs.add_text_button(text='Назад', color=ButtonColor.PRIMARY)

kbm = Keyboard()
kbm.add_text_button(text="Заметки", color=ButtonColor.PRIMARY)
kbm.add_text_button(text="Напоминания", color=ButtonColor.PRIMARY)
kbm.add_text_button(text="Сводка", color=ButtonColor.PRIMARY)

keephelp = 'Напишите заметку. Чтобы удалить заметку напишите\n "/номера через запятую"'
alarmhelp = 'Напишите напоминание. Чтобы удалить напоминание напишите\n "/номера через запятую"'
alhelplist = {}


@bot.message_handler(bot.text_contains_filter('/'))
async def delete(event: bot.SimpleBotEvent):
    user_id = event.object.object.message.peer_id
    status = db.load(db, user_id, 'status')
    if status[0][1] == 'keeps' or status[0][1] == 'alarms':
        text = event.object.object.message.text
        counter = ['']
        for u in text:
            if u.isdigit():
                counter[len(counter) - 1] += u
            else:
                counter.append('')
        l = db.load(db, user_id, status[0][1])
    for u in counter:
        if u.isdigit():
            try:
Esempio n. 2
0
from vkwave.bots import SimpleLongPollBot


bot = SimpleLongPollBot(tokens="1234", group_id=456)


@bot.message_handler(bot.conversation_type_filter(from_what="from_chat"))
async def handle(event: bot.SimpleBotEvent):
    await event.answer(f"hello to chat!")


@bot.message_handler(bot.fwd_filter(fwd_count=3))  # bot.fwd_filter() for any count
async def handle(event: bot.SimpleBotEvent):
    await event.answer("3 fwd...")


@bot.message_handler(bot.args_filter(args_count=2))
async def handle(event: bot.SimpleBotEvent):
    args = event["args"]
    await event.answer(f"Your args - {args}")


@bot.message_handler(bot.text_contains_filter("wow"))
async def handle(event: bot.SimpleBotEvent):
    await event.answer(f"Your text contains 'wow', wow!")

bot.run_forever()
Esempio n. 3
0
async def probability(event: SimpleBotEvent) -> str:
    message_text = event.object.object.message.text
    if "насколько" in message_text.lower():
        res = message_text.lower().split("насколько", 2)
    elif "на сколько" in message_text.lower():
        res = message_text.lower().split("на сколько", 2)
    if len(res) > 1:
        prob = random.randint(0, 101)
        if " я " in res[1]:
            res[1] = res[1].replace(" я ", " ты ")
        elif " ты " in res[1]:
            res[1] = res[1].replace(" ты ", " я ")
        return "Я думаю, что" + res[1] + " на " + str(prob) + "%"


@bot.message_handler(bot.text_contains_filter("или"), bot.text_startswith_filter("бот"))
async def choice(event: SimpleBotEvent) -> str:
    message_text = event.object.object.message.text
    res = message_text.lower().split("бот ")[1].split(" или ")
    for x in res:
        if " я " in x:
            x = x.replace(" я ", " ты ")
        elif x.startswith("я"):
            x = x.replace("я", "ты", 1)
        elif " ты " in x:
            x = x.replace(" ты ", " я ")
        elif x.startswith("ты"):
            x = x.replace("ты", "я", 1)
    prefixes = ["Определённо", "Ну я думаю", "Наверное", "Ну тут по любому"]
    return random.choice(prefixes) + " " + random.choice(res)