Exemplo n.º 1
0
from vkstreaming import Streaming
import vkstreaming

response = vkstreaming.getServerUrl('3af6043f3af6043f3af6043f783aa93cb333af63af6043f6301786bc51f61b908819df3')
api = Streaming(response["endpoint"], response["key"])

api.del_all_rules()
for line in open('/Users/martikvm/PycharmProjects/DoubleSearch/popular_words_100_1.txt'):
    api.add_rules(line.lower(), line)
# api.add_rules('Сегодня', 'сегодня')

rules = api.get_rules()
for rule in rules:
    print(("{tag:15}:{value}").format(**rule))

@api.stream
def my_func(event):
    print("[{}]: {}".format(event['author']['id'], event['text']))

api.start()
Exemplo n.º 2
0
        author = event['author']
        author_url = author['author_url']
        if author['author_url'][15:17] == "id":
            person = list(
                vk.users.get(user_ids=author['id'], fields='verified'))
            print(person)
            name = dict(person[0])
        else:
            club = vk.groups.getById(group_id=str(author['id'])[1:])
            print(club)

        text = event['text']
        text = text('<br>', '')

        post = {
            'SClientId': author['author_url'],
            'Message': event['event_url'],
            'Comment': text,
            'FirstName': name['first_name'],
            'Surname': name['last_name'],
            'Verification': bool(name['verified'])
        }

        req = requests.post("http://10.241.103.127:5000/api/clientinfos",
                            json=post)
        print(req.status_code)


streamingAPI.start()