예제 #1
0
    def __init__(self, token, group_id, debug=True):
        Vk.__init__(self, token=token, group_id=group_id, debug=debug)
        self.messages_to_delete = {}
        self.userbot = UserBot()
        self.debug = True

        base = BetterBotBase("users", "dat")
        #base.addPattern("rating", 0)
        base.addPattern("karma", 0)
        base.addPattern("programming_languages", [])
        base.addPattern("github_profile", "")
        #base.addPattern("current", [])
        base.addPattern("supporters", [])
        #base.addPattern("current_sub", [])
        base.addPattern("opponents", [])
        base.addPattern("last_collective_vote", 0)

        #xusers = base.getSortedByKeys("karma", otherKeys=["current", "current_sub"])
        #for xuser in xusers:
        #    uuser = base.load(xuser["uid"])
        #    uuser.supporters = []
        #    uuser.opponents = []
        #    uuser.karma = 0
        #    base.save(uuser)

        self.base = base
예제 #2
0
    def __init__(self, token, group_id, debug=True):
        Vk.__init__(self, token=token, group_id=group_id, debug=debug)
        self.messages_to_delete = {}
        self.userbot = UserBot()
        self.debug = True

        base = BetterBotBase("users", "dat")
        base.addPattern("karma", 0)
        base.addPattern("programming_languages", [])
        base.addPattern("github_profile", "")
        base.addPattern("supporters", [])
        base.addPattern("opponents", [])
        base.addPattern("last_collective_vote", 0)

        self.base = base
예제 #3
0
 def __init__(
     self,
     token: str,
     group_id: int,
     debug: bool = True
 ):
     """Auth as VK group and register commands.
     """
     Vk.__init__(self, token=token, group_id=group_id, debug=debug)
     self.messages_to_delete = {}
     self.userbot = UserBot()
     self.data = BetterBotBaseDataService()
     self.commands = Commands(self, self.data)
     self.commands.register_cmds(
         (patterns.HELP, self.commands.help_message),
         (patterns.INFO, self.commands.info_message),
         (patterns.UPDATE, self.commands.update_command),
         (patterns.ADD_PROGRAMMING_LANGUAGE,
          lambda: self.commands.change_programming_language(True)),
         (patterns.REMOVE_PROGRAMMING_LANGUAGE,
          lambda: self.commands.change_programming_language(False)),
         (patterns.ADD_GITHUB_PROFILE,
          lambda: self.commands.change_github_profile(True)),
         (patterns.REMOVE_GITHUB_PROFILE,
          lambda: self.commands.change_github_profile(False)),
         (patterns.KARMA, self.commands.karma_message),
         (patterns.TOP, self.commands.top),
         (patterns.PEOPLE, self.commands.top),
         (patterns.BOTTOM,
          lambda: self.commands.top(True)),
         (patterns.TOP_LANGUAGES, self.commands.top_langs),
         (patterns.PEOPLE_LANGUAGES, self.commands.top_langs),
         (patterns.BOTTOM_LANGUAGES,
          lambda: self.commands.top_langs(True)),
         (patterns.APPLY_KARMA, self.commands.apply_karma),
     )
예제 #4
0
 def get_users_sorted_by_karma(
         vk_instance: Vk,
         data: BetterBotBaseDataService,
         peer_id: int,
         reverse_sort: bool = True) -> List[BetterUser]:
     members = vk_instance.get_members_ids(peer_id)
     users = data.get_users(
         other_keys=[
             "karma", "name", "programming_languages", "supporters",
             "opponents", "github_profile", "uid"
         ],
         sort_key=lambda u: DataBuilder.calculate_real_karma(u, data),
         reverse_sort=reverse_sort)
     if members:
         users = [u for u in users if u["uid"] in members]
     return users
예제 #5
0
# -*- coding: utf-8 -*-
# author: Ethosa
from random import choice, randint
from time import sleep
from os import listdir

from saya import Vk  # version 0.1.46 or later
from mchains import MarkovChains  # version 0.1 or later
import regex
from gtts import gTTS

vk = Vk(login=88005553535, password="******", debug=True)
# Images folder
# this folder should contain only images.
folder = "images/"
can_delete = False
# "F" images
photos = [
    "photo556962840_457244346", "photo556962840_457244348",
    "photo556962840_457244349"
]


@vk.on_message_new
def getmessage(event):
    print(event)
    if "object" in event and "from" in event["object"] and event["object"][
            "from"] == '556962840':
        mid = event["message_id"]
        # Edit message which contains "F" text.
        if event["text"] == "F":
예제 #6
0
파일: demo3.py 프로젝트: dEN5-tech/saya
# -*- coding: utf-8 -*-
# author: Ethosa
# Receiving real-time events #2

from saya import Vk

vk = Vk(login=88005553535, password="******", debug=True)


@vk.on_message_new(False)  # Creates and starts a new thread, if True.
def get_new_message(event):
    print(event)

vk.start_listen()
예제 #7
0
 def __init__(self):
     Vk.__init__(self, token=BotToken, group_id=bot_group_id, debug=True)
     self.messages_to_delete = {}
     self.userbot = UserBot()
     self.debug = True
예제 #8
0
from saya import Vk

vk = Vk(login=123, password="******", debug=True)


@vk.to_execute
def hello(a, b, c, arg1):
    test = a
    test = test + b
    test = test + c
    test = test + "a"
    vk.messages.send(
        message=test,
        peer_id=2_000_000_035,
        random_id=4,
    )
    vk.messages.send(message=test, peer_id=2_000_000_035, random_id=5)
    return test


print(hello("бан блин))) ", "а блин :| ", "bbbbbbbbbb", 13123123123))
예제 #9
0
from saya import Vk, StreamingAPI

vk = Vk(token="service token here :3", debug=True)

streaming = StreamingAPI(vk)
streaming.auth()
streaming.add_rule("1", "аниме")
streaming.add_rule("2", "saya")
streaming.add_rule("3", "кот")
print(streaming.get_rules())

for event in streaming.listen():
    print(event)
예제 #10
0
import time
import random
from saya import Vk  #pip3.7 install saya
import json

# используем более удобную отправку сообщения


def send(text):
    vk.messages.send(message=text, peer_id=peer_id, random_id=peer_id)


# вход в аккаунт, у меня через группу, если вы хотите через аккаунт то уберите group_id

vk = Vk(token="ваш токен", group_id="айди группы")

print("✨Загрузка...")

# Основной цикл

for event in vk.longpoll.listen(True):
    try:
        # для удобства я присвоил back значение эвента, но это не обязательно
        back = event
        # возвращаем значение текста
        text = (str(back["object"]["message"]["text"]))
        # возвращаем id диалога
        peer_id = (str(back["object"]["message"]["peer_id"]))
        # возвращаем айди получателя
        from_id = (str(back["object"]["message"]["from_id"]))
예제 #11
0
from saya import Vk

# User
vk = Vk(login=81234567890, password="******", debug=True)

# Group
group = Vk(token="asdqwe1329balsduyhi_jbasuf", debug=True)


@vk.on_message_new(False)
def get_message(message):
    print(message)


vk.start_listen()
예제 #12
0
from PIL import Image, ImageDraw, ImageFont
from textwrap import wrap
from saya import Vk
from gtts import gTTS
from pydub import AudioSegment
from time import sleep, time
from random import randint, choice
from requests import get
from speech_recognition import Recognizer, AudioFile
from zalgo_text import zalgo
import json

group_id = 'your group id'
zg = zalgo.zalgo()
rec = Recognizer()
vk = Vk(token="", group_id=group_id)
vk_user = Vk(token="")

file_name = 'bot_data.json'
area = (45, 250, 95, 300)
font_italic = ImageFont.truetype('./data/a_Futurica_ExtraBoldItalic.ttf', 23)
font = ImageFont.truetype('./data/a_Futurica_ExtraBold.ttf', 18)
peer_ids_list = []

album_meme = vk_user.photos.get(owner_id=-103083994,
                                album_id="wall",
                                count=1000)["response"]["items"]
photo_list_meme = [i["id"] for i in album_meme]
del (album_meme)

spam = '👺❤💘🌵🐡🌚😅😜💮🧟‍♂🦸‍♀🙇‍♂🙆‍♂🌳🦑🌺🐉🥳😘📢🤠🥳😎'