示例#1
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "quotesLocation", "userRequirementAdd",
                              "userRequirementRemove")
     settingsHandler.writeSetting(
         name,
         ["quotesLocation", "userRequirementAdd", "userRequirementRemove"],
         [name, "None", "elevated"])
示例#2
0
文件: 8ball.py 项目: Phoshi/OMGbot
 def action(self, complete):
     msg=complete.message()
     isElevated=(isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]))
     self.__init_answers__(complete)
     if len(msg.split())>=1:
         cmd=msg.split()[0]
         msg=' '.join(msg.split()[1:])
     else:
         cmd=""
         msg=""
     if cmd=="-add" and isElevated:
         settingsHandler.writeSetting("'"+complete.cmd()[0]+"'","answer",msg)
         toReturn="Added that answer"
         self.__init_answers__(complete)
     elif cmd=="-delete" and isElevated:
         settingsHandler.deleteSetting("'"+complete.cmd()[0]+"'","answer",msg)
         toReturn="Wiped that answer."
         self.__init_answers__(complete)
     elif cmd=="-wipe" and isElevated:
         settingsHandler.dropTable("'"+complete.cmd()[0]+"'")
         settingsHandler.newTable("'"+complete.cmd()[0]+"'","answer")
         toReturn="Answer table wiped!"
         self.__init_answers__(complete)
     elif cmd=="-dump":
         self.__init_answers__(complete)
         return ["PRIVMSG $C$ :[%s]"%', '.join(["'"+x+"'" for x in self.answers])]
     else:
         toReturn=self.answers.pop()
         if complete.message()=="":
             toReturn=toReturn.replace("$1$","$U$")
         else:
             toReturn=toReturn.replace("$1$",complete.message())
     return ["PRIVMSG $C$ :"+toReturn]
示例#3
0
 def __init_db_tables__(self, name):
     import settingsHandler
     settingsHandler.newTable(name, "url", "regex", "matchText")
     settingsHandler.writeSetting(name, ["url", "regex", "matchText"], [
         "http://google.com/complete/search?output=toolbar&q=$*$", ".*",
         "Autocomplete Results:"
     ])
示例#4
0
文件: unignore.py 项目: Phoshi/OMGbot
 def action(self, complete):
     msg=complete.message()
     amsg=msg
     if isAllowed(complete.userMask())<getLevel(complete.cmd()[0]):
         return ["PRIVMSG $C$ :No."]
     if msg=="*":
         #settingsHandler.deleteSetting("coreIgnorance","1","1")
         settingsHandler.dropTable("coreIgnorance")
         settingsHandler.newTable("coreIgnorance","ignorance","nickname")
         return ["PRIVMSG $C$ :Unignored everything, my lord"]
     if msg in globalv.miscVars[0]:
         msg=globalv.miscVars[0][msg]
     try:
         if amsg in [x[0] for x in settingsHandler.readSettingRaw("coreIgnorance","ignorance")]:
             settingsHandler.deleteSetting("coreIgnorance","ignorance",amsg)
             return ["PRIVMSG $C$ :"+amsg + " successfully unignored, cap'n!"]
         msg=".*@"+msg.split('@')[1] if msg.find('@')>0 else msg
         if msg in [x[0] for x in settingsHandler.readSettingRaw("coreIgnorance","ignorance")]:
             settingsHandler.deleteSetting("coreIgnorance","ignorance",msg)
             return ["PRIVMSG $C$ :"+amsg + " successfully unignored, cap'n!"]
         else:
             matches=difflib.get_close_matches(msg,[x[0] for x in settingsHandler.readSettingRaw("coreIgnorance","ignorance")],3,0.4)
             matches=["None"] if matches==[] else matches
             globalv.variables['ignored']=matches[0]
             return ["PRIVMSG $C$ :"+msg+" is not ignored, commander! Near matches: "+', '.join(matches)+". ~ignored~ set to nearest match."]
     except Exception as detail:
         return ["PRIVMSG $C$ :"+msg+" not unignored: "+str(detail)]
     return ["PRIVMSG $C$ :"+amsg + " successfully unignored, cap'n!"]
示例#5
0
def expandExpansions(toExpand, complete=None):
    def runPluginReturnOutput(matchObj):
        command=expanDict[matchObj.group(1)]
        if matchObj.group(2) is not None:
            arguments=matchObj.group(2)[1:-1]
        else:
            arguments=""
        appendOnto=True
        for index, content in enumerate(arguments.split()):
            if "$%s$"%index in command:
                command=command.replace("$%s$"%index, content)
                appendOnto=False
        if "$*$" in command:
            command=command.replace("$*$",arguments)
            appendOnto=False
        if appendOnto:
            command="%s %s"%(command, arguments)
        inputString=":%s PRIVMSG %s :%s"%(toExpand.userMask(), toExpand.channel(), "!%s"%command)
        input=formatInput(pluginArguments(inputString))
        pluginOutput=' | '.join(globalv.loadedPlugins[command.split()[0]].action(input))
        output=' :'.join(pluginOutput.split(' :')[1:])
        return output
    if type(toExpand) in [str,unicode]:
        isObj=False
    else:
        isObj=True
    if settingsHandler.tableExists("'core-expansions'")==False:
        settingsHandler.newTable("'core-expansions'","trigger","command")
    allCommands=[[x.replace('(','\(').replace(')', '\)'),x] for x in globalv.loadedPlugins.keys()]
    expansions=settingsHandler.readSettingRaw("'core-expansions'","trigger,command") + allCommands
    expanDict={}
    for trigger, command in expansions:
        expanDict[trigger]=command
        if isObj:
            string=toExpand.fullMessage()
            #if string.find("$%s$"%trigger)!=-1:
            if re.findall("(\$%s(\(.*?\))?\$)"%trigger, string)!=[]:
                string=re.sub("\$(%s)(\(.*?\))?\$"%trigger,runPluginReturnOutput,string)
                ret=toExpand.complete()[1:].split(' :',1)
                ret[1]=string
                toExpand.setComplete(':'+' :'.join(ret))
        else:
            if complete==None:
                usermask="dummy!dummy@dummy"
                channel="#dummy"
            else:
                usermask=complete.userMask()
                channel=complete.channel()
            #if toExpand.find("$%s$"%trigger)!=-1:
            if re.findall("(\$%s(\(.*?\))?\$)"%trigger, toExpand)!=[]:
                toExpand=re.sub("\$(%s)(\(.*?\))?\$"%trigger,runPluginReturnOutput,toExpand)
    for variable in globalv.variables.keys():
        if toExpand.fullMessage().find(variable)!=-1:
            string=re.sub("~%s~"%variable,str(globalv.variables[variable]),string)
            ret=toExpand.complete()[1:].split(' :',1)
            ret[1]=string
            toExpand.setComplete(':'+' :'.join(ret))
    return toExpand
示例#6
0
 def __init_db_tables__(self, name):
     if settingsHandler.tableExists("'" + name + "'") == False:
         settingsHandler.newTable("'" + name + "'", "answer")
         answers = [
             "As I see it, yes", "It is certain", "It is decidedly so",
             "Most likely", "Outlook good", "Signs point to yes",
             "Without a doubt", "Yes", "Yes - definitely",
             "You may rely on it", "Reply hazy, try again",
             "Ask again later", "Better not tell you now",
             "Cannot predict now", "Concentrate and ask again",
             "Don't count on it", "My reply is no", "My sources say no",
             "Outlook not so good", "Very doubtful"
         ]
         for answer in answers:
             settingsHandler.writeSetting("'" + name + "'", "answer",
                                          answer)
示例#7
0
 def action(self, complete):
     msg = complete.message()
     amsg = msg
     if isAllowed(complete.userMask()) < getLevel(complete.cmd()[0]):
         return ["PRIVMSG $C$ :No."]
     if msg == "*":
         #settingsHandler.deleteSetting("coreIgnorance","1","1")
         settingsHandler.dropTable("coreIgnorance")
         settingsHandler.newTable("coreIgnorance", "ignorance", "nickname")
         return ["PRIVMSG $C$ :Unignored everything, my lord"]
     if msg in globalv.miscVars[0]:
         msg = globalv.miscVars[0][msg]
     try:
         if amsg in [
                 x[0] for x in settingsHandler.readSettingRaw(
                     "coreIgnorance", "ignorance")
         ]:
             settingsHandler.deleteSetting("coreIgnorance", "ignorance",
                                           amsg)
             return [
                 "PRIVMSG $C$ :" + amsg + " successfully unignored, cap'n!"
             ]
         msg = ".*@" + msg.split('@')[1] if msg.find('@') > 0 else msg
         if msg in [
                 x[0] for x in settingsHandler.readSettingRaw(
                     "coreIgnorance", "ignorance")
         ]:
             settingsHandler.deleteSetting("coreIgnorance", "ignorance",
                                           msg)
             return [
                 "PRIVMSG $C$ :" + amsg + " successfully unignored, cap'n!"
             ]
         else:
             matches = difflib.get_close_matches(msg, [
                 x[0] for x in settingsHandler.readSettingRaw(
                     "coreIgnorance", "ignorance")
             ], 3, 0.4)
             matches = ["None"] if matches == [] else matches
             globalv.variables['ignored'] = matches[0]
             return [
                 "PRIVMSG $C$ :" + msg +
                 " is not ignored, commander! Near matches: " +
                 ', '.join(matches) + ". ~ignored~ set to nearest match."
             ]
     except Exception as detail:
         return ["PRIVMSG $C$ :" + msg + " not unignored: " + str(detail)]
     return ["PRIVMSG $C$ :" + amsg + " successfully unignored, cap'n!"]
示例#8
0
 def action(self, complete):
     msg=complete.message()
     isElevated=(isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]))
     self.__init_answers__(complete)
     hashDate = True
     hashUser = True
     if len(msg.split())>=1:
         cmd=msg.split()[0]
         msg=' '.join(msg.split()[1:])
         if "-date" in msg.split():
             hashUser = False
         if "-user" in msg.split():
             hashDate = False
     else:
         cmd=""
         msg=""
     if cmd=="-add" and isElevated:
         settingsHandler.writeSetting("'"+complete.cmd()[0]+"'","answer",msg)
         toReturn="Added that answer"
         self.__init_answers__(complete)
     elif cmd=="-delete" and isElevated:
         settingsHandler.deleteSetting("'"+complete.cmd()[0]+"'","answer",msg)
         toReturn="Wiped that answer."
         self.__init_answers__(complete)
     elif cmd=="-wipe" and isElevated:
         settingsHandler.dropTable("'"+complete.cmd()[0]+"'")
         settingsHandler.newTable("'"+complete.cmd()[0]+"'","answer")
         toReturn="Answer table wiped!"
         self.__init_answers__(complete)
     elif cmd=="-dump":
         self.__init_answers__(complete)
         return ["PRIVMSG $C$ :[%s]"%', '.join(["'"+x+"'" for x in self.answers])]
     else:
         totalHash = 0
         if hashDate:
             totalHash += hash(date.today())
         if hashUser:
             totalHash += hash(complete.user())
         answer = totalHash % len(self.answers)
         print answer, totalHash, self.answers
         toReturn=self.answers[answer]
         if complete.message()=="":
             toReturn=toReturn.replace("$1$","$U$")
         else:
             toReturn=toReturn.replace("$1$",complete.message())
     return ["PRIVMSG $C$ :"+toReturn]
示例#9
0
def formatInput(arguments, aliases=globalv.aliasExtensions, preprocess=True):
    if settingsHandler.tableExists("'core-doNotExpand'")==False:
        settingsHandler.newTable("'core-doNotExpand'","doNotExpand")
    doNotExpand=[str(x[0]) for x in settingsHandler.readSettingRaw("'core-doNotExpand'","doNotExpand")]
    if aliases[arguments.cmd()[0]]!="":
        toAdd=aliases[arguments.cmd()[0]][1:]
        result=re.findall("\$([0-9][0-9]?[\+-]?)\$",toAdd)
        suchAThingExists=re.search('\$..?.?\$',toAdd)
        if result!=[]:
            for value in result:
                if value.find('+')==-1 and value.find('-')==-1:
                    if (len(arguments.cmd()))>int(value):
                        toAdd=toAdd.replace("$"+value+"$",arguments.cmd()[int(value)])
                    else:
                        if int(value)!=1:
                            toAdd=toAdd.replace("$"+value+"$"," ")
                        else:
                            toAdd=toAdd.replace("$"+value+"$",arguments.user())
                elif value.find('+')!=-1:
                    value=value[:-1]
                    if (len(arguments.cmd()))>(int(value)-1):
                        toAdd=toAdd.replace("$"+value+"+$",' '.join(arguments.cmd()[int(value):]))
                    else:
                        toAdd=toAdd.replace("$"+value+"+$"," ")
                elif value.find('-')!=-1:
                    value=value[:-1]
                    if (len(arguments.cmd()))>int(value):
                        toAdd=toAdd.replace("$"+value+"-$",' '.join(arguments.cmd()[1:][:int(value)]))
                    else:
                        toAdd=toAdd.replace("$"+value+"-$"," ")
        if toAdd.find('$*$')!=-1:
            toAdd=toAdd.replace('$*$',' '.join(arguments.cmd()[1:]))
        if toAdd.find('$URL$')!=-1:
            toAdd=toAdd.replace('$URL$',' '.join(arguments.cmd()[1:]).replace(' ','%20'))
        if suchAThingExists!=None:
            msg=globalv.commandCharacter+arguments.cmd()[0]+" "+toAdd
        else:
            msg=arguments.complete()[1:].split(' :',1)[1]+aliases[arguments.cmd()[0]]
        ret=arguments.complete()[1:].split(' :',1)
        ret[1]=msg
        arguments.setComplete(':'+' :'.join(ret))
    if arguments.cmd()[0] not in doNotExpand and preprocess:
        arguments=expand(arguments)

    return arguments
示例#10
0
    def action(self, complete):
        msg = complete.message()
        isElevated = (isAllowed(complete.userMask()) >= getLevel(
            complete.cmd()[0]))
        beRandom = True
        if len(self.answers) == 0:
            self.__init_answers__(complete, beRandom)
        if len(msg.split()) >= 1:
            cmd = msg.split()[0]
            msg = ' '.join(msg.split()[1:])
        else:
            cmd = ""
            msg = ""
        if cmd == "-add" and isElevated:
            settingsHandler.writeSetting("'" + complete.cmd()[0] + "'",
                                         "answer", msg)
            toReturn = "Added that answer"
            self.__init_answers__(complete, beRandom)
        elif cmd == "-delete" and isElevated:
            settingsHandler.deleteSetting("'" + complete.cmd()[0] + "'",
                                          "answer", msg)
            toReturn = "Wiped that answer."
            self.__init_answers__(complete, beRandom)
        elif cmd == "-wipe" and isElevated:
            settingsHandler.dropTable("'" + complete.cmd()[0] + "'")
            settingsHandler.newTable("'" + complete.cmd()[0] + "'", "answer")
            toReturn = "Answer table wiped!"
            self.__init_answers__(complete, beRandom)
        elif cmd == "-reset" and isElevated:
            self.__init_answers__(complete, beRandom)
            toReturn = "Re-randomising list..."
        else:
            toReturn = self.answers.pop()
            inputs = ":%s PRIVMSG %s :!%s" % (complete.userMask(),
                                              complete.channel(), toReturn)
            input = formatInput(pluginArguments(inputs))
            pluginOut = globalv.loadedPlugins[toReturn.split()[0]].action(
                input)
            return pluginOut

        return ["PRIVMSG $C$ :" + toReturn]
示例#11
0
 def action(self, complete):
     msg = complete.message()
     isElevated = (isAllowed(complete.userMask()) >= getLevel(
         complete.cmd()[0]))
     self.__init_answers__(complete)
     if len(msg.split()) >= 1:
         cmd = msg.split()[0]
         msg = ' '.join(msg.split()[1:])
     else:
         cmd = ""
         msg = ""
     if cmd == "-add" and isElevated:
         settingsHandler.writeSetting("'" + complete.cmd()[0] + "'",
                                      "answer", msg)
         toReturn = "Added that answer"
         self.__init_answers__(complete)
     elif cmd == "-delete" and isElevated:
         settingsHandler.deleteSetting("'" + complete.cmd()[0] + "'",
                                       "answer", msg)
         toReturn = "Wiped that answer."
         self.__init_answers__(complete)
     elif cmd == "-wipe" and isElevated:
         settingsHandler.dropTable("'" + complete.cmd()[0] + "'")
         settingsHandler.newTable("'" + complete.cmd()[0] + "'", "answer")
         toReturn = "Answer table wiped!"
         self.__init_answers__(complete)
     elif cmd == "-dump":
         self.__init_answers__(complete)
         return [
             "PRIVMSG $C$ :[%s]" %
             ', '.join(["'" + x + "'" for x in self.answers])
         ]
     else:
         toReturn = self.answers.pop()
         if complete.message() == "":
             toReturn = toReturn.replace("$1$", "$U$")
         else:
             toReturn = toReturn.replace("$1$", complete.message())
     return ["PRIVMSG $C$ :" + toReturn]
示例#12
0
    def action(self, complete):
        msg=complete.message()
        isElevated=(isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]))
        beRandom=True
        if len(self.answers)==0:
            self.__init_answers__(complete,beRandom)
        if len(msg.split())>=1:
            cmd=msg.split()[0]
            msg=' '.join(msg.split()[1:])
        else:
            cmd=""
            msg=""
        if cmd=="-add" and isElevated:
            settingsHandler.writeSetting("'"+complete.cmd()[0]+"'","answer",msg)
            toReturn="Added that answer"
            self.__init_answers__(complete,beRandom)
        elif cmd=="-delete" and isElevated:
            settingsHandler.deleteSetting("'"+complete.cmd()[0]+"'","answer",msg)
            toReturn="Wiped that answer."
            self.__init_answers__(complete,beRandom)
        elif cmd=="-wipe" and isElevated:
            settingsHandler.dropTable("'"+complete.cmd()[0]+"'")
            settingsHandler.newTable("'"+complete.cmd()[0]+"'","answer")
            toReturn="Answer table wiped!"
            self.__init_answers__(complete,beRandom)
        elif cmd=="-reset" and isElevated:
            self.__init_answers__(complete,beRandom)
            toReturn="Re-randomising list..."
        else:
            toReturn=self.answers.pop()
            inputs=":%s PRIVMSG %s :!%s"%(complete.userMask(), complete.channel(), toReturn)
            input=formatInput(pluginArguments(inputs))
            pluginOut=globalv.loadedPlugins[toReturn.split()[0]].action(input)
            return pluginOut

        return ["PRIVMSG $C$ :"+toReturn]
示例#13
0
文件: 8ball.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     if settingsHandler.tableExists("'"+name+"'")==False:
         settingsHandler.newTable("'"+name+"'","answer")
         answers=["As I see it, yes","It is certain","It is decidedly so","Most likely","Outlook good","Signs point to yes", "Without a doubt", "Yes", "Yes - definitely","You may rely on it", "Reply hazy, try again","Ask again later", "Better not tell you now","Cannot predict now","Concentrate and ask again","Don't count on it","My reply is no","My sources say no","Outlook not so good","Very doubtful"]
         for answer in answers:
             settingsHandler.writeSetting("'"+name+"'", "answer",answer)
示例#14
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "noKickUsers")
示例#15
0
文件: chohan.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     if settingsHandler.tableExists("chohan")==False:
         settingsHandler.newTable("chohan", "nick","points")
示例#16
0
 for line in settingsHandler.readSettingRaw("alias","aliasName, aliasPlugin, aliasArguments"):
     print line
     load_alias(line[0], ' '.join(line[1:]))
 print "Loading input sources..."
 if settingsHandler.tableExists("'core-input'"):
     for input in []: #settingsHandler.readSettingRaw("'core-input'","input, definition"):
         if input[0] not in globalv.loadedInputs.keys():
             x=__import__(str(input[1].split()[0]))
             reload(x)
             arguments=str(' '.join(input[1].split()[1:]))
             arguments=arguments.split()
             globalv.loadedInputs[input[0]]=globalv.input.addInputSource(x.asyncInput,tuple(arguments))
         else:
             globalv.loadedInputs[input[0]].put(str(input[1]))
 else:
     settingsHandler.newTable("'core-input'","input", "definition")
 for input in globalv.loadedInputs.keys():
     globalv.loadedInputs[input].put("--init--")
 globalv.input.addInputSource(asyncInput)
 print "Loading output threads..."
 #outputQueue=Queue.Queue(10)
 #outputThread=threading.Thread(target=asyncOutput, args=(outputQueue,))
 #outputThread.start()
 #initialise connection
 for server in servers:
   irc = socket.socket (socket.AF_INET, socket.SOCK_STREAM) #Initialise the socket prior to connection
   irc.settimeout(380)#So we time-out when we time-out.
   print "Connecting to %s:%s..."%(server, port)
   try:
     irc.connect ((server,port)) #Connect!
   except:
示例#17
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name,"key","value")
示例#18
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable("tumblrdIgnores", "ignore")
     settingsHandler.newTable("tumblrd", "username", "password")
示例#19
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable("greetd", "channel", "greet")
示例#20
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable("stripMCBotNames", "minecraft", "irc")
示例#21
0
文件: vote.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "votes","plugin")
     settingsHandler.writeSetting(name,["votes","plugin"],["3","9"])
示例#22
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "kickAfterBan")
     settingsHandler.writeSetting(name, "kickAfterBan", "False")
示例#23
0
文件: quit.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self,name):
     import settingsHandler
     settingsHandler.newTable(name,"userRequirement")
     settingsHandler.writeSetting(name,"userRequirement","elevated")
示例#24
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "showTitle","showLink","showLyrics","showPreview")
     settingsHandler.writeSetting(name,["showTitle","showLink","showLyrics","showPreview"],["True","False","False","False"])
示例#25
0
 def __init_db_tables__(self,name):
     import settingsHandler
     settingsHandler.newTable(name, "url", "regex","numMatches","matchText")
     settingsHandler.writeSetting(name,["url","regex","numMatches","matchText"],["http://google.com/complete/search?output=toolbar&q=$*$",".*","1","Autocomplete Results:"])
示例#26
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "nickname")
     settingsHandler.writeSetting(name, "nickname", globalv.owner)
示例#27
0
文件: wget.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "location")
     settingsHandler.writeSetting(name, "location","/home/py/")
示例#28
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "showDomainLink")
     settingsHandler.writeSetting(name, ["showDomainLink"], ["true"])
示例#29
0
class pluginClass(plugin):
    def gettype(self):
        return "realtime"

    def __init__(self):
        self.lastURLs = []

    def __init_db_tables__(self, name):
        settingsHandler.newTable("tumblrdIgnores", "ignore")
        settingsHandler.newTable("tumblrd", "username", "password")

    def action(self, completeargs):
        def makeRequest(reqData, async=True):
            success = False
            failed = 0 if async else 14
            while not success:
                try:
                    con = urllib2.urlopen(req, None, 10)
                    success = True
                except:
                    failed += 1
                    print "Tumblrd failed", failed, "times."
                    if failed > 15:
                        success = True
                    time.sleep(30)

        if not settingsHandler.tableExists("tumblrdIgnores"):
            settingsHandler.newTable("tumblrdIgnores", "ignore")
        complete = completeargs.complete()[1:].split(' :', 1)
        imageFileTypes = [".jpg", ".png", ".bmp"]
        username = settingsHandler.readSetting("tumblrd", "username")
        password = settingsHandler.readSetting("tumblrd", "password")
        ignores = [
            x[0].lower()
            for x in settingsHandler.readSettingRaw("tumblrdIgnores", "ignore")
        ]
        if completeargs.channel().lower() in ignores or completeargs.user(
        ).lower() in ignores:
            return [""]
        if len(complete[0].split()) > 2:
            if complete[0].split()[1] == "PRIVMSG":
                msg = complete[1]
                sender = complete[0].split(' ')
                sender = sender[2]
                if msg.find('http://') != -1 or msg.find('https://') != -1:
                    url = re.search(".*(?P<url>https?://.+?)[\".,?!]?\s",
                                    msg + " ").group("url")
                    if url in self.lastURLs:
                        return [""]
                    else:
                        self.lastURLs.append(url)
                        if len(self.lastURLs) > 10:
                            self.lastURLs.pop(0)
                    logindata = {
                        'email':
                        username,
                        "password":
                        password,
                        "tags":
                        ','.join((completeargs.channel(), completeargs.user()))
                    }
                    if url[-4:].lower() in imageFileTypes:
                        uploaddata = {"type": "photo", "source": url}
                    elif url.lower().find("youtube.com/watch") != -1:
                        request = urllib2.urlopen(url)
                        page = request.read(10000).replace('\n', '')
                        print page
                        title = re.findall("<\s*title\s*>(.*?)</title\s*>",
                                           page, re.I)
                        print title
                        title = title[0]
                        uploaddata = {
                            "type": "video",
                            "embed": url,
                            "caption": title
                        }
                    else:
                        uploaddata = {"type": "link", "url": url}
                    logindata.update(uploaddata)
                    print logindata
                    uploadData = urllib.urlencode(logindata)
                    req = urllib2.Request("http://www.tumblr.com/api/write",
                                          uploadData)
                    print "Constructing thread..."
                    thread = threading.Thread(target=makeRequest, args=(req, ))
                    print "Launching thread..."
                    try:
                        thread.start()
                        print "Thread launched..."
                    except:
                        print "Thread failed to launch - using synchronous fallback"
                        makeRequest(req, False)
                        print "Sucessfully submitted data"
        return [""]
示例#30
0
def createAutoload():
    settingsHandler.newTable("coreAutoLoad", "plugin", "loadAs")
    settingsHandler.writeSetting("coreAutoLoad", ["plugin", "loadAs"], ["load", "load"])
    settingsHandler.writeSetting("coreAutoLoad", ["plugin", "loadAs"], ["autoidentifyd", "autoidentifyd"])
示例#31
0
文件: ban.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "kickAfterBan")
     settingsHandler.writeSetting(name, "kickAfterBan", "False")
示例#32
0
def createDatabase():
    settingsHandler.newTable("core", "nickname", "password", "owner", "server", "port")
    newName = raw_input("Bot Name? ")
    newPassword = raw_input("Nickname password? ")
    newOwner = raw_input("Owner name? ")
    newServer = raw_input("Connect to what server? ")
    newPort = raw_input("On what port (6667 is standard)? ")
    settingsHandler.writeSetting("core", ["nickname", "password", "owner", "server", "port"],
            [newName, newPassword, newOwner, newServer, newPort])
    settingsHandler.newTable("'core-nickmasks'", "nick", "hostmask")
    newChannel = raw_input("Channel to auto-join? ")
    settingsHandler.newTable("coreAutoJoin", "channel")
    settingsHandler.writeSetting("coreAutoJoin", ["channel"], [newChannel])

    settingsHandler.newTable("alias", "aliasName", "aliasPlugin", "aliasArguments")
    settingsHandler.newTable("'core-userlevels'", "plugin", "level")
    settingsHandler.newTable("coreIgnorance", "ignorance", "nickname")
    settingsHandler.newTable("'core-input'", "input", "definition")
    settingsHandler.newTable("'core-expansions'", "trigger", "command")
    settingsHandler.newTable("'core-doNotExpand'", "doNotExpand")
    settingsHandler.newTable("autoidentifyd", "nickname", "level")
    settingsHandler.newTable("coreSettings", "verboseAutoComplete")
    settingsHandler.writeSetting("coreSettings", ["verboseAutoComplete"], ["True"])
    settingsHandler.writeSetting("autoidentifyd", ["nickname", "level"], [newOwner, "1000"])
示例#33
0
文件: laterd.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable("laterd", "id", "recipient","sender","senderMask","timestamp","message", "channel", "anonymous",  "sent")
示例#34
0
文件: noSpam.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "timeLimit", "numberLimit")
     settingsHandler.writeSetting(name,["timeLimit","numberLimit"],["30","6"])
示例#35
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "meme")
示例#36
0
 def __init_db_tables__(self, name):
     if settingsHandler.tableExists("chohan") == False:
         settingsHandler.newTable("chohan", "nick", "points")
示例#37
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "timeLimit", "numberLimit")
     settingsHandler.writeSetting(name, ["timeLimit", "numberLimit"],
                                  ["30", "6"])
示例#38
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "location")
     settingsHandler.writeSetting(name, "location", "/home/py/")
示例#39
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "votes", "plugin")
     settingsHandler.writeSetting(name, ["votes", "plugin"], ["3", "9"])
示例#40
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable("laterd", "id", "recipient", "sender",
                              "senderMask", "timestamp", "message",
                              "channel", "anonymous", "sent")
示例#41
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "showTitle")
     settingsHandler.writeSetting(name,"showTitle","True")
示例#42
0
from plugins import plugin
示例#43
0
文件: greetd.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable("greetd","channel","greet")
示例#44
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "key", "value")
示例#45
0
文件: logd.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable("logd", "ignore")
示例#46
0
 def __init_db_tables__(self, name):
     if settingsHandler.tableExists("'"+name+"'")==False:
         settingsHandler.newTable("'"+name+"'","answer")
示例#47
0
文件: np.py 项目: Phoshi/OMGbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "IRCnick", "LASTFMnick")
示例#48
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "showDomainLink")
     settingsHandler.writeSetting(name, ["showDomainLink"], ["true"])
示例#49
0
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "trigger","text")
示例#50
0
文件: np.py 项目: JoshDreamland/xbot
 def __init_db_tables__(self, name):
     settingsHandler.newTable(name, "IRCnick", "LASTFMnick")