Commits

Jason Moiron  committed 3218001

run as a stand alone module to get an announce string

  • Participants
  • Parent commits fcd65a7

Comments (0)

Files changed (1)

 # 11/28/07 - Started weechat port
 # 07/13/08 - Changed Audacious support to Dbus, added BMPx (v 0.6)
 
+class WeeChat(object):
+    """Fake 'weechat' object.  Can proxy in for printing, etc."""
+    def __nonzero__(self):
+        return False
+    def prnt(self, string):
+        string = string.replace('\00302', '')
+        string = string.replace('\00303', '')
+        string = string.replace('\002', '')
+        string = string.replace('\003', '')
+        print string
+    command=prnt
 
 try:
     import weechat
 except:
-    print "Attempting to be used as normal python module..."
-    weechat = False
+    weechat = WeeChat()
 
 import sys, struct
 import socket, os, pwd
 if weechat:
     weechat.register(__module_name__, __module_version__, '', __module_description__)
     weechat.add_command_handler('mp3', 'dispatch')
+
+# are we '__main__' when we are imported by weechat?  probably not
+if __name__ == '__main__' and not weechat:
+    announce()