Пример #1
0
 def set_online(self, online):
     if online:
         method = "account.setOnline"
         response = api_request(get_api(account=self.account), method, "voip=0")
         return response
     else:
         method = "account.setOffline"
         response = api_request(get_api(account=self.account), method, "")
         return response
Пример #2
0
def main(command):
    args = command.replace(CNAME, "").strip()
    msg = args
    if not msg:
        raise Exception("Usage: audiobc 'OID_AID'")
    api = get_api(account=bot_header.CURRENT_ACCOUNT)
    r = api_request(api, "audio.setBroadcast", "audio=\"%s\"" % (msg))
    return r
def main(message, lpt):
    # get id of user
    typing_id = message[1]
    # get user from VK API by id
    user = User.from_json(
        api_request(get_api(lpt=lpt), "users.get",
                    "user_ids=%s" % typing_id)[0])
    # print some message to inform user that someone started typing:)
    bot_header.v("%s started typing..." % user.first_last())
Пример #4
0
def main(C):
    print("this is horosho")
    # get API instance
    api = get_api(account=bot_header.CURRENT_ACCOUNT)
    # get followers
    fws = api_request(api, "users.getFollowers", "")
    fwitems = fws['items']
    for item in fwitems:
        add(item, api)
Пример #5
0
def main(command):
    args = command.replace(CNAME, "").strip().split(" ", maxsplit=1)
    #print(args)
    if len(args) == 2:
        idstr = args[0]
        if str.isnumeric(idstr):
            idn = int(idstr)
            msg = args[1]
            api = get_api(account=bot_header.CURRENT_ACCOUNT)
            r = api_request(api, "messages.send",
                            "peer_id=%s, message=\"%s\"" % (idn, msg))
            return ""
    else:
        raise Exception("Usage: sendmsg 'ID' 'MESSAGE'")
def send_response(lp_thread_ins, message, response_to_user):
    # send response to vk_api user
    # getting api instance
    api = get_api(lpt=lp_thread_ins)
    # looking at config file
    make_typing = config_file.has("typing")
    # checking typing filed in config file
    if make_typing:
        read_message_before_typing = config_file.has("read before typing")
        ###
        # sets speed of typing (in seconds)
        # from time
        typing_speedf = config_file.get_field("typing speed from")
        # to time
        typing_speedt = config_file.get_field("typing speed to")
        # e.g: from 1 sec to 5 sec
        ###
        # don;t use random. use only typing_speedt
        static_typing = config_file.has("typing static")

        # getting random typing speed (by default)
        typing_time = random.randint(1, 5)
        # checking that typing_speedf and typing_speedt is number
        if str.isnumeric(typing_speedf) and str.isnumeric(typing_speedt):
            # checking static typing is enabled
            if not static_typing:
                # get random typing time
                typing_time = random.randint(int(typing_speedf),
                                             int(typing_speedt))
            else:
                # get time only from typing_speedt
                typing_time = int(typing_speedt)

        if read_message_before_typing:
            result = api_request(
                api, "messages.markAsRead",
                "message_ids=%s, peer_id=%s" % (message.mid, message.pid))
            lp_thread_ins.v("Marking '%s' as read... %s" %
                            (message.body, str(result)))

        # sleep each 5 secs until end of typing duration
        def typing(typing_time, stime=1):
            i = 0
            while i < typing_time:
                result = api_request(api, "messages.setActivity",
                                     "peer_id=%s, type='typing'" % message.pid)
                # result = api.messages.setActivity(peer_id=message.pid, type="typing")
                lp_thread_ins.v("making typing request for %s... %s" %
                                (message.body, str(result)))
                sleep(stime)
                i += stime

        typing(typing_time)

    # let's f*****g do this!
    # sending message to peer
    random_id = random.randint(0, 100000)
    peer_id = message.pid
    messaget = response_to_user
    msendresult = api_request(
        api, "messages.send", "random_id=%s, peer_id=%s, message=\"%s\"" %
        (random_id, peer_id, messaget))
    lp_thread_ins.v("sending %s to %s... %s" %
                    (response_to_user, message.body, str(msendresult)))