Exemple #1
0
class ModuleAss(ModuleBase):
    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "ModuleAss"
        self.Url = "http://api.obutts.ru/noise/1"
        self.mediaUrl = "http://media.obutts.ru"
        self.limitator = LimitatorMultiple(
            Limitator(5, 60, True),
            Limitator(50, 600, False),
        )

    def notify_command(self, message_id, from_attr, date, chat, commandName,
                       commandStr):
        if commandName == "ass":
            try:
                self.limitator.next(from_attr)
            except LimitatorLimitted:
                self.bot.sendMessage("Pas de petit cul pour toi !", chat["id"])
                return
            response = urllib.request.urlopen(self.Url)
            str_response = response.read().decode('utf-8')
            objJSON = json.loads(str_response)
            print(objJSON)
            imgPath = objJSON[0]['preview']
            if len(imgPath) > 0:
                url = self.mediaUrl + "/" + imgPath
                self.bot.sendPhotoUrl(
                    chat["id"], url,
                    "Et un petit cul pour %s !" % from_attr["first_name"])

    def get_commands(self):
        return [
            ("ass", "Random pretty ass on demand"),
        ]
class ModuleNSFW(ModuleBase):
    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "NSFW"
        self.nsfw = Nsfw(self.logger)
        self.limitator = LimitatorMultiple(
            Limitator(5, 60, True),
            Limitator(50, 600, False),
        )

    def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr):
        if commandName == "bonjour":
            if commandStr == "":
                text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours)
                self.bot.sendMessage(text, chat["id"])
                return
            parserResult = self.nsfw.parse(commandStr)
            if len(parserResult.unknown()) > 0:
                self.bot.sendMessage("bonjour '%s' not found" % "', '".join(parserResult.unknown()), chat["id"])
            try:
                for key in parserResult.known():
                    self.limitator.next(from_attr)
                    result = self.nsfw.image(key, parserResult.mode())
                    if result.ok():
                        self.bot.sendPhotoUrl(chat["id"], result.url(), result.message())
                    else:
                        self.bot.sendMessage(result.message(), chat["id"])
            except LimitatorLimitted:
                self.bot.sendMessage("N'abuse pas mon petit cochon !", chat["id"])


    def get_commands(self):
        return [
            ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours)),
        ]
Exemple #3
0
class ModuleImageFetcher(ModuleBase):
    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "ModuleImageFetcher"
        self.limitator = LimitatorMultiple(
            Limitator(10, 900, True),
            Limitator(120, 60 * 60, False),
        )
        provider = DuckDuckGoImagesProvider()
        self.sender = ImageQuerySender(self.bot, provider)

    #Usage : /img query [--index | --random]
    #Example : /img cara -2
    def notify_command(self, message_id, from_attr, date, chat, commandName,
                       commandStr):
        if commandName == "img":
            if commandStr == "":
                self.bot.sendMessage(
                    "Not enough argument, usage : /img query [-index | -random]",
                    chat["id"])
            else:
                try:
                    self.limitator.next(from_attr)
                except LimitatorLimitted:
                    self.bot.sendMessage("Tu as abusé, réssaye plus tard !",
                                         chat["id"])
                    return
                self.sender.send_next(commandStr, chat["id"])

    def get_commands(self):
        return [
            ("img", "Fetch an image on Google Image"),
        ]
class ModuleImageFetcher(ModuleBase):

    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "ModuleImageFetcher"
        self.limitator = LimitatorMultiple(
            Limitator(10, 900, True),
            Limitator(120, 60*60, False),
        )
        provider = DuckDuckGoImagesProvider()
        self.sender = ImageQuerySender(self.bot, provider)

    #Usage : /img query [--index | --random]
    #Example : /img cara -2
    def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr):
        if commandName == "img":
            if commandStr == "":
                self.bot.sendMessage("Not enough argument, usage : /img query [-index | -random]", chat["id"])
            else:
                try:
                    self.limitator.next(from_attr)
                except LimitatorLimitted:
                    self.bot.sendMessage("Tu as abusé, réssaye plus tard !", chat["id"])
                    return
                self.sender.send_next(commandStr, chat["id"])

    def get_commands(self):
        return [
            ("img", "Fetch an image on Google Image"),
        ]
Exemple #5
0
class ModuleAss(ModuleBase):

    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "ModuleAss"
        self.Url = "http://api.obutts.ru/noise/1"
        self.mediaUrl = "http://media.obutts.ru"
        self.limitator = LimitatorMultiple(
            Limitator(5, 60, True),
            Limitator(50, 600, False),
        )

    def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr):
        if commandName == "ass":
            try:
                self.limitator.next(from_attr)
            except LimitatorLimitted:
                self.bot.sendMessage("Pas de petit cul pour toi !", chat["id"])
                return
            response = urllib.request.urlopen(self.Url)
            str_response = response.read().decode('utf-8')
            objJSON = json.loads(str_response)
            print(objJSON)
            imgPath = objJSON[0]['preview']
            if len(imgPath) > 0:
                url = self.mediaUrl + "/" + imgPath
                self.bot.sendPhotoUrl(chat["id"], url, "Et un petit cul pour %s !" % from_attr["first_name"])

    def get_commands(self):
        return [
            ("ass", "Random pretty ass on demand"),
        ]
Exemple #6
0
class ModuleNSFW(ModuleBase):
    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "NSFW"
        self.nsfw = Nsfw(self.logger)
        self.limitator = LimitatorMultiple(
            Limitator(5, 60, True),
            Limitator(50, 600, False),
        )

    def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr):
        if commandName == "bonjour":
            if commandStr == "":
                text = "Bonjours : %s" % ", ".join(self.nsfw.bonjours_keys)
                self.bot.sendMessage(text, chat["id"])
                return
            parserResult = self.nsfw.parse(commandStr)
            if len(parserResult.unknown()) > 0:
                self.bot.sendMessage("bonjour '%s' not found" % "', '".join(parserResult.unknown()), chat["id"])
            try:
                for key in parserResult.known():
                    self.limitator.next(from_attr)
                    result = self.nsfw.image(key, parserResult.mode())
                    if result.ok():
                        self.bot.sendPhotoUrl(chat["id"], result.url(), result.message())
                    else:
                        self.bot.sendMessage(result.message(), chat["id"])
            except LimitatorLimitted:
                self.bot.sendMessage("N'abuse pas mon petit cochon !", chat["id"])

    def get_commands(self):
        return [
            ("bonjour", "Bonjour. Keywords: <%s> <last/random>" % "/".join(self.nsfw.bonjours_keys)),
        ]
Exemple #7
0
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "NSFW"
     self.nsfw = Nsfw(self.logger)
     self.limitator = LimitatorMultiple(
         Limitator(5, 60, True),
         Limitator(50, 600, False),
     )
Exemple #8
0
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "ModuleImageFetcher"
     self.limitator = LimitatorMultiple(
         Limitator(10, 900, True),
         Limitator(120, 60 * 60, False),
     )
     provider = DuckDuckGoImagesProvider()
     self.sender = ImageQuerySender(self.bot, provider)
Exemple #9
0
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "ModuleAss"
     self.Url = "http://api.obutts.ru/noise/1"
     self.mediaUrl = "http://media.obutts.ru"
     self.limitator = LimitatorMultiple(
         Limitator(5, 60, True),
         Limitator(50, 600, False),
     )
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "ModuleImageFetcher"
     self.limitator = LimitatorMultiple(
         Limitator(10, 900, True),
         Limitator(120, 60*60, False),
     )
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "NSFW"
     self.nsfw = Nsfw(self.logger)
     self.limitator = LimitatorMultiple(
         Limitator(5, 60, True),
         Limitator(50, 600, False),
     )
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "ModuleImageFetcher"
     self.limitator = LimitatorMultiple(
         Limitator(10, 900, True),
         Limitator(120, 60*60, False),
     )
     provider = DuckDuckGoImagesProvider()
     self.sender = ImageQuerySender(self.bot, provider)
Exemple #13
0
 def __init__(self, bot):
     ModuleBase.__init__(self, bot)
     self.name = "ModuleAss"
     self.Url = "http://api.obutts.ru/noise/1"
     self.mediaUrl = "http://media.obutts.ru"
     self.limitator = LimitatorMultiple(
         Limitator(5, 60, True),
         Limitator(50, 600, False),
     )
class ModuleImageFetcher(ModuleBase):

    def __init__(self, bot):
        ModuleBase.__init__(self, bot)
        self.name = "ModuleImageFetcher"
        self.limitator = LimitatorMultiple(
            Limitator(10, 900, True),
            Limitator(120, 60*60, False),
        )

    #Usage : /img query [--index | --random]
    #Example : /img cara -2
    def notify_command(self, message_id, from_attr, date, chat, commandName, commandStr):
        if commandName == "img":

            args = commandStr.split()

            if len(args) > 0:
                try:
                    self.limitator.next(from_attr)
                except LimitatorLimitted:
                    self.bot.sendMessage("Tu as abusé, réssaye plus tard !", chat["id"])
                    return
                searchTerm = ""
                startIndex = 0

                #If the last argument start with "-", it means that it's an index parameter
                if args[-1][0] == "-":

                    #So the search query is composed by every argument but the last one
                    searchTerm = "%20".join(args[:-1]) # %20 -> espace

                    #Check if it's a random or a value
                    if args[-1] == "-random" or args[-1] == "-r":
                        startIndex = random.randint(0,50); #TODO put this values in a variable
                    else:
                        try:
                            startIndex = int(args[-1][1:])
                        except ValueError:
                            pass
                #Otherwise, the start index is still 0 and all the arguments are part of the search query
                else:
                    searchTerm = "%20".join(args) # %20 -> espace

                searchUrl = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" + searchTerm + "&start=" + str(startIndex)
                print("searchUrl : " + searchUrl)

                response = urllib.request.urlopen(searchUrl)

                str_response = response.read().decode('utf-8')
                objJSON = json.loads(str_response)

                if len(objJSON['responseData']['results']) > 0:
                    imageUrl = objJSON['responseData']['results'][0]['unescapedUrl']
                    self.logger.debug("Image URL : " + imageUrl)

                    self.bot.sendPhotoUrl(chat["id"], imageUrl, " ".join(searchTerm.split("%20")))
                else:
                    self.bot.sendMessage("Désolé mon petit %s, aucune image trouvé pour %s" % (from_attr['first_name'], searchTerm), chat["id"])
            else:
                self.bot.sendMessage("Not enough argument, usage : /img query [-index | -random]", chat["id"])

    def get_commands(self):
        return [
            ("img", "Fetch an image on Google Image"),
        ]