Esempio n. 1
0
def executeBuffer(arguments, sender):
	if len(_buf) > 0:
		nick = arguments[5]
		mode = arguments[6]
		if nick == _buf["nick"]:
			if 'r' in mode:
				events.callFunction(_buf["function"], [_buf["channel"], _buf["nick"]] + _buf["arguments"])
			else:
				irc.sendMessage(_buf["channel"], "%s: authenticate before using restricted commands." % _buf["nick"])
Esempio n. 2
0
def incomingIrcMessage(sender, channel, fullMessage):
    # sender is a nickname!ident@hostname triple.
    (nickname, ident, hostname) = parseSender(sender)
    if channel.startswith('#') or channel.startswith('&'):
        triggered = False
    else:
        channel = nickname
        triggered = True
    message = fullMessage.lstrip(' \t')
    if message.lower().startswith(ircstatus.currentNickname().lower()):
        reducedMessage = message[len(ircstatus.currentNickname()):]
        if reducedMessage[:2].rstrip(' \t') in [',', ':']:
            message = reducedMessage[2:]
            triggered = True
    ignored = ignorelist.isIgnored(nickname)
    authorized = authorize.isAuthorized(nickname)
    
    for handler in _functionHandlers[:]:
        if not handler.enabled:
            continue
        # If the person in question is ignored, disregard the command.
        if ignored and not handler.noIgnore:
            continue
        # If the incoming message does not start with 'bhottu, ', ignore it
        # unless this function is marked Implicit.
        if not handler.implicit and not triggered:
            continue
        if not stringmatcher.matchAttempt(message, handler.format):
            # The function was not called.
            continue
        arguments = stringmatcher.matchFormat(message, handler.format)
        if arguments == None:
            # The function matches, but with wrong syntax.
            if handler.errorMessages:
                if handler.syntaxErrorMessage != None:
                    irc.sendMessage(channel, handler.syntaxErrorMessage)
                elif handler.syntax != None:
                    irc.sendMessage(channel, "syntax: %s" % handler.syntax)
            continue
        # If we get here, the function was matched.
        # If the user is not authorized to invoke this function, abort.
        if handler.restricted and not authorized:
            if handler.errorMessages:
                if handler.restrictedErrorMessage != None:
                    irc.sendMessage(channel, handler.restrictedErrorMessage)
                else:
                    irc.sendMessage(channel, "%s, %s03>implying" % (nickname, chr(3)))
            continue
        # Everything checks out, we can execute the function.
        callFunction(handler.function, [channel, nickname] + arguments)
    
    for handler in _messageHandlers[:]:
        if not handler.enabled:
            continue
        if ignored and not handler.noIgnore:
            continue
        # Handlers with format == None are a special case - they always get called, period.
        if handler.format == None:
            callFunction(handler.function, [channel, nickname, fullMessage])
            continue
        
        # If the incoming message does not start with 'bhottu, ', ignore it
        # unless this function is marked Implicit.
        if not handler.implicit and not triggered:
            continue
        arguments = stringmatcher.matchFormat(message, handler.format)
        if arguments == None:
            # No match.
            continue
        # We have a match, so execute the handler.
        callFunction(handler.function, [channel, nickname] + arguments)
Esempio n. 3
0
            sendPongToServer(server)
            break

        user = getUser(line)
        message = getMessage(line)
        wordList = message.split(" ")
        print(str(getTime() + user + ": " +
                  message))  # Prints messages from all users to console
        if LOG_TO_FILE:
            logMessage(str(getTime() + user + ": " + message))

########## Add custom functions below ##########
# Current configuration is modular. Just copy the design patterns as seen below

        if "!level" in wordList[0]:
            sendMessage(server, getLevel(user, message, wordList))
            break

        if "!lvl" in wordList[0]:
            sendMessage(server, getLevel(user, message, wordList))
            break

        if "!commands" in wordList[0]:
            sendMessage(
                server, "@" + user +
                " !level [skill name] | !level [player name] [skill name]")
            break

        if BOTOWNER in user:
            if "!shutdown" in message:
                sendMessage(
def greetRoom(server):
    print(getTime() + "Bot initiated")
    sendMessage(
        server, GREETING
    )  # If the greeting empty is left blank, as "", no greeting will be sent