/ work.py
work.py
1 import lama2923 as l2 # 2.0.4 2 import time 3 from datetime import datetime 4 import re 5 import csv 6 import os 7 8 channel_id = '1223583388401930270' # Kanal ID | Casico 3 9 token = r"TOKEN" 10 SikimSonikBotv2 = 1223048169764683828 11 UnbelievaBoat = 292953664492929025 12 Discord = False 13 14 while not Discord: 15 try: 16 Discord = l2.Discord.Author(token) 17 except Exception as e: 18 print(f"[work.py] {e}") 19 time.sleep(10) 20 21 Author_id = int(Discord.get_author_info()[1]["id"]) 22 23 log_file = "log.csv" 24 log_headers = ["Date", "Method", "Status Code", "Money/Error"] 25 26 if not os.path.exists(log_file): 27 with open(log_file, mode="w", encoding="utf-8", newline="") as f: 28 writer = csv.writer(f) 29 writer.writerow(log_headers) 30 31 32 class Send: 33 def __init__(self): 34 self.data = self.send_commands() 35 self.log() 36 37 def send_commands(self): 38 try: 39 status1, money1 = CommandSender.çalış() 40 status2, money2 = CommandSender.work() 41 return {"çalış": (status1, money1), "work": (status2, money2)} 42 except Exception as e: 43 return {"çalış": ("ERROR", str(e)), "work": ("ERROR", str(e))} 44 45 def log(self): 46 with open(log_file, mode="a", encoding="utf-8", newline="") as f: 47 writer = csv.writer(f) 48 for key, value in self.data.items(): 49 date = datetime.now().strftime('%Y-%m-%d %H:%M:%S') 50 status = value[0] 51 money = value[1] if value[1] else "Bot Reply Not Found" 52 writer.writerow([date, key, status, money]) 53 print(f"{date} | {key.ljust(5)} | {str(status).ljust(3)} | {str(money)}") 54 55 class CommandSender: 56 57 @staticmethod 58 def çalış(): 59 status = Discord.send_message(channel_id, "/çalış") 60 time.sleep(0.5) 61 messages = Discord.get_channel_messages(channel_id)[1] 62 63 for message in messages: 64 try: 65 if int(message["author"]["id"]) == Author_id: 66 return status, False 67 68 if not int(message["author"]["id"]) == SikimSonikBotv2: 69 continue 70 71 embed = message.get("embeds", []) 72 if embed and isinstance(embed, list) and "footer" in embed[0]: 73 footer = embed[0].get("footer", {}) 74 text = footer.get("text", "") 75 search = re.search(r"([\d.,]+)", text) 76 if search: 77 return status, search.group() 78 except (KeyError, TypeError, IndexError) as e: 79 return status, f"JSON Parse Error: {e}" 80 81 return status, False 82 83 @staticmethod 84 def work(): 85 status = Discord.send_message(channel_id, "/work") 86 time.sleep(0.5) 87 messages = Discord.get_channel_messages(channel_id)[1] 88 89 for message in messages: 90 try: 91 if int(message["author"]["id"]) == Author_id: 92 return status, False 93 94 if not int(message["author"]["id"]) == UnbelievaBoat: 95 continue 96 97 embed = message.get("embeds", []) 98 if embed and isinstance(embed, list) and "description" in embed[0]: 99 description = embed[0].get("description", "") 100 search = re.search(r'💰(\d+)', description) 101 if search: 102 return status, str(search.group())[1:] 103 except (KeyError, TypeError, IndexError) as e: 104 return status, f"JSON Parse Error: {e}" 105 106 return status, False 107 108 109 while True: 110 # 30 dk LOOP 111 try: 112 if l2.check_internet(): 113 Send() 114 time.sleep(1800) # 1800 saniye = 30 dk 115 except Exception as e: 116 error_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') 117 print(f"{error_time} | ERROR | {e}") 118 with open(log_file, mode="a", encoding="utf-8", newline="") as f: 119 writer = csv.writer(f) 120 writer.writerow([error_time, "GENERAL ERROR", "ERROR", str(e)]) 121 time.sleep(10)