Skip to content

Instantly share code, notes, and snippets.

@TobiasWooldridge
Created June 18, 2014 14:20
Show Gist options
  • Save TobiasWooldridge/a5ee469c05536a3f27ef to your computer and use it in GitHub Desktop.
Save TobiasWooldridge/a5ee469c05536a3f27ef 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