Esempio n. 1
0
def on_ready():
    #initial retrieve
    GenFun.retrieveUrl()
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')
Esempio n. 2
0
def response(message):

    #gets message from user and sees what to do with it
    json = GenFun.retrieveUrl()
    json = json['Emotes']

    #checking if there are any trigger words for emotes that need to be dealt with
    for x in json.keys():

        if re.search(r"\b" + re.escape(str(json[x]['trigger'])) + r"\b", str(message.content).lower()):
            textMessage = json[x]['response']
            client.send_message(message.channel, textMessage)

    #checking for a mention in a conversation
    if 'bot ' in str(message.content).lower() or ' bot' in str(message.content).lower():
        #casually interupting the conversation
        textMessage = "You mentioned me " + str(message.author) + '!'
        client.send_message(message.channel, textMessage)

    #checking this phrase
    if 'press f to pay respect' in str(message.content).lower().strip():
        textMessage = 'f'
        #spamming f exactly enough times to fill up the screen on a normal brower window
        for x in range(0, 23):
            client.send_message(message.channel, textMessage)
Esempio n. 3
0
def emotes(message, messageObj):

    if len(message) == 0:
        return['Syntax is wrong: \n example: $emote -add kappa -link "http://goo.gl/ZEX6KN"', messageObj.channel]

    if '-help' in message:
        return["Usage, $emote -add <name> -link <\"link of image\"> -list  for list  -del <\"name\">to delete\n Please insure that there are quotes around the link \n Please use https://goo.gl/ to shorten the url.", messageObj.channel]

    elif '-list' in message:
        jsonTxt = GenFun.retrieveUrl()
        jsonTxt = jsonTxt['Emotes']
        messageTxt = ''

        for x in jsonTxt.keys():
            messageTxt = messageTxt + str(x)[0].upper() + str(x)[1:len(x)] + '\n'

        return[messageTxt, messageObj.channel]

    else:
        if '-link' in message or '-add' in message and '-list' in message or '-del' in message:

            message = message.replace(" ", "")

            jokes = GenFun.retrieveUrl()
            tmpJokes = jokes
            jokes = jokes["Emotes"]

            if '-del' in message:
                emoteToDel = message[message.find('-del"')+len('-del"'):message.rfind('"', 0, len(message))].lower()
                if len(emoteToDel) == 0:
                    return["ERROR nothing to delete",messageObj.channel]

                for x in jokes.keys():

                    if jokes[x]['trigger'] == emoteToDel:
                        jokes.pop(x, None)

                        tmpJokes['Emotes'] = jokes
                        GenFun.store(json.dumps(tmpJokes, indent=4, separators=(',', ': ')))

                        return['Deleted successfully', messageObj.channel]

                return["ERROR Something went wrong",messageObj.channel]



            if message[len(message)-1] == '"':

                add = message[message.find("-add")+len("-add"):message.find("-link")]
                link = message[message.find("-link")+len('-link"'):len(message)-1]

                if jokes.has_key(add):
                    return["That emote already exists!", messageObj.channel]
                else:
                    jokes[add] = {'response':link, 'trigger':add.lower()}

                    tmpJokes['Emotes'] = jokes

                    GenFun.store(json.dumps(tmpJokes, indent=4, separators=(',', ': ')))

                    return ["Successful", messageObj.channel]
                print "*EMOTE*"


            else:
                return['Syntax is wrong: \n example: $emote -add kappa -link "http://goo.gl/ZEX6KN"', messageObj.channel]

        else:
            return['Syntax is wrong: \n example: $emote -add kappa -link "http://goo.gl/ZEX6KN"', messageObj.channel]
            pass