Ejemplo n.º 1
0
def exec_(connection, channel, nick, cmd, args):
    """"""
    if not args: return
    args = args.encode("utf-8")
    args = map(str.strip, args.strip().split())
    cmd = args[0]

    if cmd[0] != "/":
        cmd = normpath(join("/bin", cmd))
        cmd = cmd.replace("\\", "/")

    res = "-tehsh: %s: Command not found" % args[0]
    if cmd == "/bin/ls":
        res = ls(args[1:])
    elif cmd == "/bin/head":
        res = head(args[1:])
    elif cmd == "/bin/cat":
        res = cat(args[1:])
    elif cmd == "/bin/uptime":
        res = execute(["uptime"])
    elif cmd == "/bin/uname":
        res = execute(["uname"] + args[1:])
    elif cmd == "/bin/free":
        res = execute(["free"])
    elif cmd == "/bin/tehsh":
        res = "-tehsh: No cando"
    elif cmd == "/bin/bash":
        res = "-tehsh: No, I like tehsh."

    plugins.say_nick(connection, channel, nick, res)
Ejemplo n.º 2
0
def shoot(connection, channel, nick, cmd, args):
    if not shotmap.has_key(nick) or shotmap[nick] == 0:
        return plugins.say_nick(connection, channel, nick, "Your glass is empty!")

    shotmap[nick] -= 1
    plugins.say_nick(connection, channel, nick, "| |  AH!")
    plugins.say_nick(connection, channel, nick, "+-+  Want another one, %s?" % nick)
Ejemplo n.º 3
0
def pun(connection, channel, nick, cmd, args):
    """Print a random pun from jhype.co.uk"""
    page = urllib.urlopen("http://jhype.co.uk/puns.php").read()
    init = False
    puns = []
    currpun = []
    for line in page.splitlines():
        if line.startswith('<p class="emph2">'):
            init = True
            if currpun:
                puns.append("\n".join(currpun))
                currpun = []
            continue
        if init and line.find("</div>") > -1:
            init = False
            break
        if init:
            if line.startswith("<br />"):
                if currpun:
                    puns.append("\n".join(currpun))
                    currpun = []
            else:
                currpun.append(line.replace("<br />", ""))
    if currpun:
        puns.append("\n".join(currpun))
        
    print puns

    random.shuffle(puns)
    if puns:
        plugins.say_nick(connection, channel, nick, puns[0])
Ejemplo n.º 4
0
def solve(connection, channel, nick, cmd, args):
    if not args:
        return
    if args == "https://www.sabrefilms.co.uk/revolutionelite/chall-for-tehron.php":
        plugins.say_nick(connection, channel, nick, "muffins")
    else:
        seq = ["nice try :P", "you wish", "haha", "ok. ...wait, aren't you %s?" % nick]
        plugins.say_nick(connection, channel, nick, random.choice(seq))
Ejemplo n.º 5
0
    def react_to_command(self, connection, event, msg):
        tmp = msg.split(" ", 1)
        cmd = tmp[0]
        args = tmp[1] if len(tmp) == 2 else None

        if cmd in self.operator_cmd_handlers:
            if not self.is_op(connection, event.source):
                return plugins.say_nick(connection, event.target, event.source.nick, "You are no operator.")
            self.operator_cmd_handlers[cmd](connection, event.target, event.source.nick, cmd, args)
        elif cmd in plugins.operator_cmd_handlers and self.is_op(connection, event.source):
            self.tehbot.queue.put((plugins.operator_cmd_handlers[cmd], (connection, event.target, event.source.nick, cmd, args)))
        elif irc.client.is_channel(event.target):
            if cmd in plugins.pub_cmd_handlers:
                self.tehbot.queue.put((plugins.pub_cmd_handlers[cmd], (connection, event.target, event.source.nick, cmd, args)))
        else:
            if cmd in plugins.priv_cmd_handlers:
                self.tehbot.queue.put((plugins.priv_cmd_handlers[cmd], (connection, event.target, event.source.nick, cmd, args)))
Ejemplo n.º 6
0
def reverse(connection, channel, nick, cmd, args):
    """Gives back the string reversed"""
    print args,"->",args[::-1]
    txt = plugins.myfilter(args[::-1])

    plugins.say_nick(connection, channel, nick, txt)
Ejemplo n.º 7
0
def say(connection, channel, nick, cmd, args):
    print "say", args
    if not args:
        return
    plugins.say_nick(connection, channel, nick, plugins.myfilter(args))
Ejemplo n.º 8
0
def shots(connection, channel, nick, cmd, args):
    plugins.say_nick(connection, channel, nick, "|~|")
    plugins.say_nick(connection, channel, nick, "+-+  Cheers, %s!" % nick)
    if not shotmap.has_key(nick):
        shotmap[nick] = 0
    shotmap[nick] += 1