tr{{tutorialPage.title}}

tr{{tutorialPage.settingEnv}}

tr{{tutorialPage.pythonSupport}}

tr{{tutorialPage.install}}

pip install --upgrade mailru-im-bot

tr{{tutorialPage.or}}

git clone https://github.com/mail-ru-im/bot-python.git
cd bot-python
python setup.py install

tr{{tutorialPage.register}}

tr{{tutorialPage.registerFirstStep}}

1.png

tr{{tutorialPage.libraryUse}}

tr{{tutorialPage.libraryExample}}

from bot.bot import Bot
from bot.handler import MessageHandler

TOKEN = "" #your token here

bot = Bot(token=TOKEN)

def message_cb(bot, event):
    bot.send_text(chat_id=event.from_chat, text=event.text)

bot.dispatcher.add_handler(MessageHandler(callback=message_cb))
bot.start_polling()
bot.idle()

tr{{tutorialPage.library1}}

from bot.bot import Bot

tr{{tutorialPage.library2}}

from bot.handler import MessageHandler

tr{{tutorialPage.library3}} @metabot

TOKEN = ""
bot = Bot(token=TOKEN)

tr{{tutorialPage.library4}}

def message_cb(bot, event):
    bot.send_text(chat_id=event.from_chat, text=event.text)

tr{{tutorialPage.library5}}

bot.dispatcher.add_handler(MessageHandler(callback=message_cb))

tr{{tutorialPage.library6}}


tr{{tutorialPage.library7}}

bot.start_polling()

tr{{tutorialPage.library8}}

bot.idle()

tr{{tutorialPage.chat}}

tr{{tutorialPage.chat1}} @metabot, tr{{tutorialPage.chat2}} /setjoingroups , tr{{tutorialPage.chat3}} enable . tr{{tutorialPage.chat4}} 2.png tr{{tutorialPage.chat5}}


tr{{tutorialPage.chat6}}
print(event) #Event(type='EventType.NEW_MESSAGE', data='{'chat': {'chatId': '682502386@chat.agent', ...
tr{{tutorialPage.chat7}}

tr{{tutorialPage.chat8}}
some_nick = '' #nick, stamp or chat_id
bot.send_text(chat_id=some_nick, text="Hello, I'm a very fledged bot!")

tr{{tutorialPage.chat9}}


tr{{tutorialPage.chat10}} https://teams.vk.com/test_chat, tr{{tutorialPage.chat11}} - test_chat


Stamp - tr{{tutorialPage.chat12}} https://teams.vk.com/AoLFuNFynm67V2xGFX0. tr{{tutorialPage.chat13}} AoLFuNFynm67V2xGFX0


Chat_id - tr{{tutorialPage.chat14}}


tr{{tutorialPage.chat15}}

import schedule
import time
from bot.bot import Bot

TOKEN = "" #your token here
bot = Bot(token=TOKEN)

chats_to_send_notifications = [
"chat_to_recieve_messages", #nick of a public group chat
"AoLFuNFynm67V2xGFX0", #stamp of private group chat
"some_user_nickname", #nick of a person
"682502386@chat.agent" # default chat id
]
text_to_send = "Let's go home!"

def send_alert():
    for chat in chats_to_send_notifications:
        bot.send_text(chat_id=chat, text=text_to_send)

schedule.every().day.at("19:00").do(send_alert)
while True:
    schedule.run_pending()
    time.sleep(1)

tr{{tutorialPage.chat16}}

import schedule
import time
from bot.bot import Bot

tr{{tutorialPage.chat17}}:

TOKEN = "" #your token here
bot = Bot(token=TOKEN)

tr{{tutorialPage.chat18}}:

chats_to_send_notifications = [
"chat_to_recieve_messages", #nick of a public group chat
"AoLFuNFynm67V2xGFX0", #stamp of private group chat
"some_user_nickname", #nick of a person
"682502386@chat.agent" # default chat id
]
text_to_send = "Let's go home!"

tr{{tutorialPage.chat19}}:

def send_alert():
    for chat in chats_to_send_notifications:
        bot.send_text(chat_id=chat, text=text_to_send)

tr{{tutorialPage.chat20}}:

schedule.every().day.at("19:00").do(send_alert)
while True:
    schedule.run_pending()
    time.sleep(1)

tr{{tutorialPage.buttons}}

tr{{tutorialPage.buttons1}} github.com/shvedoff/Icq_buttons


tr{{tutorialPage.buttons2}}: 5.png tr{{tutorialPage.buttons3}} inline_keyboard_markup:

bot.send_text(chat_id=OWNER,
              bot.send_text(chat_id=event.from_chat,
                  text="Hello with buttons.",
                  inline_keyboard_markup="{}".format(json.dumps([[
                      {"text": "Action 1", "url": "https://teams.vk.com"},
                      {"text": "Action 2", "callbackData": "call_back_id_2", "style": "attention"},
                      {"text": "Action 3", "callbackData": "call_back_id_2", "style": "primary"}
                  ]])))

tr{{tutorialPage.buttons4}}


tr{{tutorialPage.buttons5}}.
tr{{tutorialPage.buttons15}} text - tr{{tutorialPage.buttons6}}.
callbackData - tr{{tutorialPage.buttons7}}.
url - tr{{tutorialPage.buttons8}}.
style - tr{{tutorialPage.buttons9}}
tr{{tutorialPage.buttons10}}:
bot.dispatcher.add_handler(BotButtonCommandHandler(callback=buttons_answer_cb))
tr{{tutorialPage.buttons11}} buttons_answer_cb:
def buttons_answer_cb(bot, event):
    if event.data['callbackData'] == "call_back_id_1":
        bot.answer_callback_query(
            query_id=event.data['queryId'],
            text="Hey! It's a working button 2.",
            show_alert=True
        )

    elif event.data['callbackData'] == "call_back_id_2":
        bot.answer_callback_query(
            query_id=event.data['queryId'],
            text="Hey! It's a working button 3.",
            show_alert=False
        )
tr{{tutorialPage.buttons12}} callbackData tr{{tutorialPage.buttons13}} answer_callback_query, tr{{tutorialPage.buttons14}}:
tr{{tutorialPage.buttons15}} text – tr{{tutorialPage.buttons16}}
showAlert – tr{{tutorialPage.buttons17}} true tr{{tutorialPage.buttons18}}
url – tr{{tutorialPage.buttons19}}
tr{{tutorialPage.buttons20,answer_callback_query}}

tr{{tutorialPage.buttons21}}
import json
from bot.bot import Bot
from bot.handler import MessageHandler, BotButtonCommandHandler


TOKEN = "" #your token here

bot = Bot(token=TOKEN)

def buttons_answer_cb(bot, event):
    if event.data['callbackData'] == "call_back_id_2":
        bot.answer_callback_query(
            query_id=event.data['queryId'],
            text="Hey! It's a working button 2.",
            show_alert=True
        )

    elif event.data['callbackData'] == "call_back_id_3":
        bot.answer_callback_query(
            query_id=event.data['queryId'],
            text="Hey! It's a working button 3.",
            show_alert=False
        )

def message_cb(bot, event):
    bot.send_text(chat_id=event.from_chat,
                  text="Hello with buttons.",
                  inline_keyboard_markup="{}".format(json.dumps([[
                      {"text": "Action 1", "url": "https://teams.vk.com"},
                      {"text": "Action 2", "callbackData": "call_back_id_2", "style": "attention"},
                      {"text": "Action 3", "callbackData": "call_back_id_2", "style": "primary"}
                  ]])))


bot.dispatcher.add_handler(MessageHandler(callback=message_cb))
bot.dispatcher.add_handler(BotButtonCommandHandler(callback=buttons_answer_cb))

bot.start_polling()
bot.idle()

tr{{tutorialPage.format}}

tr{{tutorialPage.format1}}

tr{{tutorialPage.format2}}

tr{{tutorialPage.format3}}

Format ranges

tr{{tutorialPage.format4}}

{
    "bold": [
        {
            "offset": 0,
            "length": 1
        },
        {
            "offset": 2,
            "length": 5
        }
    ],
    "italic": [
        {
            "offset": 2,
            "length": 3
        }
    ]
}

offsettr{{tutorialPage.format5}}

lengthtr{{tutorialPage.format6}}

Markdown

tr{{tutorialPage.format7}}

tr{{tutorialPage.format8}}

tr{{tutorialPage.format9}}

*bold*
_italic_
__underline__
~strikethrought~
[url](https://example.com)
[mention]
`inline_code`
```
pre-formatted fixed-width code block
```
```python
pre-formatted fixed-width code block written in the Python programming language
```
Ordered list:
1. First element
2. Second element
Unordered list:
- First element
- Second element
Quote:
>Begin of quote
>End of quote

HTML

tr{{tutorialPage.format10}}

tr{{tutorialPage.format11}}

  1. < - &lt;
  2. > - &gt;
  3. & - &amp;

tr{{tutorialPage.format9}}

<b>bold</b>, <strong>bold</strong>
<i>italic</i>, <em>italic</em>
<u>underline</u>, <ins>underline</ins>
<s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
<a href="http://www.example.com/">inline URL</a>
<a>inline mention of a user</a>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
<pre><code class="python">pre-formatted fixed-width code block written in the Python programming language</code></pre>
Ordered list:
<ol>
<li>First element</li>
<li>Second element</li>
</ol>
Unordered list:
<ul>
<li>First element</li>
<li>Second element</li>
</ul>
Quote:
<blockquote>
Begin of quote.
End of quote.
</blockquote>