Jump to content

Procesul de fuziune va fi reluat din pacate. Detalii aici aici
Cele mai noi detalii de dupa fuziune aici

Sign in to follow this  
AIM 0xFrANZ

[PYTHON] Chatlog reader

Recommended Posts

import pyperclip, time, getpass
from os.path import getsize
from pathlib import Path


username = getpass.getuser()
path = Path('C:\\Users\\'+ username + '\\Documents\\GTA San Andreas User Files\\SAMP\\chatlog.txt')



if path.is_file():
    print(path.is_file())
    print(f"Heyy {username}")
else:
    path = input('Chatlog directory path > ')


cuv_cap = {

     'virgin' : 'me',
     'Romania' : 'Bucuresti',
     'gay' : 'user88',
     'BMW' : 'i8',
     'ugbase' : 'nothin'

    }
custom_pref = input('custom prefix[blank = no prefix]: ')


def chatEntry(custom_pref):
   
    if not custom_pref or custom_pref in ['no', 'nu', 'n'] :
        return None
    elif custom_pref:
        return custom_pref

chatEntry(custom_pref)


def read_lines(path):
    if getsize(path) > 0:
        with open(path, 'r+') as chatlog:
            for line in chatlog:
                for cuv, cap in cuv_cap.items():
                    if cuv in line:
                        print(f"Key: [{cuv}] Value: [{cap}] --> PRINT{[cap]}")
                        print(line)
                       
                        pyperclip.copy(chatEntry(custom_pref) + " " + cap)
                        pyperclip.paste()
                        chatlog.truncate(0)
                   

                    if cap in line:
                        print(f"Value: [{cap}] Key: [{cuv}] --> PRINT{[cuv]}")
                        print(line)

                        pyperclip.copy(chatEntry(custom_pref) + " " + cuv)
                        pyperclip.paste()
                        chatlog.truncate(0)



while True:
    try:
        read_lines(path)
    except PermissionError:
        pass
    except FileNotFoundError:
        raise Exception("PathError: Path(chatlog.txt) is WRONG")
    time.sleep(0.2)

Un simplu mod care iti citeste chatlog-ul si iti seteaza cuvantul in clipboard cand il gaseste in chat

merci @monday pentru niste optimizari

Share this post


Link to post
Share on other sites

Aolo franzelo, ce limbaj ti-ai gasit si tu sa faci programu asta, desi e unul relativ cautat, nu mi-a placut niciodata din simplul fapt ca nu pot sa-mi fac damblaua sa-mi pun paranteze, acuolade si punct si virgula =)), mna obisnuinta...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.