Created
December 6, 2012 22:03
-
-
Save Sanqui/4228922 to your computer and use it in GitHub Desktop.
beep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__module_name__ = "beep" | |
__module_version__ = "0.1.1" | |
__module_description__ = "Beeps for channel messages" | |
import xchat | |
import os | |
print "Beep loaded!" | |
# http://www.phy.mtu.edu/~suits/notefreqs.html | |
# From C4 to C6 | |
note_freqs = [261, 293, 329, 349, 392, 440, 493, 523, 587, 659, 698, 783, 880, 987, 1046] | |
channels = "#chan1 #chan2".split() | |
bonuschans = "#rarechan".split() | |
def privmsg(word, word_eol, userdata): | |
name = word[0] | |
channel = word[2] | |
message = word_eol[3] | |
freq = None | |
if channel in channels: | |
freq = note_freqs[channels.index(channel)%len(note_freqs)] | |
elif channel in bonuschans: | |
freq = note_freqs[-1] | |
if freq: | |
os.system('beep -f {0} -l {1} &'.format(freq, len(message)*3)) | |
xchat.hook_server("PRIVMSG", privmsg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment