Ejemplo n.º 1
0
    def do_command(self, e, cmd):
        nick = nm_to_n(e.source())
        c = self.connection

        if cmd == "disconnect":
            self.disconnect()
        elif cmd == "die":
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(nick, "--- Channel statistics ---")
                c.notice(nick, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(nick, "Users: " + string.join(users, ", "))
                opers = chobj.opers()
                opers.sort()
                c.notice(nick, "Opers: " + string.join(opers, ", "))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(nick, "Voiced: " + string.join(voiced, ", "))
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp("DCC", nick, "CHAT chat %s %d" % (
                ip_quad_to_numstr(dcc.localaddress),
                dcc.localport))
        else:
            c.notice(nick, "Not understood: " + cmd)
Ejemplo n.º 2
0
    def do_command(self, e, cmd):
        nick = nm_to_n(e.source())
        c = self.connection

        if cmd == "disconnect":
            self.disconnect()
        elif cmd == "die":
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(nick, "--- Channel statistics ---")
                c.notice(nick, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(nick, "Users: " + ", ".join(users))
                opers = chobj.opers()
                opers.sort()
                c.notice(nick, "Opers: " + ", ".join(opers))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(nick, "Voiced: " + ", ".join(voiced))
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp(
                "DCC", nick, "CHAT chat %s %d" %
                (ip_quad_to_numstr(dcc.localaddress), dcc.localport))
        else:
            c.notice(nick, "Not understood: " + cmd)
Ejemplo n.º 3
0
    def do_command(self, e, cmd):
        nick = nm_to_n(e.source())
        c = self.connection

        if cmd == "disconnect":
            c.part(canal, "You murder me !")
            self.disconnect()
        elif cmd == "die":
            c.part(canal, "You murder me !")
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(self.channel, "--- Channel statistics ---")
                c.notice(self.channel, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(self.channel, "Users: " + ", ".join(users))
                opers = chobj.opers()
                opers.sort()
                c.notice(self.channel, "Opers: " + ", ".join(opers))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(self.channel, "Voiced: " + ", ".join(voiced))
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp("DCC", self.channel, "CHAT chat %s %d" % (
                ip_quad_to_numstr(dcc.localaddress),
                dcc.localport))
        elif cmd == "hl":
            for chname, chobj in self.channels.items():
                users = chobj.users()
                users.sort()
                c.privmsg(self.channel, "Highlight : " + ", ".join(users))
        else:
            c.notice(self.channel, "Not understood: " + cmd)
Ejemplo n.º 4
0
 def send_dcc_auth(self, nickname):
     self.send_notice(nickname, "Please accept the DCC chat request to authenticate your IP for the admin web interface.")
     
     print "[httpd_on_auth_request] Attempting to get external IP address..."
     try:
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         s.connect(("whatsmyip.co.za",80))
         s.settimeout(1)
         external_ip = s.getsockname()[0]
         s.close()
         print "[httpd_on_auth_request] Successfully fetched external IP: %s" % external_ip
         dcc = self.ircobj.dcc()
         dcc.previous_buffer = "" 
         dcc.handlers = {} 
         dcc.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
         dcc.passive = 1 
         dcc.socket.bind((external_ip, 0)) 
         dcc.localaddress, dcc.localport = dcc.socket.getsockname() 
         dcc.socket.listen(10) 
         self.dcc_connections.append(dcc)
     except socket.error:
         print "[httpd_on_auth_request] Failed to get external IP. Binding to default."
         dcc = self.dcc_listen()
     
     dcc.nick = nickname
     self.connection.ctcp("DCC", nickname, "CHAT chat %s %s" % (ip_quad_to_numstr(dcc.localaddress), dcc.localport))
	def do_command(self, e, cmd):
		debug.send(('cmd in do_command',cmd),3)
		nick = nm_to_n(e.source())
		chan = e.target()
		if chan == irc_lower(self.connection.get_nickname()): chan = nick
		c = self.connection
		if self._isboss(nick):
			if cmd == "disconnect":
				self.disconnect()
			elif cmd == "die":
				self.die()
			elif cmd == "stats":
				for chname, chobj in self.channels.items():
					c.privmsg(nick, "--- Channel statistics ---")
					c.privmsg(nick, "Channel: " + chname)
					users = chobj.users()
					users.sort()
					c.privmsg(nick, "Users: " + ", ".join(users))
					opers = chobj.opers()
					opers.sort()
					c.privmsg(nick, "Opers: " + ", ".join(opers))
					voiced = chobj.voiced()
					voiced.sort()
					c.privmsg(nick, "Voiced: " + ", ".join(voiced))
			elif cmd == "dcc":
				dcc = self.dcc_listen()
				c.ctcp("DCC", nick, "CHAT chat %s %d" % (ip_quad_to_numstr(dcc.localaddress), dcc.localport))
		elif cmd in ('disconnect','die','stats','dcc','cycle'):
			c.privmsg(chan,'''you're not the boss of me :P''')
		return
Ejemplo n.º 6
0
 def one_param_command(self, c, e, cmd):
     nick = nm_to_n(e.source())
     ch = self.channel
     if cmd == "disconnect":
         quote="Batman is the hero Gotham deserves, but not the one it needs right now"
         c.privmsg(ch, quote)
         self.disconnect(quote)
     elif cmd == "die":
         quote="The Dark Knight Will Rise. Then Fear will find you again"
         c.privmsg(ch, nick+": "+quote)
         self.die(quote)
     elif cmd == "stats":
         for chname, chobj in self.channels.items():
             c.privmsg(nick, "--- Channel statistics ---")
             c.privmsg(nick, "Channel: " + chname)
             users = chobj.users()
             users.sort()
             c.privmsg(nick, "Users: " + ", ".join(users))
             opers = chobj.opers()
             opers.sort()
             c.privmsg(nick, "Opers: " + ", ".join(opers))
             voiced = chobj.voiced()
             voiced.sort()
             c.privmsg(nick, "Voiced: " + ", ".join(voiced))
     elif cmd == "dcc":
         dcc = self.dcc_listen()
         c.ctcp("DCC", nick, "CHAT chat %s %d" % (
             ip_quad_to_numstr(dcc.localaddress),
             dcc.localport))
     elif cmd == "chatlog":
         c.privmsg(ch, "Want to check the web first ? http://irc.launchvn.com/ ")
         c.privmsg(ch, "Or not? Choose day and check private message (ex: \"2013-04-18\"): ")
     elif re.match(r'(\d{4}-\d{2}-\d{2})',cmd):
         param = cmd
         self.rep_log(c, e, param)
     elif cmd == "pythonmode":
         self.pyflg=True
         c.privmsg(ch, "Welcome to "+cmd)
     elif cmd == "chatmode":
         self.pyflg=False
         self.buf=""
         self.safe_dict={}
         c.privmsg(ch, "Welcome to "+cmd)
     else:
         try:
             self.let_me_see_you(cmd)
         except:
             pass
         try:
             rel=self.safe_eval(cmd)
             c.privmsg(ch, rel)
         except:
             self.said_you_said_me(c, e, cmd)
             if self.pyflg: self.buf.append(cmd)
Ejemplo n.º 7
0
    def do_command(self, e, cmd):
        nick = nm_to_n(e.source())
        if e.eventtype() == "pubmsg":
            nick = e.target()
        c = self.connection

        t = time()
        if (self.time + self.learninterval) < t:
            self.learn_prelude()
            c.notice(
                nick,
                "I automatically learned what we talked about. This happens every %d seconds."
                % (self.learninterval))
            self.time = t

        if cmd == "disconnect":
            self.disconnect()
        elif cmd == "die":
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(nick, "--- Channel statistics ---")
                c.notice(nick, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(nick, "Users: " + string.join(users, ", "))
                opers = chobj.opers()
                opers.sort()
                c.notice(nick, "Opers: " + string.join(opers, ", "))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(nick, "Voiced: " + string.join(voiced, ", "))
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp(
                "DCC", nick, "CHAT chat %s %d" %
                (ip_quad_to_numstr(dcc.localaddress), dcc.localport))
        elif cmd == "quit":
            c.notice(nick, "Not understood: " + cmd)
        elif cmd == "learn":
            self.learn_prelude()
            c.notice(nick, "I learned what we talked about.")
        else:
            self.pipein.write(cmd + "\n")
            self.pipein.flush()
            line = self.pipeout.readline()
            answer = line.replace("You say: ", "", 1)
            answer = answer.replace("Prelude's reply: ", "", 1)
            c.privmsg(nick, answer)
Ejemplo n.º 8
0
    def do_command(self, e, cmd):
        nick = nm_to_n(e.source())
        if e.eventtype() == "pubmsg":
            nick = e.target()
        c = self.connection

        t = time()
        if (self.time + self.learninterval) < t:
            self.learn_prelude()
            c.notice(nick, "I automatically learned what we talked about. This happens every %d seconds."%(self.learninterval))
            self.time = t
        
        if cmd == "disconnect":
            self.disconnect()
        elif cmd == "die":
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(nick, "--- Channel statistics ---")
                c.notice(nick, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(nick, "Users: " + string.join(users, ", "))
                opers = chobj.opers()
                opers.sort()
                c.notice(nick, "Opers: " + string.join(opers, ", "))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(nick, "Voiced: " + string.join(voiced, ", "))
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp("DCC", nick, "CHAT chat %s %d" % (
                ip_quad_to_numstr(dcc.localaddress),
                dcc.localport))
        elif cmd == "quit":
            c.notice(nick, "Not understood: " + cmd)
        elif cmd == "learn":
            self.learn_prelude()
            c.notice(nick, "I learned what we talked about.")
        else:
            self.pipein.write(cmd+"\n")
            self.pipein.flush()
            line = self.pipeout.readline()
            answer = line.replace("You say: ", "", 1)
            answer = answer.replace("Prelude's reply: ", "", 1)
            c.privmsg(nick, answer)
Ejemplo n.º 9
0
    def do_command(self, event, cmd):
        nick = nm_to_n(event.source())
        c = self.connection

        # cmd, arg = cmd.split(r" ", 1)
        splitcmd = cmd.split(r" ", 1)
        arg = None
        if len(splitcmd) > 1:
            cmd = splitcmd[0]
            arg = splitcmd[1]

        if cmd == "disconnect":
            self.disconnect()
        elif cmd == "die":
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(nick, "--- Channel statistics ---")
                c.notice(nick, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(nick, "Users: " + ", ".join(users))
                opers = chobj.opers()
                opers.sort()
                c.notice(nick, "Opers: " + ", ".join(opers))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(nick, "Voiced: " + ", ".join(voiced))
        elif cmd == "get":
            if arg is None:
                c.notice(nick, "get expects an argument")
            else:
                self.search_for(arg)
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp("DCC", nick, "CHAT chat %s %d" % (
                ip_quad_to_numstr(dcc.localaddress),
                dcc.localport))
        else:
            c.notice(nick, "Not understood: " + cmd)
Ejemplo n.º 10
0
    def do_command(self, event, cmd):
        nick = nm_to_n(event.source())
        c = self.connection

        # cmd, arg = cmd.split(r" ", 1)
        splitcmd = cmd.split(r" ", 1)
        arg = None
        if len(splitcmd) > 1:
            cmd = splitcmd[0]
            arg = splitcmd[1]

        if cmd == "disconnect":
            self.disconnect()
        elif cmd == "die":
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(nick, "--- Channel statistics ---")
                c.notice(nick, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(nick, "Users: " + ", ".join(users))
                opers = chobj.opers()
                opers.sort()
                c.notice(nick, "Opers: " + ", ".join(opers))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(nick, "Voiced: " + ", ".join(voiced))
        elif cmd == "get":
            if arg is None:
                c.notice(nick, "get expects an argument")
            else:
                self.search_for(arg)
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp(
                "DCC", nick, "CHAT chat %s %d" %
                (ip_quad_to_numstr(dcc.localaddress), dcc.localport))
        else:
            c.notice(nick, "Not understood: " + cmd)
Ejemplo n.º 11
0
    def do_command(self, e, cmd):
        nick = nm_to_n(e.source())
        c = self.connection
        try:
            count = len(re.findall(r'\w+', cmd))
            arguments = (e.arguments())[0].split()
            find = find_user_and_group(self.user_to_group, nick)
            text = ""
        
            if arguments[0][0] == "\'":
                c.privmsg(nick, "Essaie sans l'apostrophe ;)")

            elif (cmd == "!disconnect") and (nick == "Pouwapouwa"):
                self.disconnect()

            elif (cmd == "!die") and (nick == "Pouwapouwa"):
                self.die()

            elif cmd == "!stats":
                for chname, chobj in self.channels.items():
                    c.privmsg(nick, "--- Channel statistques ---")
                    c.privmsg(nick, "Channel: " + chname)
                    users = chobj.users()
                    users.sort()
                    c.privmsg(nick, "Users: " + ", ".join(users))
                    opers = chobj.opers()
                    opers.sort()
                    c.privmsg(nick, "Opers: " + ", ".join(opers))
                    voiced = chobj.voiced()
                    voiced.sort()
                    c.privmsg(nick, "Voiced: " + ", ".join(voiced))

            elif (cmd == "!dcc") and (nick == "Pouwapouwa"):
                dcc = self.dcc_listen()
                c.ctcp("DCC", nick, "CHAT chat %s %d" % (
                    ip_quad_to_numstr(dcc.localaddress),
                    dcc.localport))       

####### EDT

            elif "!edt" in cmd:
                       
                if ((len(arguments) == 1) and (len(find) == 0)):
                    c.privmsg(nick, "Il faut enregistrer un groupe ou alors rajouter des arguments. Pourquoi ne pas tenter \'!edt help\' ?")

                elif (len(arguments) == 1):
                    edt = find[0]
                    for i in range(len(classe_url)):
                        if classe_url[i][0] == edt:
                            text =  classe_url[i][0] + ": " + classe_url[i][1] + ".html "
                            c.privmsg(nick, text)
                            return
                    c.privmsg(nick, "Je n'ai pu trouver le groupe " + edt + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")

                elif arguments[1] == "licence":
                    if len(arguments) == 2:
                        text = "Groupes de Licence proposés : "
                        for i in range(len(classe_url_licence)-1):
                            text = text + classe_url_licence[i][0] + " - " + classe_url_licence[i][2] + ", "
                        text = text + classe_url_licence[len(classe_url_licence)-1][0] + " - " + classe_url_licence[len(classe_url_licence)-1][2]
                        c.privmsg(nick, text)
                        text = "Utilise \'!edt\' suivi de l'identifiant de l'emploi du temps pour obtenir l'url de l'emploi du temps concerné. Ex: \'!edt MI201\'."
                        c.privmsg(nick, text)
                        
                elif arguments[1] == "master":
                    if len(arguments) == 2:
                        text = "Groupes de Master proposés : "
                        for i in range(len(classe_url_master)-1):
                            text = text + classe_url_master[i][0] + " - " + classe_url_master[i][2] + ", "
                        text = text + classe_url_master[len(classe_url_master)-1][0] + " - " + classe_url_master[len(classe_url_master)-1][2]
                        c.privmsg(nick, text)
                        text = "Utilise \'!edt\' suivi de l'identifiant de l'emploi du temps pour obtenir l'url de l'emploi du temps concerné. Ex: \'!edt IN811\'."
                        c.privmsg(nick, text)

                elif arguments[1] == "master2":
                    if len(arguments) == 2:
                        text = "Groupes de Master2 proposés : "
                        for i in range(len(classe_url_master2)-1):
                            text = text + classe_url_master2[i][0] + " - " + classe_url_master2[i][2] + ", "
                        text = text + classe_url_master2[len(classe_url_master2)-1][0] + " - " + classe_url_master2[len(classe_url_master2)-1][2]
                        c.privmsg(nick, text)
                        text = "Utilise \'!edt\' suivi de l'identifiant de l'emploi du temps pour obtenir l'url de l'emploi du temps concerné. Ex: \'!edt IN011\'."
                        c.privmsg(nick, text)

                elif RepresentsInt(arguments[1]):
                    if ((arguments[1] >= len(find)) or (arguments[1] <= 0)):
                        c.privmsg(nick, "Et faut pas me prendre pour une idiote ! Tu demandes un numéro de groupe que tu n'as pas ;)")
                        return
                    edt = find[int(arguments[1])-1]
                    for i in range(len(classe_url)):
                        if classe_url[i][0] == edt:
                            text =  classe_url[i][0] + ": " + classe_url[i][1] + ".html "
                            c.privmsg(nick, text)
                            return
                    c.privmsg(nick, "Je n'ai pu trouver le groupe " + edt + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")

                elif ((arguments[1] == "today") or (arguments[1] == "tomorrow")):
                    if arguments[1] == "today":
                        d = 0
                        t = "aujourd'hui"
                    else:
                        d = 1
                        t = "demain"
                    find = find_user_and_group(self.user_to_group, nick)

                    if (len(arguments) == 2):
                        if len(find) == 0:
                            c.privmsg(nick, "Aucun groupe d'enregistré.")
                            return
                        else:
                            number = 1
                    else:
                        number = arguments[2]
                        
                    if (RepresentsInt(number)):
                        tmp = int(number)
                        if ((tmp-1 >= len(find)) or (tmp <= 0)):
                            c.privmsg(nick, "Et faut pas me prendre pour une idiote ! Tu demandes un numéro de groupe que tu n'as pas ;)")
                            return
                        number = find[int(number)-1]
                    bool = False
                    for i in range(len(classe_url)):
                        if classe_url[i][0] == number:
                            text = parser_all_day(classe_url[i][1]+".xml", d)
                            bool = True
                            
                    if (len(text) == 0 and bool):
                        c.privmsg(nick, "Pas de cours pour " + t + " ... Lucky "+ nick +" ;)")
                        return
                    else:
                        bool = False
                        for i in range(len(text)):
                            if (d):
                                text2 = "Demain:"
                            else:
                                text2 = "Aujourd'hui:"
                            for j in range(len(text[i])):
                                text2 = text2 + " " +  str(text[i][j])
                                bool = True
                            c.privmsg(nick, text2)
                            
                        if not bool:
                            c.privmsg(nick, "Je n'ai pu trouver le groupe " + number + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")
                            return
                    

                elif arguments[1] == "now":
                    find = find_user_and_group(self.user_to_group, nick)
                    if (len(arguments) == 2):
                        if len(find) == 0:
                            c.privmsg(nick, "Aucun groupe d'enregistré.")
                            return
                        else:
                            number = 1
                    else:
                        number = arguments[2]
                    
                    if (RepresentsInt(number)):
                        if ((int(number)-1 >= len(find)) or (int(number) <= 0)):
                            c.privmsg(nick, "Je n'ai pu trouver le groupe " + number + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")
                            return
                        edt = find[int(number)-1]
                        for i in range(len(classe_url)):
                            if classe_url[i][0] == edt:
                                text = parser_delayed(classe_url[i][1]+".xml")
                                if len(text) == 0:
                                    c.privmsg(nick, "Plus de cours pour aujourd'hui ... Lucky "+ nick +" ;)")
                                    return
                                else:
                                    bool = False
                                    for j in range(len(text)):
                                        text2 = "Aujourd'hui: "
                                        for k in range(len(text[j])):
                                            text2 = text2 + " " +  str(text[j][k])
                                        c.privmsg(nick, text2)
                                        bool = True
                                    if not bool:
                                        c.privmsg(nick, "Je n'ai pu trouver le groupe " + edt + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")
                                    return
                        c.privmsg(nick, "Je n'ai pu trouver le groupe " + edt + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")

                    else:
                        for i in range(len(classe_url)):
                            if classe_url[i][0] == arguments[2]:
                                text = parser_delayed(classe_url[i][1]+".xml")
                                if len(text) == 0:
                                    c.privmsg(nick, "Plus de cours pour aujourd'hui ... Lucky "+ nick +" ;)")
                                    return
                                else:
                                    bool = False
                                    for j in range(len(text)):
                                        text2 = "Aujourd'hui: "
                                        print text, len(text)
                                        for k in range(len(text[j])):
                                            text2 = text2 + " " +  str(text[j][k])
                                            bool = True
                                        c.privmsg(nick, text2)
                                    if not bool:
                                        c.privmsg(nick, "Je n'ai pu trouver le groupe " + arguments[2] + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")
                                    return
                                    
                        c.privmsg(nick, "Je n'ai pu trouver le groupe " + arguments[2] + ". Vérifie que ce groupe existe bien en faisant \'!edt licence\' si c'est un groupe de licence, de même pour ceux de master et master2.")

                elif arguments[1] == "groups":
                    if len(arguments) > 2:
                        c.privmsg(nick, "Pas besoin de rajouter quelques choses après \'groups\' ;)")
                    find = find_user_and_group(self.user_to_group, nick)
                    for i in range(len(find)):
                        text = text + " {nmb}: ".format(nmb=i+1) + find[i] + " "
                    c.privmsg(nick, "Voici vos groupes : " + text)
             
                elif arguments[1] == "add":
                    if len(arguments) < 3:
                        c.privmsg(nick, "Il faut un identifiant de groupe à ajouter. Voyons ... ;)")
                    else:
                        for i in range(2, len(arguments)):
                            self.user_to_group = add_user_and_group(self.user_to_group, nick, arguments[i])
                            rewrite_user_to_group(self.user_to_group)
                            find = find_user_and_group(self.user_to_group, nick)
                        for j in range(len(find)):
                            text = text + " {nmb}: ".format(nmb=j+1) + find[j] + " "
                        c.privmsg(nick, "Voici vos groupes : " + text)

                elif arguments[1] == "delete":
                    if len(arguments) < 3:
                        c.privmsg(nick, "Il faut un identifiant de groupe à supprimer. Voyons ... ;)")
                    else:
                        for i in range(2, len(arguments)):
                            self.user_to_group = del_user_and_group(self.user_to_group, nick, arguments[i])
                            rewrite_user_to_group(self.user_to_group)
                            find = find_user_and_group(self.user_to_group, nick)
                        for j in range(len(find)):
                            text = text + " {nmb}: ".format(nmb=j+1) + find[j] + " "
                        c.privmsg(nick, "Voici vos groupes : " + text)
                
                elif ((arguments[1] == "help") and (len(arguments) == 2)):
                    text = "Voici la liste des commandes que je propose : " 
                    for i in range(len(edt_opt)-1):
                        text = text + edt_opt[i][0] + ', '
                    text = text + edt_opt[len(edt_opt)-1][0] + ' '
                    c.privmsg(nick, text)
                    c.privmsg(nick, "Faites précéder ces commandes du mot help pour mieux comprendre ce qu'elles font ;)")

                elif arguments[1] == "help":
                    text = ""
                    for i in range(len(edt_opt)-1):
                        if edt_opt[i][0] == arguments[2]:
                            text = edt_opt[i][0] + ": " + edt_opt[i][1]
                            break
                    if text == "":
                        text =  "Cette commande n'existe pas ... Essaie encore !"
                    c.privmsg(nick, text)
                
                else:
                    for i in range(len(classe_url)):
                        if classe_url[i][0] == arguments[1]:
                            text =  classe_url[i][0] + ": " + classe_url[i][1] + ".html "
                            c.privmsg(nick, text)
                            return
                    c.privmsg(nick, "Impossible de trouver le groupe " + arguments[1] + " ...")

            elif arguments[0] == "!joke":
                if ((len(arguments) > 1) and (arguments[1] == "add")):
                    joke = ""
                    for i in range(2, len(arguments)):
                        joke = joke + " " + arguments[i]
                    self.jokes.append([joke])
                    rewrite_jokes(self.jokes)
                    text = "Cette blague a bien été enregistrée \o/"
                else:
                    text = "La prochaine implémentation prendra en compte un dictionnaire de blagues dont TU seras un des auteurs. Bien sûr, celles-ci devront être \"approuvées\", mais il ne devrait pas y avoir de problèmes :) Pour ajouter une blague, faites-là précéder du mot clé \'add\' : \'!joke add Peut-on dire qu'un clavier azerty en vaut deux ?\'"
                c.privmsg(nick, text)


            else:
                c.privmsg(nick, "Commande non comprise : " + cmd)
                text = "Voici la liste des commandes que je propose : " 
                for i in range(len(command)-1):
                    text = text + command[i] + ', '
                text = text + command[len(command)-1]
                c.privmsg(nick, text)
                c.privmsg(nick, "Si vous ne savez pas comment l'utiliser, faites-là suivre de help : \'!edt help\'")
    
        except:
            c.privmsg(nick, "Oups, une erreur est survenue. Pouwapouwa s'en chargera dès que possible !")
            file = open("log/errors", 'a+')
            file.write("\n" + strftime("%d/%m/%Y  %H:%M", gmtime()) + " : " + nick + " " + cmd + "\n")
            file.close()
            #pass
            raise 
Ejemplo n.º 12
0
    def do_command(self, e, cmd):
        nick = nm_to_n(e.source())
        c = self.connection

        if cmd == "disconnect":
            self.disconnect()
        elif cmd == "die":
            self.die()
        elif cmd == "stats":
            for chname, chobj in self.channels.items():
                c.notice(nick, "--- Channel statistics ---")
                c.notice(nick, "Channel: " + chname)
                users = chobj.users()
                users.sort()
                c.notice(nick, "Users: " + ", ".join(users))
                opers = chobj.opers()
                opers.sort()
                c.notice(nick, "Opers: " + ", ".join(opers))
                voiced = chobj.voiced()
                voiced.sort()
                c.notice(nick, "Voiced: " + ", ".join(voiced))
        elif cmd == "dcc":
            dcc = self.dcc_listen()
            c.ctcp("DCC", nick, "CHAT chat %s %d" % (
                ip_quad_to_numstr(dcc.localaddress),
                dcc.localport))
        elif cmd == "start":
            for chname, chobj in self.channels.items():
                for i in range(10, 0 , -1):
                    c.privmsg(chname, i)
                    time.sleep(1)
                i = 10
                t = datetime.now()
                c.privmsg(chname, "Press play now! To get the current time send me a PM that says time")
        elif cmd == "time":
            try:
                global t
                c.privmsg(nick, (datetime.now() - t))
            except TypeError:
                c.privmsg(nick, "We aren't watching anything right now")
            except NameError:
                c.privmsg(nick, "We aren't watching anything right now")
        elif cmd == "stop":
            try:
                for chname, chobj in self.channels.items():
                    c.privmsg(chname, "Stopping now, hope everyone enjoyed the movie!")
                    backup = datetime.now() #if there is a mistake you can restore from backup
            except TypeError:
                c.privmsg(nick, "We haven't started, why even try to stop? Idiot.")
        elif cmd == "backup": #not working!
            for chname, chobj in self.channels.items():
                c.privmsg(nick, "Restoring backup, telling channel")
                c.privmsg(chname, "Oops, didn't mean to stop there, let's keep going from where we stopped!")
                global backup
                t = backup
                c.privmsg(chname, (datetime.now() - t))
        elif cmd == "welcome":
            for chname, chobj in self.channels.items():
                c.privmsg(chname, "The way this will work is everyone pauses at 0:00 before we start. Then I will countdown from 10 and we all hit play together. So go and pause those players now!")
        elif cmd == "announce":
            for chname, chobj in self.channels.items():
                c.privmsg(chname, "Pinging everyone because we're starting soon!")
                users = chobj.users()
                users.sort()
                c.notice(chname, ", ".join(users))
        else:
            c.notice(nick, "Not understood: " + cmd)
Ejemplo n.º 13
0
 def show_version(self, varChat, varEvent):
     dcc = self.dcc_listen()
     nick = nm_to_n(varEvent.source())
     varChat.ctcp("VERSION", nick, "pyBoter 2.64 Python IRC %s %d" % (
         ip_quad_to_numstr(dcc.localaddress),
         dcc.localport))