boralyl avatar boralyl committed a5ed75a

Add a # to the channel name if it doesn't exist.

Comments (0)

Files changed (1)

pidgin_irc_notifications/plugin.py

     """
     
     def __init__(self, args):
-        self.channels = args.channels
+        self.add_channels(args.channels)
         self.verbose = args.verbose
         
         bus = dbus.SessionBus()
             "/im/pidgin/purple/PurpleObject")
         self.purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
 
+    def add_channels(self, channels):
+        """
+        Prefixes each channel with a # if it doesn't have one then sets the var
+        """
+        self.channels = [add_hash(c) for c in channels]
+
     def received_chat_msg_callback(self, account, sender, message, conversation, flags):
         """
         Creates a notification for IRC channel message if in one of the
     parser.add_argument("-v", "--verbose", dest="verbose",
         action="store_true", default=False, help="Enables verbose mode.")
     return parser.parse_args()
-        
+
+
+def add_hash(name):
+    """
+    Adds the hash to the name if it doesn't start with one
+    """
+    if not name.startswith('#'):
+        name = '#' + name
+    return name
+
 
 def main():
     """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.