Skip to content

Instantly share code, notes, and snippets.

@Sanqui
Created December 6, 2012 22:03
Show Gist options
  • Save Sanqui/4228922 to your computer and use it in GitHub Desktop.
Save Sanqui/4228922 to your computer and use it in GitHub Desktop.
beep
__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