Skip to content

Instantly share code, notes, and snippets.

@TobiasWooldridge
Created June 18, 2014 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TobiasWooldridge/54da2b95c9f6b33171c3 to your computer and use it in GitHub Desktop.
Save TobiasWooldridge/54da2b95c9f6b33171c3 to your computer and use it in GitHub Desktop.
from Uni import *
import time
servers = CSEM.loadServers(["lofty"])
def notify(title, subtitle, message):
sh.Command("terminal-notifier")("-title", title, "-subtitle", subtitle, "-message", message)
# Get all users on every server
activeUsers = {}
while True:
users = CSEM.getUsers(servers)
newActiveUsers = {}
for user in users.values():
newActiveUsers[user.fan] = user
for fan, user in newActiveUsers.iteritems():
if not activeUsers.has_key(fan):
notify("CSEM", "+" + user.name, "%s logged in to lofty" % fan)
for fan, user in activeUsers.iteritems():
if not newActiveUsers.has_key(fan):
notify("CSEM", "-" + user.name, "%s logged out of lofty" % fan)
activeUsers = newActiveUsers
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment