Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
5.2 kB
14
Indexable
Never
import os, random, json, re
from PIL import Image
from telethon import TelegramClient, events, sync, types
from telethon.tl.functions.messages import GetRepliesRequest, SetTypingRequest, GetStickerSetRequest, ImportChatInviteRequest
from  telethon.errors.rpcerrorlist import *
from telethon.tl.functions.channels import JoinChannelRequest
from config import api_hash, api_id
from time import sleep
from datetime import datetime
from telethon.tl.functions.messages import GetBotCallbackAnswerRequest, StartBotRequest
from random_username.generate import generate_username

class Telethon:
	def __init__(self, api_id, api_hash):
		self.api_id = api_id
		self.api_hash = api_hash
		self.check_file()
		self.list_group = []
		self.list_phone = []
	def check_file(self):
		if not os.path.exists("session"):
			os.makedirs("session")
			print("Đã tạo tự động thư mục session, vui lòng bỏ tệp <phone>.session vào thư mục session")
			exit()
		if len(os.listdir("session")) == 0:
			print("Bỏ tệp <phone>.session vào thư mục session để chạy tool")
			exit()
	def connect(self):
		self.client = TelegramClient(f"session/{self.phone}", self.api_id, self.api_hash)
		self.client.connect()
		if not self.client.is_user_authorized():
			print(f"Không thể kết nối session - {self.phone}")
			return False, ""
		return True, self.client
	def process_entity(self, group):
		return self.client.get_entity(group) if type(group) == str else group
	def process_error(self, err=False):
		self.client.disconnect()
		return err
	def get_client_count(self):
		count = 0
		for session in os.listdir("session"):
			if session.split(".")[1] != "session":
			 	continue
			else:
			 	count += 1
			 	if session.split(".")[0] not in self.list_phone:
			 		self.list_phone.append(session.split(".")[0])
		return count
	def delete_session(self):
		if os.path.exists("session/%s.session" %self.phone):
			os.system("del session\%s.session" %self.phone)
		if os.path.exists("session/%s.session-journal" %self.phone):
			os.system("del session\%s.session-journal" %self.phone)
	def get_all_group(self, group=False, username=False):
		for x in self.client.get_dialogs():
			 if group and username and x.is_group and "username" in dir(x.entity):
			 	if not x.entity.username:
			 		continue
			 	self.list_group.append(x.entity)
			 elif group and not username and x.is_group:
			 	self.list_group.append(x.entity)
			 elif username and not group and  "username" in dir(x.entity):
			 	self.list_group.append(x.entity)
			 elif not group and username:
			 	self.list_group.append(x.entity)
		return self.list_group
	def cheat(self, bot, ref, group):
		for session in os.listdir("session"):
			sleep(2)
			if session.split(".")[1] != "session":
				continue
			else:
			     try:
			     	self.phone = session.split(".")[0].strip()
			     	print(f"Tài khoản {self.phone}")
			     	connect = self.connect()
			     	if connect[0] == False:
			     		print(f"Không thể kết nối --> {self.phone}")
			     		self.client.disconnect()
			     		continue
			     	for x in group:
			     		self.client(JoinChannelRequest(x))
			     	self.client(StartBotRequest(bot=bot, peer=bot, start_param=ref))
			     	sleep(2)
			     	message = self.client.get_messages(bot, limit=1)[0]
			     	text = message.message
			     	answer = text.split("\n")[2]
			     	self.client.send_message(entity=bot, message=answer)
			     	sleep(2)
			     	self.client.get_messages(bot, limit=1)[0].click(-1)
			     	sleep(2)
			     	username = generate_username(1)[0]
			     	self.client.send_message(entity=bot, message=username+"@gmail.com")
			     	sleep(2)
			     	self.client.send_message(entity=bot, message="https://twitter.com/"+username)
			     	sleep(2)
			     	self.client.send_message(entity=bot, message="Yes")
			     	sleep(2)
			     	self.client.send_message(entity=bot, message=username+"#"+"".join(random.choices("0123456789", k=4)))
			     	sleep(2)
			     	self.client.send_message(entity=bot, message="Skip this task")
			     	sleep(2)
			     	self.client.send_message(entity=bot, message="Yes")
			     	sleep(2)
			     	self.client.send_message(entity=bot, message="https://medium.com/"+username)
			     	sleep(2)
			     	self.client.send_message(entity=bot, message="Yes")
			     	sleep(2)
			     	self.client.send_message(entity=bot, message="Yes")
			     	sleep(2)
			     	vi = open("wallet.txt", "r").read().split("\n")
			     	self.client.send_message(entity=bot, message=vi[0])
			     	vi = vi[1:]
			     	open("wallet.txt", "w")
			     	for x in vi:
			     		open("wallet.txt", "a").write(x+"\n")
			     	sleep(2)
			     	print("Cheat thành công")
			     	self.client.disconnect()
			     	continue
			     except Exception as e:
			     	print("Lỗi", "-", e)
			     	self.client.disconnect()
			     	continue

if __name__ == "__main__":
	telethon = Telethon(api_id, api_hash)
	telethon.cheat("@DeadKnightNewRoundAirdropBot", "730811943", ["https://t.me/DeadKnightMeta_Official", "https://t.me/ICOAnnouncement"])