예제 #1
0
파일: Date.py 프로젝트: karp57/D20chat
def change_name():
    global u_log, u_pas, uid
    hours = (number_of_day(date()) - 1) * 24 + int(cur_time()[0])
    vk = vk_api.VkApi(login = u_log, password = u_pas)
    vk.auth()
    vk.method('messages.editChat', {'chat_id':int(uid), 'title':periodic_number((9 * 2400 + hours), 2400)+ ' Д'})
    return 0
예제 #2
0
파일: vkSpy.py 프로젝트: Ademishe/vkSpy
def workingThreadRoutine(uemail, upassword, result):
	resp = get_online_friends(u_id, access_token)
	if resp == None:
		print("token has expired")
		access_token, u_id = vk.auth(uemail, upassword, "3336140", "friends")
		workingThreadRoutine(uemail, upassword, result)
		return
	print("{0} {1}".format(time.strftime("%d-%m-%Y %H:%M:%S", time.localtime()), resp))
	for friend in resp:
		result[friend]['online_time'] += sleepTime
	logChanges(result)
예제 #3
0
파일: newDate.py 프로젝트: karp57/D20chat
def change_name():
    global u_log, u_pas
    k = vk_api.VkApi(login = u_log, password = u_pas)
    vk.auth()
    vk.method('messages.editChat', {'chat_id':int(user_data[2]), 'title':str(9 + res_value(date())) + ' Д'})
    return 0;
예제 #4
0
import vk
import json

APP_ID = '3313789'
SCOPE = '8388607' #all (sum([2**x for x in range(23)])) 
mytoken, user_id = vk.auth(email='email', password='******', client_id=APP_ID, scope=SCOPE)
print('\n', mytoken, user_id)
d = {'user_id': user_id, 'count':'14'}
json_obj = json.loads(vk.method_request(token=mytoken, method_name='audio.get', params=d).decode())

print(json_obj['response'])
예제 #5
0
def main():
    # noinspection PyGlobalUndefined
    global access_token, user_id, max_count_post

    while True:
        access_token, user_id = vk.auth(
            '+79123260552', "GiveMeUsaTank1337", "4826374",
            'audio,groups,friends,photos,wall,notify,messages,stats,offline')
        if access_token != '':
            break

    init_var()
    # pp = telegram.utils.request.Request(proxy_url='socks5://46.101.209.178:1080')
    # bot = telegram.Bot(token=telegram_token_news_bayanist_bot, request=pp)
    bot = Bot(telegram_token_news_bayanist_bot)
    uploader = bot.get_uploader()

    while True:

        for group_id, domain in list_groups:
            wall_record = vk_api.wall.get(owner_id=group_id,
                                          domain=domain,
                                          count='10',
                                          access_token=access_token,
                                          v='5.95')
            if wall_record is None:
                continue
            post = get_most_like_post(wall_record, domain)
            if post is None:
                continue
            else:

                photos_path = save_photo_for_post(post)

                try:
                    # status = bot.send_message(chat_id="@bayan_shop_vk", text='Хоп хэй лалалалей',
                    #                           parse_mode=telegram.ParseMode.HTML)
                    status = uploader.send_photo("@bayan_shop_vk",
                                                 open(photos_path, 'rb'),
                                                 request_kwargs=REQUEST_KWARGS)

                    print(status)
                except Exception as e:

                    status = None

                time_to_last_post = datetime.now()
                if status is not None:
                    utcnow = datetime.utcnow()
                    session = Session()
                    session.add_all([
                        Post(id_post=now_post_id,
                             timestamp=utcnow + timedelta(seconds=1),
                             time=datetime.time(datetime.now()),
                             id_group=domain),
                        Hash(hash=now_img_hash,
                             timestamp=utcnow + timedelta(seconds=1))
                    ])
                    session.commit()

                    hash_list.append(
                        Hash(hash=now_img_hash,
                             timestamp=utcnow + timedelta(seconds=1)))

                    time_to_sleep = 25 - (
                        (datetime.now() - time_to_last_post).seconds / 60)

                    print(
                        'между постами рекомендуется выдержать время, в среднем '
                        + str(time_to_sleep) + ' минут')

                    print(datetime.now())
                    if time_to_sleep > 0:
                        time.sleep(time_to_sleep * 60)
예제 #6
0
import requests, time, vk, vk_api, random, time

idNumber = []
# Проверяем не писали ли раньше сообщения
vkIdNumber = open("logVk.txt", "r")
for i in vkIdNumber:
    idNumber.append(i)
vkIdNumber.close()

vk = vk_api.VkApi(login='******', password='******')
vk.auth()

# Шаблоны сообщений
dictFemale = {"1": """
        This is message Female
    """}
dictMale = {"1": """
        This is message Male
    """}


# Функция "написать сообщение"
def write_msg(user_id, s):
    vk.method('messages.send', {'user_id': user_id, 'message': s})


# Начинаем хаос _____________________________________________________

# Массив из счастливчиков
luckUser = []
예제 #7
0
파일: main.py 프로젝트: aleeusgr/KZnO
        print(today)
        return False

def write_log():
    with open('log.txt','r+') as f:
       import datetime
       f.write(str(datetime.date.today()))

def check_log():
    with open('log.txt') as f:
        for line in f:
            pass
        last = line
    import datetime
    if datetime.datetime.strptime(last, '%Y-%m-%d').date()==datetime.date.today():
        return False
    else:
        return True

weekdays = [1,3]
if check_date(weekdays) and check_log():
    v = vk.auth()
    pic = choose_pic(newpath)
    result = vk.post_pic(v,pic)
    print(result)
    write_log()
    shutil.move('./{}/{}'.format(newpath,pic),'./{}/{}'.format(oldpath,pic))
    

check_log()
예제 #8
0
 def auth(self):
     self._vk_ = auth()
     pass
예제 #9
0
 def __init__(self):
     self._vk_ = auth()
     self._m_worker_ = ThreadMessages(vk=self._vk_)
     self._t_worker_ = ThreadSheduler(vk=self._vk_)
예제 #10
0
파일: sample.py 프로젝트: ruspython/pyvko
import vk
import json

APP_ID = "3313789"
SCOPE = "8388607"  # all (sum([2**x for x in range(23)]))
mytoken, user_id = vk.auth(email="email", password="******", client_id=APP_ID, scope=SCOPE)
print("\n", mytoken, user_id)
d = {"user_id": user_id, "count": "14"}
json_obj = json.loads(vk.method_request(token=mytoken, method_name="audio.get", params=d).decode())

print(json_obj["response"])
예제 #11
0
def main():
    # noinspection PyGlobalUndefined
    global access_token, user_id, max_count_post

    while True:
        access_token, user_id = vk.auth('+79123260552', "GiveMeUsaTank1337", "4826374",
                                        'audio,groups,friends,photos,wall,notify,messages,stats,offline')
        if access_token != '':
            break

    init_var()
    #  update_stats()

    while True:

        for group_id, domain in list_groups:
            wall_record = vk_api.wall.get(owner_id=group_id, domain=domain, count='10', access_token=access_token
                                          , v='5.95')
            time.sleep(1)
            if wall_record is None:
                continue
            post = get_most_like_post(wall_record, domain)
            time.sleep(1)
            if post is None:
                continue
            else:
                upload_server = vk_api.photos.getWallUploadServer(group_id=id_owner_group, domain=domain,
                                                                  access_token=access_token, v='5.95')
                time.sleep(1)
                if upload_server is None:
                    continue
                else:
                    photos_path = save_photo_for_post(post)
                    time.sleep(1)
                    attachments = material_for_post(photos_path, upload_server['upload_url'])
                    time.sleep(1)
                    if attachments is '':
                        continue

                    try:
                        posted_id = vk_api.wall.post(owner_id='-' + id_owner_group,
                                                     message=post[1]['text'] + ' |%23баян |%23bayan |%23мемы |%23memes',
                                                     attachments=attachments, from_group='1',
                                                     access_token=access_token,
                                                     v='5.95')['post_id']
                        time.sleep(1)
                    except Exception as e:
                        posted_id = None

                    time_to_last_post = datetime.now()
                    if posted_id is not None:
                        utcnow = datetime.utcnow()
                        session = Session()
                        session.add_all([Post(id_post=now_post_id,
                                              timestamp=utcnow + timedelta(seconds=1),
                                              time=datetime.time(datetime.now()),
                                              id_group=domain),
                                         Hash(hash=now_img_hash,
                                              timestamp=utcnow + timedelta(seconds=1))])
                        session.commit()

                        hash_list.append(Hash(hash=now_img_hash, timestamp=utcnow + timedelta(seconds=1)))

                        """
                        comments = vk_api.wall.getComments(owner_id=str(group_id), post_id=str(post[1]['id']),
                                                           count=str(random.randrange(20, 100)),
                                                           need_likes='1', access_token=access_token, v='5.95')
                        """
                        # поставить лайк под постом
                        for akk in akk_for_comment:
                            todo = random.randint(0, 1)
                            if todo:
                                liked = vk_api.likes.add(owner_id='-' + id_owner_group, item_id=str(posted_id),
                                                         type='post', access_token=akk['token'], v='5.95')
                                print(liked)

                        # if comments is not None:
                        #     structure_comments = build_structure_comments(comments)
                        #     time.sleep(1)
                        #     create_life(structure_comments, str(posted_id), id_owner_group, str(group_id), domain)
                        #     time.sleep(1)

                        time_to_sleep = 60 - ((datetime.now() - time_to_last_post).seconds / 60)

                        print('между постами рекомендуется выдержать время, в среднем ' + str(time_to_sleep) + ' минут')
                        print(datetime.now())
                        if time_to_sleep > 0:
                            time.sleep(time_to_sleep * 60)
예제 #12
0
파일: vkSpy.py 프로젝트: Ademishe/vkSpy
def workingThreadRoutine(uemail, upassword, result):
	resp = get_online_friends(u_id, access_token)
	if resp == None:
		print("token has expired")
		access_token, u_id = vk.auth(uemail, upassword, "3336140", "friends")
		workingThreadRoutine(uemail, upassword, result)
		return
	print("{0} {1}".format(time.strftime("%d-%m-%Y %H:%M:%S", time.localtime()), resp))
	for friend in resp:
		result[friend]['online_time'] += sleepTime
	logChanges(result)
	

email = input("Enter your email:")
password = getpass.getpass()
access_token, u_id = vk.auth(email, password, "3336140", "friends")
print("Authorization is successful!\nAccess token: {0}, user id: {1}".format(access_token, u_id))

user_friends = get_all_friends(u_id, access_token)

result_dict = dict()
for friend in user_friends:
	id = friend['user_id']
	result_dict[id] = dict()
	result_dict[id]['first_name'] = friend['first_name']
	result_dict[id]['last_name'] = friend['last_name']
	result_dict[id]['online_time'] = 0.0
user_friends = None

startTime = time.localtime()
t = RepeatTimer(sleepTime, workingThreadRoutine, email, password, u_id, access_token, result_dict)