コード例 #1
0
ファイル: __init__.py プロジェクト: spaceone/tehbot
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)
コード例 #2
0
ファイル: __init__.py プロジェクト: spaceone/tehbot
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)
コード例 #3
0
ファイル: __init__.py プロジェクト: spaceone/tehbot
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])
コード例 #4
0
ファイル: __init__.py プロジェクト: spaceone/tehbot
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))
コード例 #5
0
ファイル: dynamic.py プロジェクト: spaceone/tehbot
    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)))
コード例 #6
0
ファイル: __init__.py プロジェクト: spaceone/tehbot
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)
コード例 #7
0
ファイル: __init__.py プロジェクト: spaceone/tehbot
def say(connection, channel, nick, cmd, args):
    print "say", args
    if not args:
        return
    plugins.say_nick(connection, channel, nick, plugins.myfilter(args))
コード例 #8
0
ファイル: __init__.py プロジェクト: spaceone/tehbot
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