Skip to content

Instantly share code, notes, and snippets.

@ask-compu
Last active January 16, 2016 00:21
Show Gist options
  • Save ask-compu/6359e22b9c9be7683161 to your computer and use it in GitHub Desktop.
Save ask-compu/6359e22b9c9be7683161 to your computer and use it in GitHub Desktop.
__module_name__ = 'flashlight.py'
__module_version__ = '0.0.0'
__module_description__ = 'Flash lights on notify'
__module_author__ = 'Compu'
print '\0034',__module_name__, __module_version__,'has been loaded\003'
import sys
sys.path.append("/home/compu/.config/hexchat/addons")
import lightify
import hexchat
import time
import logging
import thread
MODULE = "__main__"
def main():
logging.basicConfig()
logger = logging.getLogger(MODULE)
logger.setLevel(logging.CRITICAL)
#logger.addHandler(logging.StreamHandler())
liblogger = logging.getLogger('lightify')
#liblogger.addHandler(logging.StreamHandler())
liblogger.setLevel(logging.CRITICAL)
logger.info("Logging %s", MODULE)
conn = lightify.Lightify("192.168.1.149")
conn.update_all_light_status()
conn.update_group_list()
for (name, group) in conn.groups().iteritems():
logger.info("group: %s %s", name, group)
#print "keys:%s" % conn.groups().keys()
desk = conn.groups()["DJs Room"]
djlight = conn.light_byname("DJs Room")
djison = djlight.on()
if djison == 1:
desk.set_onoff(0)
time.sleep(0.25)
desk.set_onoff(1)
time.sleep(0.5)
desk.set_onoff(0)
time.sleep(0.25)
desk.set_onoff(1)
else:
desk.set_onoff(1)
time.sleep(0.25)
desk.set_onoff(0)
time.sleep(0.5)
desk.set_onoff(1)
time.sleep(0.25)
desk.set_onoff(0)
return hexchat.EAT_NONE
def threadstart(word, word_eol, user_data):
thread.start_new_thread(main, ())
hexchat.hook_print("Channel Action Hilight", threadstart)
hexchat.hook_print("Channel Msg Hilight", threadstart)
hexchat.hook_print("DCC CHAT Offer", threadstart)
hexchat.hook_print("DCC Generic Offer", threadstart)
hexchat.hook_print("DCC Offer", threadstart)
hexchat.hook_print("Private Action", threadstart)
hexchat.hook_print("Private Message", threadstart)
hexchat.hook_print("Private Action to Dialog", threadstart)
hexchat.hook_print("Private Message to Dialog", threadstart)
hexchat.hook_print("Server Error", threadstart)
hexchat.hook_command('lightifytest', threadstart)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment