Creating and integrating a VK bot into a group via VkBotLongPoll[Python]

 3r31096. 3r3-31. In this article we will create a bot and integrate it into the VK group in Python 3.x
 3r31096.
 3r31096.

Who is this article for? 3r31050.
 3r31096. For those who want to write a simple bot for their community, who knows how to define commands and display the appropriate answer 3r31082.  3r31096.
 3r31096.
The main stages 3r31050.
 3r31096. 3r31063.  3r31096.
First, let's create a bot in the VK, configure the API key and enable the Long Poll API 3r31085. 3r31075.  3r31096.
Configure Long Poll
 3r31096.
Add definitions of commands that will be processed by the
bot.  3r31096.
Create team associations
 3r31096.
Add a keyboard
 3r31096. 3r31077.
 3r31096. 3r340. 3r31085.
 3r31096.
Creating a bot group


 3r31096. We begin with the creation of a bot, namely a group in the VC
 3r31096.
 3r31096. For this you need to go to "groups" → "create a community" 3r3-31082.  3r31096.
 3r31096. Select any type of community and enter the name, subject of the group
 3r31096.
 3r31096. On the settings page that opens, select "Work with API" 3r3-31082.  3r31096.
 3r31096. Next, you need to create an API key
 3r31096.
 3r31096. Then select the parameters you need with access for your API key
 3r31096.
 3r31096. Most likely, you will have to confirm the action in the VC using a mobile phone. Then copy the resulting API key somewhere in the file. We still need him 3r3r1082.  3r31096.
 3r31096. Then you need to enable messages. To do this, go to the "message" and turn them on. We also turn on “Bots features” in “Messages” -> “Settings for bot” 3r31082.  3r31096.
 3r31096. In the same place, let's allow the community to be added to groups if we want the bot to be able to receive messages from the group 3r31082.  3r31096.
 3r31096.

Setting Long Poll 3r31050.
 3r31096.
 3r31096. To work with the Long Poll API, we use the
library. vk_api
. You can install it through pip
 3r31096.
 3r31096. Before work we will save our API token in the config.py file from there we will load our key.
 3r31096.
 3r31096. Let's create our first script. Let's call server.py, which will be the main server script
 3r31096.
 3r31096. We import the modules we need:
 3r31096. 3r31025. 3r31026. import vk_api.vk_api
3r31096. from vk_api.bot_longpoll import VkBotLongPoll
from vk_api.bot_longpoll import VkBotEventType 3r3103.
 3r31096.
 3r31096. Create a class server: 3r31082.  3r31096.
 3r31096. 3r31025. 3r31026. class Server: 3r31096. 3r31096. def __init __ (self, api_token, group_id, server_name: str = "Empty"):
3r31096. # Give the server the name
self.server_name = server_name
3r31096. # For Long Poll
self.vk = vk_api.VkApi (token = api_token)
3r31096. # To use the Long Poll API
self.long_poll = VkBotLongPoll (self.vk, group_id)
3r31096. # To call the methods vk_api
self.vk_api = self.vk.get_api ()
3r31096. def send_msg (self, send_id, message):
"" "
Sending a message via the messages.send method
: Param send_id: vk id of the user who receives the message
: Param message: the contents of the sent letter 3r31096.: Return: None
" ""
self.vk_api.messages.send (peer_id = send_id, 3r31096. message = message) 3r31096. 3r31096. def test (self):
# Send a message to the user with the specified ID
self.send_msg (25539661? Hi-Hi!) 3r3103.
 3r31096.
 3r31096. Now we will create a server_manager.py file in which we will manage different servers. For the time being, for tests, we will only list the call to the Server class: 3r31082.  3r31096. 3r31025. 3r31026. # Import the class Server 3r31096 created by us. from server import Server
# We get from config.py our api-token
from config import vk_api_token
3r31096. 3r31096. server1 = Server (vk_api_token, 17299802? "server1") 3r31096. # vk_api_token - API token, which we previously created 3r31096. # 172998024 - community bot id
# "server1" is the server name for
3r31096. server1.test () 3r3103.
 3r31096.
3r33939. Important! 3r3393930. A bot can write messages only to those users who have allowed the bot to send messages. You can do this on the community page, or write bot first
 3r31096. If everything is done correctly, the bot will send us a personal message
 3r31096.
 3r31096. Now we will add a bot to the group and teach it to process messages.
 3r31096. To add a bot to a group, click “Invite to conversation” in the right-hand menu of the community.
 3r31096.
 3r31096. Add the start function to the bot, after calling which it will start “listening” to messages via Long Poll (do not forget to add permissions to the event types in the “Working with API” -> “Long Poll API” section and install the latest version):
 3r31096. 3r31025. 3r31026. def start (self):
for event in self.long_poll.listen ():
print (event) 3r3103.
 3r31096.
 3r31096. Run it through server_manager.py:
 3r31096. 3r31025. 3r31026. server1.start () 3r3103.
 3r31096.
 3r31096. Now, if we write a message to the group, we can see the event object: 3r31082.  3r31096.
class' vk_api.bot_longpoll.VkBotMessageEvent '> ({' type ':' message_new ',' object ': {' date ': 154127315?' from_id ': 2559999999?' id ': ?' out ': ?' peer_id ': 200000000?' text ':'[club172998024|bot in da Vk]This is a text! ',' Conversation_message_id ': 18?' fwd_messages':[], 'Important': False, 'random_id': ? 'attachments':[], 'is_hidden': False}, 'group_id': 172998024})>
 3r31096. Also, if we write in private messages:
 3r31096.
class' vk_api.bot_longpoll.VkBotMessageEvent '> ({' type ':' message_new ',' object ': {' date ': 154127323?' from_id ': 2559999999?' id ': 4?' out ': ?' peer_id ': 25539661?' text ':' this is a private message ',' conversation_message_id ': 4?' fwd_messages':[], 'Important': False, 'random_id': ? 'attachments':[],' Is_hidden ': False}, 'group_id': 172998024})>
 3r31096.
 3r31096. From this data we should pay attention to 3r33510. type, object.from_id, object.id, object.peer_id, object.text [/i] . The data received from the messages and from the group is not much different, except for 3r33510. object.peer_id [/i] and 3r?310. object.id [/i] .
 3r31096.
 3r31096. If you take a closer look, object.id for all messages from the group is ? and there are no messages from personal messages Thus, it is possible to separate the messages received from the group and from personal ones.
 3r31096.
 3r31096. We process the received data inside the Server class:
 3r31096.
 3r31096. 3r31025. 3r31026. def start (self):
for event in self.long_poll.listen (): # Listen to server
3r31096. # New message arrived
if event.type == VkBotEventType.MESSAGE_NEW:
3r31096. print ("Username:" + self.get_user_name (event.object.from_id))
print ("From:" + self.get_user_city (event.object.from_id))
print ("Text:" + event.object.text)
print ("Type:", end = "")
if event.object.id> 0:
print ("private message")
else:
print ("group message")
print ("---")
3r31096. def get_user_name (self, user_id):
"" "Get the username" ""
return self.vk_api.users.get (user_id = user_id)[0] ['first_name']3r31096. 3r31096. def get_user_city (self, user_id):
"" "Getting the city of the user" ""
return self.vk_api.users.get (user_id = user_id, fields = "city")[0] ["city"] ['title']3r31038. 3r3103.
 3r31096.
 3r31096. We will write two messages to the bot: one from the group, one in lichku. Then we get:
 3r31096.
Username: Arthur
 3r31096. From: St. Petersburg
 3r31096. Text:[club172998024|@club172998024]this is a message from group
 3r31096. Type: group message
 3r31096. - 3r31082.  3r31096. Username: Arthur
 3r31096. From: St. Petersburg
 3r31096. Text: this is a private message
 3r31096. Type: private message
 3r31096. - 3r3507.
 3r31096.
 3r31096.
3r33939. Note
 3r31096. As you can see before the message in the group there is[club172998024|@club172998024], for correct processing of the command, you should get rid of all the content in square brackets, or allow the bot access to the entire correspondence
 3r31096. As we see, vk_api allows us to easily use VK API methods. For example, now we used the method 3r33510. users.get [/i]
 3r31096.
 3r31096. A list of all methods is available at the link: vk.com/dev/methods
 3r31096.
 3r31096. I advise you to study and experiment with methods that interest you. Fortunately VK has provided us with very good documentation, also in Russian.
 3r31096.
 3r31096. To consolidate the material, let's add the function of sending a message through the method 3r33510. messages.send [/i] :
 3r31096. 3r31025. 3r31026. def send_message (self, peer_id, message):
self.vk_api.messages.send (peer_id = peer_id, message = message) 3r3103.
 3r31096. 3r33337. - destination identifier. To reply to someone's message, as parameter 3r3510. peer_id [/i] we specify 3r33510. event.object.peer_id [/i] . That is, send a message to where the request came from.
 3r31096.
 3r31096. Change the start method:
 3r31096. 3r31025. 3r31026. def start (self):
for event in self.long_poll.listen (): # Listen to server
3r31096. # New message arrived
if event.type == VkBotEventType.MESSAGE_NEW:
3r31096. username = self.get_user_name (event.object.from_id)
print ("Username:" + username)
print ("From:" + self.get_user_city (event.object.from_id))
print ("Text:" + event.object.text)
print ("Type:", end = "")
if event.object.id> 0:
print ("private message")
else:
print ("group message")
print ("---")
3r31096. self.send_message (event.object.peer_id, f "{username}, I received your message!") 3r3103.
 3r31096.
 3r31096. Now, if the bot accepts the message, it will respond to us in this style: 3r31082.  3r31096.
Arthur, I received your message!
 3r31096.
 3r31096. 3r3805. 3r3r6806. All code 3r3807. 3r3808. 3r33939. server.py
 3r31096. 3r31025. 3r31026. import vk_api.vk_api
3r31096. from vk_api.bot_longpoll import VkBotLongPoll
from vk_api.bot_longpoll import VkBotEventType
3r31096. 3r31096. class Server: 3r31096. 3r31096. def __init __ (self, api_token, group_id, server_name: str = "Empty"):
3r31096. # Give the server the name
self.server_name = server_name
3r31096. # For Long Poll
self.vk = vk_api.VkApi (token = api_token)
3r31096. # To use Long Poll API
self.long_poll = VkBotLongPoll (self.vk, group_id, wait = 20)
3r31096. # To call the methods vk_api
self.vk_api = self.vk.get_api ()
3r31096. def send_msg (self, send_id, message):
"" "
Sending a message via the messages.send method
: Param send_id: vk id of the user who receives the message
: Param message: the contents of the sent letter 3r31096.: Return: None
" ""
self.vk_api.messages.send (peer_id = send_id, 3r31096. message = message) 3r31096. 3r31096. def test (self):
self.send_msg (25539661? Hi-Hi!)
3r31096. def start (self):
for event in self.long_poll.listen (): # Listen to server
3r31096. # New message arrived
if event.type == VkBotEventType.MESSAGE_NEW:
3r31096. username = self.get_user_name (event.object.from_id)
print ("Username:" + username)
print ("From:" + self.get_user_city (event.object.from_id))
print ("Text:" + event.object.text)
print ("Type:", end = "")
if event.object.id> 0:
print ("private message")
else:
print ("group message")
print ("---")
3r31096. self.send_message (event.object.peer_id, f "{username}, I received your message!")
3r31096. def get_user_name (self, user_id):
"" "Get the username" ""
return self.vk_api.users.get (user_id = user_id)[0] ['first_name']3r31096. 3r31096. def get_user_city (self, user_id):
"" "Getting the city of the user" ""
return self.vk_api.users.get (user_id = user_id, fields = "city")[0] ["city"] ['title']3r31096. 3r31096. def send_message (self, peer_id, message):
self.vk_api.messages.send (peer_id = peer_id, message = message)
3r31038. 3r3103.
 3r31096. 3r33939. server_manager.py
 3r31096. 3r31025. 3r31026. # Import the class Server 3r31096 created by us. from server import Server
# We get from config.py our api-token
from config import vk_api_token
3r31096. 3r31096. server1 = Server (vk_api_token, 17299802? "server1") 3r31096. server1.start () 3r3103.
 3r31096. 3r31092. 3r31092.
 3r31096. 3r33939. Problem to secure the material:
 3r31096. Create a function that takes a peer_id parameter and sends the user a photo uploaded to the community. Useful dock: vk.com/dev/messages.send
 3r31096.
 3r31096. 3r3805. 3r3r6806. Solution 3r3807. 3r3808. First, upload a photo to the group and open it in VC. Consider the link: 3r31082.  3r31096.
vkcom /club172998024? z = 3r33510. 3r3502. photo-172998024_456239017 [/b] 3r33511. % 2Falbum-172998024_256250731
 3r31096. We are only interested in the highlighted part: 3r33510. photo-172998024_456239017 3r3355111. . Let's pass it as an argument to the messages.send method:
 3r31096. 3r31025. 3r31026. def send_img (self, peer_id):
self.vk_api.messages.send (peer_id = peer_id,
attachment = "photo-172998024_456239017") 3r3103.
 3r31096. Add it to the start method and get: 3r31082.  3r31096. 3r33524.
 3r31096. 3r31092. 3r31092.
 3r31096. That's all the basics. The main thing is to learn how to use vk_api using various methods, their entire list: vk.com/dev/methods . If you learn to work with VK API documentation, you can create bots of varying complexity and assignments. An example of my bot for the training group: 3r3333533. github.com/AppLoidx/GroupAssistant/tree/master
 3r31096.
 3r31096.
Now let's get down to creating the logic of the bot 3—3–31050.
 3r31096. Let's create commander.py, which will accept commands and return the response given to user Vk:
 3r31096. 3r31025. 3r31026. class Commander:
3r31096. def __init __ (self, vk_api, user_id):
self.vk_api = vk_api
self.user_id = user_id
3r31096. def input (self, msg):
"" "
The function accepts user messages
: Param msg: Message
: Return: Reply to the user who sent the message 3r31096." "" 3r31096. pass
3r31038. 3r3103.
 3r31096. 3r33939. Construct the architecture of our program:
 3r31096. We “listen” to the Long Poll server and get the user's message ->
 3r31096. We transfer the message to Commander.input () -> We define the mode -> We define the command ->
 3r31096. We return the answer -> We transfer to the user
 3r31096.
 3r31096. To determine the mode and command, create two files command_enum.py and mode_enum.py. With them, we will determine the modes and commands through the methods of the class Enum:
 3r31096.
 3r31096. 3r33939. command_enum.py:
 3r31096. 3r31025. 3r31026. from enum import Enum
3r31096. 3r31096. class Command (Enum):
"" "weather" ""
weather =["weather", "погода"]3r31096. 3r31096. "" "myanimelist" ""
anime_top =["top anime", "топ аниме"]3r31038. 3r3103.
 3r31096.
 3r31096. 3r33939. mode_enum.py:
 3r31096. 3r31025. 3r31026. from enum import Enum
3r31096. 3r31096. class Mode (Enum):
default =["Обычный режим", "default"]3r31096. translate =["Режим переводчика", "translate"]3r31096. get_ans = 0 3r3103.
 3r31096.
 3r31096. To change modes use[слэш("/")+<имя_режима>], and we will accept all other teams as teams.
 3r31096.
 3r31096. Implement it in Commander.py:
 3r31096. 3r31025. 3r31026. # Enumeration of commands, modes 3r31096. from command_enum import Command
from mode_enum import Mode
3r31096. # Working modules
from translate.yandex_translate import Translator
from weather import Weather
from myanimelist import Myanimelist
3r31096. # Config
from config import yandex_translate_api
3r31096. 3r31096. class Commander:
3r31096. def __init __ (self):
3r31096. # Current, previous modes
self.now_mode = Mode.default
self.last_mode = Mode.default
3r31096. self.last_command = None
3r31096. # To memorize user responses
self.last_ans = None
3r31096. # Work with translation
self.translator = Translator (yandex_translate_api)
3r31096. def change_mode (self, to_mode):
"" "
Changes the mode of receiving commands
: Param to_mode: Modified mode
" ""
self.last_mode = self.now_mode
self.now_mode = to_mode
3r31096. self.last_ans = None
3r31096. def input (self, msg):
"" "
The function accepts user messages
: Param msg: Message
: Return: Reply to the user who sent the message 3r31096." "" 3r31096. 3r31096. # Check on the team change mode
3r31096. if msg.startswith ("/"):
for mode in Mode:
if msg[1::]in mode.value:
self.change_mode (mode)
return "Mode changed to" + self.now_mode.value[0]3r31096. return "Unknown mod" + msg[1::]3r31096. 3r31096. # Receive mode answer
if self.now_mode == Mode.get_ans:
self.last_ans = msg
self.now_mode = self.last_mode
return "Ok!" 3r31096. 3r31096. if self.now_mode == Mode.default:
3r31096. # Weather
if msg in Command.weather.value:
return Weather.get_weather_today ()
3r31096. # Top anime
if msg in Command.anime_top.value:
res = ""
top = Myanimelist.get_top ()
for anime in top:
res + = anime + ":" + top[anime]+ "n"
3r31096. return res
3r31096. if self.now_mode == Mode.translate:
if self.last_ans is None:
3r31096. # If no language is selected, ask the user to enter
self.change_mode (Mode.get_ans)
self.last_command = msg
Return "Select the language you want to translate" 3r3-31096. 3r31096. elif self.last_ans == "change":
3r31096. # Change the translated language
self.last_ans = None
self.change_mode (Mode.default)
3r31096. else:
# Translate 3r31096. Return self.translator.translate_to (msg, self.last_ans)
3r31096. return "Command not recognized!" 3r31038. 3r3103.
 3r31096. 3r3805. 3r3r6806. weather.py [/b] 3r3808. 3r31025. 3r31026. import requests
from bs4 import BeautifulSoup
3r31096. 3r31096. class Weather:
@staticmethod
def get_weather_today (city: str = "st. petersburg") -> list:
3r31096. http = "https://sinoptik.com.ru/pogoda-" + city
b = BeautifulSoup (requests.get (http) .text, "html.parser")
3r31096. p3 = b.select ('. temperature .p3')
weather1 = p3[0].getText ()
p4 = b.select ('. temperature .p4')
weather2 = p4[0].getText ()
p5 = b.select ('. temperature .p5 ')
weather3 = p5[0].getText ()
p6 = b.select ('. temperature .p6')
weather4 = p6[0].getText ()
3r31096. result = ''
result = result + ('In the morning:' + weather1 + '' + weather2) + 'n'
result = result + ('Day:' + weather3 + '' + weather4) + 'n'
temp = b.select ('. rSide .description')
weather = temp[0].getText ()
result = result + weather.strip ()
3r31096. Return result
3r31038. 3r3103.
 3r31096. 3r31092. 3r31092.
 3r31096. 3r3805. 3r3r6806. myanimelist.py [/b] 3r3808. 3r31025. 3r31026. import requests
import bs4
3r31096. 3r31096. class Myanimelist:
3r31096. @staticmethod
def get_top (count: int = ? by: str = "") -> dict:
types =["", "airing", "upcoming", "tv", "movie", "ova", "special", "bypopularity", "favorite"]3r31096. if by not in types:
return {"error:": "Unknown type!"}
html = requests.get ("https://myanimelist.net/topanime.php?type=" + by)
soup = bs4.BeautifulSoup (html.text, "html.parser")
3r31096. res = {}
3r31096. for anime in soup.select (". ranking-list", limit = count):
3r31096. url = anime.select (". hoverinfo_trigger")[0] ['href']3r31096. anime = anime.select (". hoverinfo_trigger")[0].findAll ("img")[0]3r31096. name = anime['alt'].split (":")[1].strip ("")
res[name]= url
3r31096. return res
3r31038. 3r3103.
 3r31096. 3r31092. 3r31092.
 3r31096. 3r3805. 3r3r6806. yandex_translate.py [/b] 3r3808. 3r31025. 3r31026. import requests
from config import yandex_translate_api
3r31096. 3r31096. class Translator:
"" "
Class translator using the Yandex Translate API 3r31096. 3r31096. Parameters:
3r31096. _Key is the key from Yandex.Translate API. "
def __init __ (self, key, comment = None):
"" "
: Param key: a key from API Yandex.Translate
: Param comment: Comment on each translation
" ""
self._key = key
if comment is None:
self._yandex_comment = "n Translated by the Yandex.Translate service http://translate.yandex.ru/" 3r31096. else:
self._yandex_comment = comment
3r31096. def translate (self, text, lang, to_lang = None):
"" "
Translates text from the specified language into another specified
: Param text: Text to be translated
: Param lang: source language
: Param to_lang: target language
. "" "
if to_lang is not None:
lang = f "{lang} - {to_lang}"
main_url = "https://translate.yandex.net/api/v1.5/tr.json/translate"
response = requests. get (f "{main_url}?"
f "key = {self._key} &"
f "lang = {lang} &"
f "text = {text}") 3r31096. 3r31096. return response.json ()['text'] [0]+ self._yandex_comment
3r31096. def lang_identify (self, text, hint = "ru, en"):
"" "
Identifies the language
: Param text: Text
: Param hint: Hints for defining the language
: Return: the language code 3r31096." ""
main_url = "https://translate.yandex.net/api/v1.5/tr.json/detect"
response = requests. get (f "{main_url}?"
f "key = {self._key} &"
f "hint = {hint} &"
f "text = {text}") 3r31096. 3r31096. return response.json ()['lang']3r31096. 3r31096. def translate_ru_en (self, text):
"" "
Translates text from Russian to English
: Param text: Text to be translated
: Return: The translated text into English
" ""
if self.lang_identify (text) == "en":
to_lang = "en"
from_lang = "ru"
else:
to_lang = "ru"
from_lang = "en"
3r31096. return self.translate (text, from_lang, to_lang)
3r31096. def translate_to_ru (self, text, hint = None):
"" "
Translates the text into Russian
: Param text: Text to be translated
: Param hint: Hints to the definition of language
: Return: Text translated into Russian
if hint is None:
hint = "ru, en"
from_lang = self.lang_identify (text, hint)
3r31096. return self.translate (text, from_lang, "ru")
3r31096. def translate_to (self, text, to_lang, hint = None):
"" "
Translates the text into the desired language
: Param text: The text to be translated
: Param to_lang: The code of the resulting language
: Param hint: Tips for defining the language
: ? 3r31096: hints: . "" "
if hint is None:
hint = "ru, en"
from_lang = self.lang_identify (text, hint)
3r31096. return self.translate (text, from_lang, to_lang)
3r31038. 3r3103.
 3r31096. 3r31092. 3r31092.
 3r31096.
 3r31096. All code is available on github: github.com/AppLoidx/VkLongPollBot
 3r31096.
 3r31096. 3r33939. Add a keyboard:
 3r31096. This is a very easy process, complications can be caused when we change the keyboard to a specific command signature, which is different for each mode.
 3r31096.
 3r31096. To add a keyboard in the dialog box, you need to specify in the messages.send method the keyboard parameter that accepts json. It looks like this:
 3r31096. 3r31025. 3r31026. vk_api.messages.send (, keyboard = keyboard_json, ) 3r3103.
 3r31096. Alternatively, you can transfer the keyboard directly from a .json file:
 3r31096. 3r31025. 3r31026. vk_api.messages.send (, keyboard = open (filename, "r", encoding = "UTF-8"). read ()
 3r31096. Documentation: 3r3953. vk.com/dev/bots_docs_3?f=4.%2BKeyboard% 2B for% 2B work
 3r31096.
 3r31096. Consider the example of our program by adding a keyboard.
 3r31096. First, create a file called keyboard.json:
 3r31096. 3r31025. 3r3999. {
"one_time": false,
"buttons":[
[{
"action": {
"type": "text",
"label": "top anime"
},
"color": "positive"
},
{
"action": {
"type": "text",
"label": "weather"
},
"color": "positive"
}], 3r31096.[{
"action": {
"type": "text",
"label": "translate"
},
"color": "default"
}]3r31096. ]
} 3r3103.
 3r31096.
 3r31096. To remove the keyboard, you must pass json with empty buttons:
 3r31096. 3r31025. 3r3999. {"buttons":[], "one_time": true} 3r3103.
 3r31096.
 3r31096. Override send_message in server.py:
 3r31096. 3r31025. 3r31026. def send_msg (self, send_id, message):
"" "
Sending a message via the messages.send method
: Param send_id: vk id of the user who receives the message
: Param message: the contents of the sent letter 3r31096.: Return: None
" ""
return self.vk_api.messages.send (peer_id = send_id,
message = message,
keyboard = open ("keyboards /default.json", "r", encoding = "UTF-8"). read ()) 3r31038. 3r3103.
 3r31096. And also in the start method:
 3r31096. 3r31025. 3r31026. def start (self):
for event in self.long_poll.listen (): # Listen to server
if event.type == VkBotEventType.MESSAGE_NEW:
3r31096. if event.object.from_id not in self.users:
self.users[event.object.from_id]= Commander ()
3r31096. # New message arrived
if event.type == VkBotEventType.MESSAGE_NEW:
3r31096. self.send_msg (event.object.peer_id,
self.users[event.object.from_id]input (event.object.text)) 3r3103.
 3r31096. As a result, we get:
 3r31096. 3r31044.
 3r31096.
 3r31096.
The last word is


 3r31096. Do not use 3r31053. naked [/u] listing of source codes presented here, they are used only to make you better understand what is happening under the hood. Of course, they are all usable and can be used in parts.
 3r31096.
 3r31096. Personally, I used such a bot for a group assistant who could: 3r31082.  3r31096.
 3r31096. 3r31063.  3r31096.
create queues of group members, including many teams that edited the queue, such as adding, deleting, creating, and so on. 3r31075.  3r31096.
send out to all participants the messages 3–3–31075.  3r31096.
asked questions (for example, on the Java language) 3r31075.  3r31096.
made it possible to create applications for exchange of places, etc. 3r31075.  3r31096. 3r31077.
 3r31096. The github project: 3r31080. github.com/AppLoidx/GroupAssistant
 3r31096. The sources are presented here: github.com/AppLoidx/VkLongPollBot 3r31092. 3r31096. 3r31096. 3r3-1089. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () ();
3r31096. 3r31092. 3r31096. 3r31096. 3r31096. 3r31096.
+ 0 -

Add comment