import os  
import time  
import platform  
from telethon.sync import TelegramClient  
from telethon.tl import types  
from telethon import functions  
from prettytable import PrettyTable  
  
# Color codes  
rd, gn, lgn, yw, lrd, be, pe = '\033[00;31m', '\033[00;32m', '\033[01;32m', '\033[01;33m', '\033[01;31m', '\033[94m', '\033[01;35m'  
cn, k, g = '\033[00;36m', '\033[90m', '\033[38;5;130m'  
  
def clear():  
   if 'Windows' in platform.uname():  
      os.system("cls")  
   else:  
      os.system("clear")  
  
def re(text):  
   for char in text:  
      print(char, end='', flush=True)  
      time.sleep(0.001)  
  
def get_api_credentials():  
   api_id = input(f"{lrd}[{lgn}+{lrd}] {gn}Enter Api id account: {g}")  
   api_hash = input(f"{lrd}[{lgn}+{lrd}] {gn}Enter Api hash account: {g}")  
   phone_number = input(f"{lrd}[{lgn}+{lrd}] {gn}Enter phone account:{g} ")  
   return api_id, api_hash, phone_number  
  
def get_channel_info():  
   channel_username = input(f"{lrd}[{lgn}+{lrd}] {gn}Enter username channel {k}")  
   number = input(f"{lrd}[{lgn}+{lrd}] {gn}Number of reports: {k}")  
   return channel_username, number  
  
def report_channel(client, channel_entity, reason, message, number):  
   for _ in range(int(number)):  
      try:  
        result = client(functions.messages.ReportRequest(  
           peer=channel_entity,  
           id=[42],  
           reason=reason,  
           message=message  
        ))  
        print(f"{lrd}[{lgn}+{lrd}] {gn}A report has been sent")  
      except Exception as e:  
        print(f"{lrd}[{lgn}+{lrd}] {gn}Error sending report: {e}")  
        break  
  
def main():  
   clear()  
   re(f"""{g}  
  _____    __    _  _________    ____    
 (_  _)   /  \   / ) (_  _____)  / __ \    
  | |    / /\ \  / /   ) (___    / /  \ \   
  | |    ) ) ) ) ) )  (  ___)  ( ()  () )  
  | |   ( ( ( ( ( (    ) (     ( ()  () )  
  _| |__  / /  \ \/ /   (  )     \ \__/ /   
 /_____( (_/   \__/    \_/      \____/  
""")  
  
   api_id, api_hash, phone_number = get_api_credentials()  
   client = TelegramClient('session', api_id, api_hash)  
  
   clear()  
   account = f"""{k}  
 ____                    _            
|  _ \  ___  _ __   ___  _ __ | |_  ___  _ __  
| |_) | / _ \| '_ \  / _ \ | '__|| __| / _ \| '__|  
|  _ < |  __/| |_) || (_) || |  | |_ |  __/| |   {cn}Channel{k}  
|_| \_\ \___|| .__/  \___/ |_|   \__| \___||_|    
         |_|	  
  
	{lrd}[{lgn}+{lrd}] {gn}Channel : {lgn}@Esfelurm	  
			"""  
   re(account)  
  
   print(f"{lrd}")  
   t = PrettyTable([f'{cn}Number{lrd}', f'{cn}Method{lrd}'])  
   t.add_row([f'{lgn}1{lrd}', f'{gn}Report Spam{lrd}'])  
   t.add_row([f'{lgn}2{lrd}', f'{gn}Reporter Other{lrd}'])  
   t.add_row([f'{lgn}3{lrd}', f'{gn}Reporter Violence{lrd}'])  
   t.add_row([f'{lgn}4{lrd}', f'{gn}Reporter Pornography{lrd}'])  
   t.add_row([f'{lgn}5{lrd}', f'{gn}Reporter Copyright{lrd}'])  
   t.add_row([f'{lgn}6{lrd}', f'{gn}Reporter Fake{lrd}'])  
   t.add_row([f'{lgn}7{lrd}', f'{gn}Reporter Geo Irrelevant{lrd}'])  
   t.add_row([f'{lgn}8{lrd}', f'{gn}Reporter Illegal Drugs{lrd}'])  
   t.add_row([f'{lgn}9{lrd}', f'{gn}Reporter Personal Details{lrd}'])  
   print(t)  
  
   method = input(f"{lrd}[{lgn}?{lrd}] {gn}Choose a method : {k}")  
   channel_username, number = get_channel_info()  
  
   with client as client:  
      client.connect()  
      if not client.is_user_authorized():  
        client.send_code_request(phone_number)  
        client.sign_in(phone_number, input('Enter the code: '))  
      try:  
        channel_entity = client.get_entity(channel_username)  
      except Exception as e:  
        print(f"{lrd}Username does not exist: {e}")  
        return  
  
      if method == "1":  
        report_channel(client, channel_entity, types.InputReportReasonSpam(), "This channel contains spam content.", number)  
      elif method == "2":  
        message = input(f"{lrd}[{lgn}+{lrd}] {gn}Enter your message: {g}")  
        report_channel(client, channel_entity, types.InputReportReasonOther(), message, number)  
      elif method == "3":  
        report_channel(client, channel_entity, types.InputReportReasonViolence(), "This channel contains violent content.", number)  
      elif method == "4":  
        report_channel(client, channel_entity, types.InputReportReasonPornography(), "This channel has pornographic content", number)  
      elif method == "5":  
        report_channel(client, channel_entity, types.InputReportReasonCopyright(), "Block this channel due to copyright", number)  
      elif method == "6":  
        report_channel(client, channel_entity, types.InputReportReasonFake(), "Block this channel due to scam and impersonation", number)  
      elif method == "7":  
        report_channel(client, channel_entity, types.InputReportReasonGeoIrrelevant(), "Block this channel due to irrelevant geo", number)  
      elif method == "8":  
        report_channel(client, channel_entity, types.InputReportReasonIllegalDrugs(), "Block this channel because of IllegalDrugs", number)  
      elif method == "9":  
        report_channel(client, channel_entity, types.InputReportReasonPersonalDetails(), "Block this channel because of PersonalDetails", number)  
  
      print(f"\n\n{k}End of reports !")  
  
if __name__ == "__main__":  
   try:  
      main()  
   except Exception as e:  
      print(f"{lrd}[{lgn}+{lrd}] {gn}An error occurred: {e}")
