Log in

View Full Version : Python script to pull online status.



Spectrus
05-17-2012, 10:12 AM
I was bored. Pulls online status of all chars in names list. I'll be using this to write the online status of my chars to a file so that I can have conky (Linux equivalent to Rainmeter) pull the information from the file and display it on my desktop. If anyone else finds a use for it, that's great!



import urllib.request

url = 'http://www.tibia.com/community/?subtopic=characters&name='
names = ['Raedys','Sairu']

for name in names :
response = urllib.request.urlopen(url+name)
text = response.read().decode("utf-8")
if name and "CLASS=green" in text : #"CLASS=green" is only used on online status
print(name +": online")
else :
print(name +": offline")


There are some pretty glaring bugs in it. For instance, I'm not sure how it will handle names with 2 words, also if they are online on a different character it will show as online, also if their character is hidden, it will show as offline. Doesn't matter for any of my chars so I won't fix it for now.

Elvang
05-17-2012, 01:58 PM
Make it check the world list for the player name to check if they are online.



import urllib.request

world = 'solera'
url = 'http://www.tibia.com/community/?subtopic=worlds&world=' + world
names = ['name1','name2']

for name in names :
response = urllib.request.urlopen(url)
text = response.read().decode("utf-8")
if name in text :
print(name +": online")
else :
print(name +": offline")


Not sure if it will work since I don't know the syntax for programming in python, and the name appears twice in the source.

Spectrus
05-17-2012, 06:42 PM
Yeah, I already did this after I posted it but for some reason I couldn't edit on my laptop yesterday. :/

I'll tweak it a little later.

rellikpoc
05-22-2012, 02:25 AM
Any way to input into a free text message website or attach to an email and send to me when X player logs in or out?

Elvang
05-22-2012, 04:19 AM
You can check my other post rellikpoc