示例#1
0
async def v(client, channel, msg_id):

    msg = await client.get_messages(channel, ids=msg_id)

    answers = msg.media.poll.answers

    w = 2

    for z in range(1, len(answers) + 1):

        for y in range(int(target[str(z)] * target['row'] * 0.01)):

            clients = TelegramClient(str(w), api_id, api_hash)

            await clients.start()

            await clients(
                SendVoteRequest(peer=channel,
                                msg_id=msg_id,
                                options=[msg.media.poll.answers[z - 1].option])
            )

            await client.disconnect()

            w += 1

            print('🌚')

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {'$set': {
                    'status': 'Complete'
                }})
示例#2
0
async def v_c(channel):

    messages_id = []

    for s in range(1, 10):

        messages_id.append(s)

    if ('joinchat' in channel) and ('https' in channel):

        channel = channel[22:]

    elif ('joinchat' in channel) and (not 'https' in channel):

        channel = channel[14:]

    elif '@' in channel:

        channel = channel[1:]

    try:

        await client(
            GetMessagesViewsRequest(peer=channel,
                                    id=messages_id,
                                    increment=True))

    except telethon.errors.rpcerrorlist.ChannelPrivateError:

        coll_targets.update_one({
            '#': target['#'],
            'owner': target['owner']
        }, {'$set': {
            'additional': 'Канал является приватным'
        }})
    except (telethon.errors.rpcerrorlist.ChatIdInvalidError, ValueError):

        coll_targets.update_one({
            '#': target['#'],
            'owner': target['owner']
        }, {'$set': {
            'additional': 'Канал недействителен'
        }})
    except telethon.errors.rpcerrorlist.PeerIdInvalidError:

        pass

    print('👍')
示例#3
0
async def v_p(channel, msg_id):

    try:

        await client(
            GetMessagesViewsRequest(peer=channel, id=[msg_id], increment=True))

    except telethon.errors.rpcerrorlist.ChannelPrivateError:

        coll_targets.update_one({
            '#': target['#'],
            'owner': target['owner']
        }, {'$set': {
            'additional': 'Канал является приватным'
        }})
    except (telethon.errors.rpcerrorlist.ChatIdInvalidError,
            telethon.errors.rpcerrorlist.PeerIdInvalidError, ValueError):

        coll_targets.update_one({
            '#': target['#'],
            'owner': target['owner']
        }, {
            '$set': {
                'additional': 'Пересланный пост является недействительным'
            }
        })

    coll_targets.update_one({
        '#': target['#'],
        'owner': target['owner']
    }, {'$set': {
        'status': 'Complete'
    }})
    print('👌')
示例#4
0
async def s(channel):

    #   channel = await client.get_input_entity(chat)

    if ('joinchat' in channel) and ('https' in channel):

        channel = channel[22:]

        try:

            await client(ImportChatInviteRequest(channel))

        except (telethon.errors.rpcerrorlist.UserAlreadyParticipantError,
                telethon.errors.rpcerrorlist.ChannelsTooMuchError):

            pass

        except telethon.errors.rpcerrorlist.InviteHashEmptyError:

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {'$set': {
                    'additional': 'Ссылка недействительна'
                }})

        except telethon.errors.rpcerrorlist.InviteHashExpiredError:

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {'$set': {
                    'additional': 'Срок действия ссылки истёк'
                }})

        except telethon.errors.rpcerrorlist.UsersTooMuchError:

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {
                    '$set': {
                        'additional':
                        'Количество участников группы достигнуто максимума'
                    }
                })

    elif ('joinchat' in channel) and (not 'https' in channel):

        channel = channel[14:]

        try:

            await client(ImportChatInviteRequest(channel))

        except (telethon.errors.rpcerrorlist.UserAlreadyParticipantError,
                telethon.errors.rpcerrorlist.ChannelsTooMuchError):

            pass

        except (telethon.errors.rpcerrorlist.InviteHashEmptyError, ValueError):

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {'$set': {
                    'additional': 'Ссылка недействительна'
                }})

        except telethon.errors.rpcerrorlist.InviteHashExpiredError:

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {'$set': {
                    'additional': 'Срок действия ссылки истёк'
                }})

        except telethon.errors.rpcerrorlist.UsersTooMuchError:

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {
                    '$set': {
                        'additional':
                        'Количество участников группы достигнуто максимума'
                    }
                })

    elif '@' in channel:

        channel = channel[1:]

        try:

            await client(JoinChannelRequest(channel))

        except telethon.errors.rpcerrorlist.ChannelsTooMuchError:

            pass

        except (telethon.errors.rpcerrorlist.ChannelInvalidError, ValueError):

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {
                    '$set': {
                        'additional': 'Ссылка на канал/чат недействительна'
                    }
                })

    else:

        try:

            await client(JoinChannelRequest(channel))

        except telethon.errors.rpcerrorlist.ChannelsTooMuchError:

            pass

        except (telethon.errors.rpcerrorlist.ChannelInvalidError, ValueError):

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {
                    '$set': {
                        'additional': 'Ссылка на канал/чат недействительна'
                    }
                })

    coll_targets.update_one({
        '#': target['#'],
        'owner': target['owner']
    }, {'$set': {
        'status': 'Complete'
    }})

    print('😌')
示例#5
0
                loop.run_until_complete(v_c(target['channel']))
                client.disconnect()

            else:  #пишем по сплошным целям

                for x in range(1, target['row'] + 1):
                    client = TelegramClient(str(x), api_id, api_hash)
                    client.start()
                    loop.run_until_complete(v_c(target['channel']))
                    client.disconnect()

            coll_targets.update_one(
                {
                    '#': target['#'],
                    'owner': target['owner']
                }, {'$set': {
                    'status': 'Complete'
                }})

            coll_to_do.delete_one({'date': target['date']})

        elif target['type'] == 'vote':

            try:

                target['row']

            except (KeyError, TypeError):  #пишем по сессиям

                client = TelegramClient(target['session'], api_id, api_hash)