예제 #1
0
 def _generate_keyboard(self, peer_id, chat_flg=False) -> str:
     admin_flg = peer_id in self._admins
     keyboard = Keyboard(one_time=not admin_flg and chat_flg)
     if not self._timetable_work_flg and admin_flg:
         keyboard.row()
         keyboard.add(Text("Включить уведомления."),
                      color=KeyboardButtonColor.POSITIVE)
     keyboard.row()
     keyboard.add(Text("Расписание на сегодня."),
                  color=KeyboardButtonColor.POSITIVE)
     keyboard.row()
     keyboard.add(Text("Да или нет?"), color=KeyboardButtonColor.PRIMARY)
     keyboard.row()
     keyboard.add(Text("Поддержать."))
     return keyboard.get_json()
예제 #2
0
from vkbottle import Keyboard, Text, KeyboardButtonColor

# Simplest way of generating keyboard is non-builder interface
# Use <.raw()> to add raw
# Use <.add(Action(...), COLOR)> to add button to the last raw
# Use <.get_json()> to make keyboard sendable
KEYBOARD_STANDARD = Keyboard(one_time=True, inline=False)
KEYBOARD_STANDARD.add(Text("Button 1"), color=KeyboardButtonColor.POSITIVE)
KEYBOARD_STANDARD.add(Text("Button 2"))
KEYBOARD_STANDARD.row()
KEYBOARD_STANDARD.add(Text("Button 3"))
KEYBOARD_STANDARD = KEYBOARD_STANDARD.get_json()

# add and row methods returns the instance of Keyboard
# so you can use it as builder
KEYBOARD_WITH_BUILDER = (
    Keyboard(one_time=True, inline=False)
    .add(Text("Button 1"), color=KeyboardButtonColor.POSITIVE)
    .add(Text("Button 2"))
    .row()
    .add(Text("Button 3"))
    .get_json()
)

# Schema is another way to create keyboard
# all fields except of color are read as action fields
KEYBOARD_WITH_SCHEMA = (
    Keyboard(one_time=True, inline=False)
    .schema(
        [
            [
예제 #3
0
from vkbottle import Keyboard, KeyboardButtonColor, Text

# Simplest way of generating keyboard is non-builder interface
# Use <.row()> to add row
# Use <.add(Action(...), COLOR)> to add button to the last row
# Use <.get_json()> to make keyboard sendable
KEYBOARD_STANDARD = Keyboard(one_time=True, inline=False)
KEYBOARD_STANDARD.add(Text("Button 1"), color=KeyboardButtonColor.POSITIVE)
KEYBOARD_STANDARD.add(Text("Button 2"))
KEYBOARD_STANDARD.row()
KEYBOARD_STANDARD.add(Text("Button 3"))
KEYBOARD_STANDARD = KEYBOARD_STANDARD.get_json()  # type: ignore

# add and row methods returns the instance of Keyboard
# so, you can use it as builder
KEYBOARD_WITH_BUILDER = (Keyboard(one_time=True, inline=False).add(
    Text("Button 1"), color=KeyboardButtonColor.POSITIVE).add(
        Text("Button 2")).row().add(Text("Button 3")).get_json())

# Schema is another way to create keyboard
# all fields except of color are read as action fields
KEYBOARD_WITH_SCHEMA = (Keyboard(one_time=True, inline=False).schema([
    [
        {
            "label": "Button 1",
            "type": "text",
            "color": "positive"
        },
        {
            "label": "Button 2",
            "type": "text"