Commits

Anonymous committed cb2c4c8

only greet a person once.

Comments (0)

Files changed (1)

 
 writers = []
 
+def greet(irc, nick, wait):
+    """Write a greeting message"""
+    irc.reply("Hi "+nick+", welcome to #freenet! If you have a question, please ask it. People here are volunteers, so they may take several minutes to answer. ")
+    irc.reply("I am the welcome bot. I write if it’s quiet for "+str(wait)+"s after a webuser joins. ")
+
 class SupportBot(callbacks.Plugin):
     """The SupportBot welcomes new users who say something after 30s, if no other user wrote after the new user. It’s main goal is to tell the user that a real user should drop by soon.
     Just ignore it: It will work on its own."""
           self.__parent.__init__(irc)
           self.watchnicks = ["qwebirc"]
           self.wait = 30
-          self.togreet = {}
-
-    def greet(self, irc, nick):
-        """Write a greeting message"""
-        irc.reply("Hi "+nick+", welcome to #freenet! If you have a question, please ask it. People here are volunteers, so they may take several minutes to answer. ")
-        irc.reply("I am the welcome bot. I write if it’s quiet for "+str(self.wait)+"s after a webuser joins. ")
 
     def doJoin(self, irc, msg):
         """Check if the user needs to be greeted."""
         if not True in (msg.nick.startswith(nick) for nick in self.watchnicks):
             return
         channels = msg.args[0].split(',')
+        # only greet a person once.
+        if msg.nick in writers:
+            return
+
         writers.append(msg.nick)
         t = Timer(self.wait, self.conditionalMessage, [irc, msg])
         t.start()
                        in writers[writers.index(msg.nick):]]
         otherwriters = True in writernotme
         if not otherwriters:
-            self.greet(irc, msg.nick)
+            greet(irc, msg.nick, self.wait)
             # slice writers
         else:
             print "someone posted within", self.wait, "seconds. No need to greet.", writers[writers.index(msg.nick):], "writernotme", writernotme, "otherwriters?", otherwriters