Exemplo n.º 1
0
def handle_msg(ircmsg, config_dict):
    """ handle_msg() - parse and handle an irc msg"""

    if ircmsg.find("Hello %s" % config_dict['technux_bot']) != -1:
        nick = parse_nick(ircmsg)
        send_msg(config_dict['channel'], nick, config_dict['greeting'])
    elif ircmsg.find("%s: help" % (config_dict['technux_bot'])) != -1:
        nick = parse_nick(ircmsg)
        usage(config_dict['channel'], nick, config_dict['usagemsg'])
    elif ircmsg.find("%s: info" % (config_dict['technux_bot'])) != -1:
        nick = parse_nick(ircmsg)
        send_msg(config_dict['channel'], nick, config_dict['info'])
    elif ircmsg.find("%s: redmine" % (config_dict['technux_bot'])) != -1:
        nick = parse_nick(ircmsg)
        if redmine_enabled is False:
            send_msg(config_dict['channel'], nick,
                     "Redmine commands not enabled")
        else:
            index = ircmsg.find("%s: redmine" % (config_dict['technux_bot']))
            cmd = ircmsg[index:].split()
            res = redmine_interface.parse_command(cmd[2:])
            if len(res) > REDMINE_MAX_RESULTS:
                tmpmsg = "More than %d results, only sending first %d" % \
                    (REDMINE_MAX_RESULTS, REDMINE_MAX_RESULTS)
                send_priv_msg(nick, tmpmsg)
                res = res[:REDMINE_MAX_RESULTS]
            for r in res:
                for line in r.strip().split('\n'):
                    send_priv_msg(nick, line)
                    time.sleep(0.5)  # avoid flooding the IRC server
Exemplo n.º 2
0
 def test_listp(self):
     res = redmine_interface.parse_command(["listp"])
     for r in res:
         self.assertEqual(r, "Redmine")
Exemplo n.º 3
0
 def test_single_issue_list_formatted(self):
     res = redmine_interface.parse_command(["17113"])
     self.assertEqual(
         "".join(res), "Parent task invalid although type ahead shows ticket @ http://www.redmine.org/issues/17113"
     )
Exemplo n.º 4
0
 def test_single_issue_not_list_formatted(self):
     res = redmine_interface.parse_command("17113")
     self.assertIn("'cmd' must be a list of strings", "".join(res))
Exemplo n.º 5
0
 def test_empty_list(self):
     res = redmine_interface.parse_command([])
     self.assertRegexpMatches("".join(res), "Available commands:")
Exemplo n.º 6
0
 def test_help(self):
     res = redmine_interface.parse_command(["help"])
     self.assertRegexpMatches("".join(res), "Available commands:")