Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telethon
- from telethon import TelegramClient, sync, functions
- from telethon.tl.functions.messages import GetHistoryRequest
- from telethon.tl.functions.channels import JoinChannelRequest
- import gspread
- from oauth2client.service_account import ServiceAccountCredentials
- import socks
- import glob
- import time
- scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
- creds = ServiceAccountCredentials.from_json_keyfile_name("CHeatproject-890ddda2e266.json", scope)
- client = gspread.authorize(creds)
- sheet = client.open("cheat").sheet1
- channels = []
- for i in range(sheet.row_count):
- if sheet.cell(i + 1, 1).value != '':
- channels.append([sheet.cell(i + 1, 1).value,
- sheet.cell(i + 1, 2).value,
- sheet.cell(i + 1, 3).value,
- 0])
- else:
- break
- api_id = open('app_id_and_hash.dat').read().splitlines()[0]
- api_hash = open('app_id_and_hash.dat').read().splitlines()[1]
- post_id = 0
- class Channel:
- def __init__(self, channel):
- self.channel = channel
- self.channel_name = self.channel[0]
- self.id_last_message = self.channel[3]
- while True:
- for k in glob.glob("sessions/*.session"):
- tg_client = TelegramClient(k, api_id, api_hash,
- ) # proxy=(socks.SOCKS5, "37.1.218.213", 10051)
- tg_client.start()
- for channel in channels:
- try:
- Class_of_channel = Channel(channel)
- print(Class_of_channel.posts)
- tg_client(JoinChannelRequest(Class_of_channel.channel_name))
- entity = tg_client.get_entity(Class_of_channel.channel_name)
- peer = telethon.utils.get_input_peer(entity)
- posts = tg_client(GetHistoryRequest(
- peer=entity,
- limit=1,
- offset_date=None,
- offset_id=0,
- max_id=0,
- min_id=0,
- add_offset=0,
- hash=0))
- if Class_of_channel.id_last_message != posts.messages[0].id:
- post_id = posts.messages[0].id
- Class_of_channel.id_last_message = posts.messages[0].id
- result = tg_client(functions.messages.GetMessagesViewsRequest(
- peer=peer,
- id=[post_id],
- increment=True))
- tg_client.disconnect()
- print(result[0])
- else:
- continue
- except:
- continue
- time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement