· 6 years ago · Dec 28, 2019, 10:12 AM
1import apiai, json, os, vk
2from random import randint
3from requests import *
4import time
5
6VK_API_ACCESS_TOKEN = a042774dc3131ba61c46da48af53e88f3634027553aa246e077167fc9c87e9ee3313eef7a7a0521085da0
7VK_API_VERSION = "5.89"
8GROUP_ID = 190167055
9debug = 1
10
11session = vk.Session(access_token = VK_API_ACCESS_TOKEN)
12api = vk.Api(session, v = VK_API_VERSION)
13
14longpool = api.groups.getLongPoolServer(group_id = GROUP_ID)
15server, key, ts = longPool["server"], longPool["key"], longPool["ts"]
16
17while true:
18 longPool = post('%s'%server, data = {'act': 'a_check',
19 'key': key,
20 'ts': ts,
21 'wait':25}) .json()
22 if longPool['updates'] and len(longPool['updates']) !=0:
23 for update in longPool['updates']:
24 if update ['type'] == 'message_new':
25 peer_id = update['object']['peer_id'] - 2000000000
26 message = update['object']['text']
27 user_id = update['object']['from_id']
28 message_id = update['object']['conversation_message_id']
29 if debug == 1:
30 print(update)
31 if message.lower().find('govno') != -1:
32 api.messages.send(chat_id = peer_id, message = 'govno'