def output(message,chatroom='A'): print('said --> [%s] %s'%(chatroom, message)) text = "CHAT:" if chatroom == 'C': text += message elif 'rivatein' in chatroom: text += '/w ' + database.get_setting('lastwhisper') + ' ' + message else: text += "/a " + message connect.poll((text,),True) return True
def whisper(message, target = None): if not target: target = database.get_setting('lastwhisper') print 'whispered ---> [' + target + ']' + message return connect.poll(("CHAT:/w " + target + ' ' + message,),True)
def check(): r = connect.poll(("CHAT:",),True) try: r[1] except (IndexError, TypeError): return False types = {'@C': '[C]', 'privatein': '[P]', '@A': '[A]'} for msg in r[1]['D']: try: print '[msg] %15s %s -- %s'%(msg['s'][1:], types.get(msg['c'],'[?]'), msg['m']) except TypeError: print 'Type Error:', msg process(msg) return True