I have just recently started coding in python and found myself overwhelmed when it came to creating this script.
So, I have a chatlog.txt file that is constantly being updated and I want to make it so that whenever a new line that contains "Apple" (for example) appears, something happens (ex. print("Green")). Of course, this would be a loop and the exit conditions would be when "Apple" has appeared five times.
chatlog.txt
Adam received a pear
Adam received a pear
Adam received a tomato # This is the chatlog.txt file when it is first opened
Adam received an orange
Adam received a banana
All of the lines when the chatlog.txt file should be ignored and only the ones that come them should be taken into account.
A̶d̶a̶m̶ ̶r̶e̶c̶e̶i̶v̶e̶d̶ ̶a̶ ̶p̶e̶a̶r̶
A̶d̶a̶m̶ ̶r̶e̶c̶e̶i̶v̶e̶d̶ ̶a̶ ̶p̶e̶a̶r̶
A̶d̶a̶m̶ ̶r̶e̶c̶e̶i̶v̶e̶d̶ ̶a̶ ̶t̶o̶m̶a̶t̶o̶
A̶d̶a̶m̶ ̶r̶e̶c̶e̶i̶v̶e̶d̶ ̶a̶n̶ ̶o̶r̶a̶n̶g̶e̶
A̶d̶a̶m̶ ̶r̶e̶c̶e̶i̶v̶e̶d̶ ̶a̶ ̶b̶a̶n̶a̶n̶a̶
**Adam received an apple** -> This triggers Messages()
Messages
```python
import pyautogui as sendstuff
def Messages():
sendstuff.press("enter")
sendstuff.typewrite("That is a nice apple!")
sendstuff.press("enter")
```
How do I do this?