S
S
Sergey Pavlov2021-04-05 14:57:45
Python
Sergey Pavlov, 2021-04-05 14:57:45

How to make an online vk parser and send notifications to telegrams?

Help me make a program in python
Essence: parsing online of a certain id in VKontakte ..
If a person went online, a telegram message "online" comes in, and then we start checking his exit from the network (parsing offline) and a notification is also received in telegram

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sokolov, 2021-04-05
@sergiks

Once every 5 minutes, request from VK using the users.get() method with fields user_ids=12345and fields=onlineinformation about the current online / offline account.
Store the next result of checks in the database, Redis, in a text file, in the VK itself using the storage set()
method Compare with the previously saved value. If it has changed, send a message to Telegram :

  1. pre- create a bot via @BotFather
  2. get his token
  3. create a chat with the bot and get the id of the conversation or add the bot to the group where it will write.

Communication with the VK can be saved up to a single request of the execute() method , where to transfer the procedure code:
  • online request
  • getting the previously stored value in storage
  • comparison
  • saving the current
  • return the result of the comparison.

E
EchoA, 2021-04-05
@EchoA

I think that for your purposes, it will be enough to store data about the current (online / offline) state in the RAM allocated to the application. Those. stupid in code.
Another thing is storing data about which id from vk we generally track - find the simplest solution in your language and use it.
The tg-bot code will be simple. The logic there is this: everyone who wrote the bot, from the point of view of the code, is a "dialog" that has a unique id.
The bot has a .send(dialog id, message text) method.
The mailing is done by a cycle through the list of dialogs - it can be fetched from tg each time, it can be stored somewhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question