A library that focuses on monitoring EVE Online chat logs for messages and doing nothing else. It is meant to be focused and lightweight.
Python 3.3.x Python 3.4.x
pip install py-eve-chat-mon
import time
from py_eve_chat_mon.monitor import Monitor
def handler(chat, messages):
print(chat)
for msg in messages:
print(msg)
if __name__ == "__main__":
monitor = Monitor(['Alliance', 'Corp'],
"C:\\Users\\YourName\\Documents\\EVE\\logs\\Chatlogs\\",
handler)
monitor.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
monitor.stop()
exit()
monitor = Monitor(chats, path, handler, poll_rate=2)
monitor = Monitor(['Alliance', 'Corp'],
"C:\\Users\\YourName\\Documents\\EVE\\logs\\Chatlogs\\",
handler,
5)
The monitor initializer takes in four arguments:
chats
- Alist
of case sensitivestr
chats that should be monitoredpath
- Astr
path to the EVE chat log directory (The default is in the current user's documents folder)handler
- A callable handler (i.e. a function or any other object that supports the call attribute) that accepts two argumentschat
- Thestr
name of the chat that received a messagemessages
- An array ofdict
representing the chat messagespoll_rate
- An optionalint
that represents the seconds to wait between polling intervals on the chat logs. A higher values reduces the responsiveness but lightens the load on the local machines disk I/O
The messages
array contains message dictionaries that have the following attributes:
timestamp
- Adatetime
object representing the game time when the message was receivedmessage
- Astr
representing the message portion of the chat log (i.e. just the text the user typed)line
- Astr
representing the entire chat log line (including un-parsed timestamp, username, etc.username
- Astr
representing the username of the user who sent the messagehash
- Anstr
that uniquely identified this string.
monitor.start()
The monitor starts its own polling thread as a daemon (meaning it will stay running as long as the main thread is running). It can be stopped by calling monitor.stop()
and restarted again by monitor.start()
.
It is worth noting that Eve's chat logs are in UTF-16. As such messages and text in there can cause issues if you are attempting to print it out to the console in Windows and there happens to be characters outside the consoles supported code points (Unicode charmap errors). You can get around this a little bit by setting the code page in the console to UTF-8 support (run chcp 65001
), but it isn't perfect.
Yes polling. The initial implementation attempted to use watchdog
to receive file update events. However, besides the initial creation of the log files, no events are fired in a timely fashion.
I wrote this as a basis of another project. However I have thought of some other things that this could be used for:
- Watch for keywords (mentions) and provide toast/growl notifications
- Accumulate chat frequency statistics
- Stream chat to a central server (away-from-eve reading)
Unit tests are run on every commit via Travis-CI