Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.