예제 #1
0
 def __init__(
         self,
         ircbot,
         cache_time=None,
         random_message=[6 * 60 * 60, 24 * 60 * 60]  # between 6 h and 24 h
 ):
     Plugin.__init__(self, ircbot, cache_time, random_message)
예제 #2
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if msg in ("!lectures"):
            self.ircbot.switch_personality("infod")

            #get data from cache
            reload_data, self.lectures = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.lectures = self._get_lectures()
                self.save_cache(data=self.lectures)

            message = ""
            for lecture in self.lectures:
                message += "%s - %s" % (
                    lecture["time"], lecture["title"],
                )
                if lecture["lecturer"]:
                    message += " (%s)" % lecture["lecturer"]
                message += ", room %s\n" % lecture["room"]

            if message == "":
                message = "There are currently no lectures!"

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message.strip().encode("utf-8"))

            self.ircbot.reset_personality()
예제 #3
0
파일: wm.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!wm"):
            #self.ircbot.switch_personality(nick="KMH")

            #NO CACHING

            if msg == "!wm":
                message = "--- WM 2014 today ---\n"
                message += self._get_fixtures()

            elif msg in (
                "!wm+A", "!wm+B", "!wm+C", "!wm+D", "!wm+E", "!wm+F",
                "!wm+G", "!wm+H",
            ):
                message = "--- WM 2014 - Group %s ---\n" % msg[-1]
                message += self._get_groups(msg[-1])

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)
예제 #4
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if msg in ("!lectures"):
            self.ircbot.switch_personality("infod")

            #get data from cache
            reload_data, self.lectures = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.lectures = self._get_lectures()
                self.save_cache(data=self.lectures)

            message = ""
            for lecture in self.lectures:
                message += "%s - %s" % (
                    lecture["time"],
                    lecture["title"],
                )
                if lecture["lecturer"]:
                    message += " (%s)" % lecture["lecturer"]
                message += ", room %s\n" % lecture["room"]

            if message == "":
                message = "There are currently no lectures!"

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message.strip().encode("utf-8"))

            self.ircbot.reset_personality()
예제 #5
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg in ("!mensa", "!mensa+1"):
            self.ircbot.switch_personality("souschef")

            #get data from cache
            reload_data, self.days = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.days = self._get_dishes()
                self.save_cache(data=self.days)

            if msg == "!mensa":
                message = self._get_today()
                if message:
                    message = message.replace("DAY", "heute")
                else:
                    message = "Die Küche hat heute bereits geschlossen."
            elif msg == "!mensa+1":
                message = self._get_tomorrow()
                if message:
                    message = message.replace("DAY", "morgen")
                else:
                    message = "Die Küche hat morgen geschlossen."

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #6
0
파일: uniliga.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!uniliga"):
            #get data from cache

            self.ircbot.switch_personality(nick="derTitan")

            #load data from cache
            reload_data, data = self.load_cache()
            if data:
                self.matches = data["matches"]
                self.table   = data["table"]
            if reload_data:
                #reload the data, if too old
                self._get_uniliga_results()
                self.save_cache(
                    data={
                        "matches" : self.matches, "table" : self.table
                    }
                )

            #get last and next day
            last_day, next_day = self._get_last_day()

            #build message depending on given parameter
            message = "--- Uni-Liga powered by Stoppelhopser  ---\n\n"
            if msg == "!uniliga":
                message  += "%s\n%s" % (
                    self._match_day(last_day),
                    self._get_table()
                )

            elif msg == "!uniliga+last":
                if last_day is not None:
                    message += self._match_day(last_day)
                else:
                    message += "There is no last day!"

            elif msg == "!uniliga+next":
                if next_day is not None:
                    message += self._match_day(next_day)
                else:
                    message += "There is no next day!"

            elif msg == "!uniliga+table":
                message += self._get_table()

            elif msg == "!uniliga+all":
                for match_day in self.matches.keys():
                    message += "%s\n" % self._match_day(match_day)

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #7
0
파일: wetter.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!wetter"):
            #get data from cache

            self.ircbot.switch_personality(nick="kachelmann")

            reload_data, self.days = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.days = self._get_weather()
                self.save_cache(data=self.days)

            if msg == "!wetter" or msg == "!wetter_heute":
                message = "--- Wetter heute in Göttingen: ---\n"
                message += self._get_today()

            elif msg == "!wetter+1" or msg == "!wetter_morgen":
                message = "--- Wetter morgen in Göttingen: ---\n"
                message += self._get_tomorrow()

            elif msg == "!wetter+2" or msg == "!wetter_uebermorgen":
                message = "--- Wetter übermorgen in Göttingen: ---\n"
                message += self._get_tomorrow()

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #8
0
파일: yt.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg == "!yt":
            self.ircbot.switch_personality(nick="ytroulet")
            self.ircbot.privmsg(
                params[0],
                random.choice(self.urls).encode("utf-8")
            )
            self.ircbot.reset_personality()

        else:
            res = re.compile(r".*(youtube\.com/.*v=[^&]*)").search(msg)
            if res:
                #create https url
                url = "http://www.%s" % res.group(1)

                if url not in self.urls:
                    #store url, if not existing yet
                    self.urls.append(url)
                    self.save_cache(data=self.urls)

                #get info from youtube url
                info = self._get_information(self.urls[-1])
                if info["comments"]:
                    self.ircbot.privmsg(
                        params[0],
                        random.choice(info["comments"])[:255].encode(
                            "ascii", "ignore"
                        )
                    )
예제 #9
0
파일: wm.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!wm"):
            #self.ircbot.switch_personality(nick="KMH")

            #NO CACHING

            if msg == "!wm":
                message = "--- WM 2014 today ---\n"
                message += self._get_fixtures()

            elif msg in (
                    "!wm+A",
                    "!wm+B",
                    "!wm+C",
                    "!wm+D",
                    "!wm+E",
                    "!wm+F",
                    "!wm+G",
                    "!wm+H",
            ):
                message = "--- WM 2014 - Group %s ---\n" % msg[-1]
                message += self._get_groups(msg[-1])

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)
예제 #10
0
파일: ifi.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg == "!ifi":
            self.ircbot.switch_personality(nick="chiefsec")

            #get data from cache
            reload_data, self.data = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.data = self._get_news()
                self.save_cache(data=self.data)
            else:
                self.data = self.data.encode("utf-8")

            message = "--- IfI News: ---\n"
            if self.data:
                message += self.data
            else:
                message += "there are currently no news!"

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #11
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg in ("!mensa", "!mensa+1"):
            self.ircbot.switch_personality("souschef")

            #get data from cache
            reload_data, self.days = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.days = self._get_dishes()
                self.save_cache(data=self.days)
            
            if msg == "!mensa":
                message = self._get_today()
                if message:
                    message = message.replace("DAY", "heute")
                else:        
                    message = "Die Küche hat heute bereits geschlossen."
            elif msg == "!mensa+1":
                message = self._get_tomorrow()
                if message:
                    message = message.replace("DAY", "morgen")
                else:
                    message = "Die Küche hat morgen geschlossen."

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #12
0
파일: gwdg.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg == "!gwdg":
            self.ircbot.switch_personality("murphy")

            #get data from cache
            reload_data, self.breakdowns = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.breakdowns = self._get_breakdowns()
                self.save_cache(data=self.breakdowns)

            self.breakdowns = self._get_breakdowns()
            if len(self.breakdowns) > 0:
                message = "--- GWDG-Breakdowns ---\n"
                for b in self.breakdowns:
                    message += "%s  %s\n" % (
                        str(b["pubdate"]), b["title"]
                    )

            else:
                message = "Unbelievable, but there were no " \
                          "breakdowns at GWDG recently!"


            #finally, send the message with the
            self.ircbot.privmsg(params[0], message.encode("utf-8").strip())

            self.ircbot.reset_personality()
예제 #13
0
파일: wetter.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!wetter"):
            #get data from cache

            self.ircbot.switch_personality(nick="kachelmann")

            reload_data, self.days = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.days = self._get_weather()
                self.save_cache(data=self.days)

            if msg == "!wetter" or msg == "!wetter_heute":
                message = "--- Wetter heute in Göttingen: ---\n"
                message += self._get_today()

            elif msg == "!wetter+1" or msg == "!wetter_morgen":
                message = "--- Wetter morgen in Göttingen: ---\n"
                message += self._get_tomorrow()

            elif msg == "!wetter+2" or msg == "!wetter_uebermorgen":
                message = "--- Wetter übermorgen in Göttingen: ---\n"
                message += self._get_tomorrow()

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #14
0
    def __init__(self,
                 ircbot,
                 cache_time=datetime.timedelta(hours=1),
                 random_message=[None, None]):
        Plugin.__init__(self, ircbot, cache_time, random_message)

        self.__nickname = None
예제 #15
0
 def __init__(
         self,
         ircbot,
         cache_time=None,
         random_message=[4 * 60 * 60, 8 * 60 * 60]  # between 4 h and 8 h
 ):
     Plugin.__init__(self, ircbot, cache_time, random_message)
예제 #16
0
    def __init__(
        self, ircbot, cache_time=datetime.timedelta(hours=1),
        random_message=[None, None]
    ):
        Plugin.__init__(self, ircbot, cache_time, random_message)

        self.__nickname = None
예제 #17
0
파일: gwdg.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg == "!gwdg":
            self.ircbot.switch_personality("murphy")

            #get data from cache
            reload_data, self.breakdowns = self.load_cache()
            if reload_data:
                #reload the data, if too old
                self.breakdowns = self._get_breakdowns()
                self.save_cache(data=self.breakdowns)

            self.breakdowns = self._get_breakdowns()
            if len(self.breakdowns) > 0:
                message = "--- GWDG-Breakdowns ---\n"
                for b in self.breakdowns:
                    message += "%s  %s\n" % (str(b["pubdate"]), b["title"])

            else:
                message = "Unbelievable, but there were no " \
                          "breakdowns at GWDG recently!"

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message.encode("utf-8").strip())

            self.ircbot.reset_personality()
예제 #18
0
파일: uniliga.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!uniliga"):
            #get data from cache

            self.ircbot.switch_personality(nick="derTitan")

            #load data from cache
            reload_data, data = self.load_cache()
            if data:
                self.matches = data["matches"]
                self.table = data["table"]
            if reload_data:
                #reload the data, if too old
                self._get_uniliga_results()
                self.save_cache(data={
                    "matches": self.matches,
                    "table": self.table
                })

            #get last and next day
            last_day, next_day = self._get_last_day()

            #build message depending on given parameter
            message = "--- Uni-Liga powered by Stoppelhopser  ---\n\n"
            if msg == "!uniliga":
                message += "%s\n%s" % (self._match_day(last_day),
                                       self._get_table())

            elif msg == "!uniliga+last":
                if last_day is not None:
                    message += self._match_day(last_day)
                else:
                    message += "There is no last day!"

            elif msg == "!uniliga+next":
                if next_day is not None:
                    message += self._match_day(next_day)
                else:
                    message += "There is no next day!"

            elif msg == "!uniliga+table":
                message += self._get_table()

            elif msg == "!uniliga+all":
                for match_day in self.matches.keys():
                    message += "%s\n" % self._match_day(match_day)

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #19
0
파일: static.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg in STATIC_MESSAGES:
            #finally, send the message with the
            self.ircbot.privmsg(params[0], random.choice(STATIC_MESSAGES[msg]))
예제 #20
0
파일: yt.py 프로젝트: akellne/toolshed
    def __init__(
        self, ircbot, cache_time=datetime.timedelta(days=365*10),
        random_message=[None, None]
    ):
        Plugin.__init__(self, ircbot, cache_time, random_message)

        #load all urls from cache
        reload_data, self.urls = self.load_cache()
        if self.urls is None:
            self.urls = []
예제 #21
0
    def on_msg(self, cmd, sender, msg, *params):
        Plugin.on_msg(self, cmd, sender, msg, *params)

        if cmd == 'PRIVMSG' and msg == "\x01VERSION\x01":
            try:
                self.__nickname = params[0]
            except: pass

        if cmd == 'JOIN':
            self.on_join(sender, msg, *params)
예제 #22
0
파일: film.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!film"):
            title = ' '.join(msg.split(' ')[1:])
            message = self.get_film(title)
            self.ircbot.privmsg(params[0], message)
예제 #23
0
파일: film.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!film"):
            title = ' '.join(msg.split(' ')[1:])
            message = self.get_film(title)
            self.ircbot.privmsg(params[0], message)
예제 #24
0
    def on_msg(self, cmd, sender, msg, *params):
        Plugin.on_msg(self, cmd, sender, msg, *params)

        if cmd == 'PRIVMSG' and msg == "\x01VERSION\x01":
            try:
                self.__nickname = params[0]
            except:
                pass

        if cmd == 'JOIN':
            self.on_join(sender, msg, *params)
예제 #25
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg == "!durchsage":
            self.ircbot.privmsg(params[0], self.durchsage())

        if "bahn" in msg and random.random() < 0.5:
            self.ircbot.privmsg(params[0], self.durchsage())
예제 #26
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg == "!durchsage":
            self.ircbot.privmsg(params[0], self.durchsage())

        if "bahn" in msg and random.random() < 0.5:
            self.ircbot.privmsg(params[0], self.durchsage())
예제 #27
0
파일: kino.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!kino"):
            self.ircbot.switch_personality(nick="popcorn")
            message = self.get_kino()
            self.ircbot.privmsg(params[0], message)
            self.ircbot.reset_personality()
예제 #28
0
파일: static.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg in STATIC_MESSAGES:
            #finally, send the message with the
            self.ircbot.privmsg(
                params[0], random.choice(STATIC_MESSAGES[msg])
            )
예제 #29
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!bundesliga"):
            self.ircbot.switch_personality(nick="loddar")
            message = self.get_bundesliga()
            self.ircbot.privmsg(params[0], message)
            self.ircbot.reset_personality()
예제 #30
0
파일: bus.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!bus"):
            self.ircbot.switch_personality(nick="busfahrer")

            message = "--- Gleich an der Goldschmidtstrasse ---\n"
            message += self.get_bus()

            self.ircbot.privmsg(params[0], message)
            self.ircbot.reset_personality()
예제 #31
0
    def __init__(self,
                 ircbot,
                 cache_time=datetime.timedelta(days=1),
                 random_message=[None, None]):
        Plugin.__init__(self, ircbot, cache_time, random_message)

        #set locale to German (required for parsing the German date)
        try:
            locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")
        except Exception, e:
            print "de_DE.UTF-8 needs to be generated so that the " \
                  "date can be parsed correctly! (use 'dpkg-" \
                  "reconfigure locales' to generate the " \
                  "corresponding locales)"
            sys.exit(1)
예제 #32
0
파일: gwdg.py 프로젝트: akellne/toolshed
    def __init__(
        self, ircbot, cache_time=datetime.timedelta(days=0),
        random_message=[None, None]
    ):
        Plugin.__init__(self, ircbot, cache_time, random_message)

        #set locale to German (required for parsing the German date)
        try:
            locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")
        except Exception, e:
            print "de_DE.UTF-8 needs to be generated so that the " \
                  "date can be parsed correctly! (use 'dpkg-" \
                  "reconfigure locales' to generate the " \
                  "corresponding locales)"
            sys.exit(1)
예제 #33
0
파일: bus.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!bus"):
            self.ircbot.switch_personality(nick="busfahrer")

            message = "--- Gleich an der Goldschmidtstrasse ---\n"
            message += self.get_bus()

            self.ircbot.privmsg(params[0], message)
            self.ircbot.reset_personality()
예제 #34
0
파일: analyse.py 프로젝트: akellne/toolshed
    def __init__(
        self, ircbot, cache_time=datetime.timedelta(days=1),
        random_message=[None, None]
    ):
        Plugin.__init__(self, ircbot, cache_time, random_message)

        #get data from cache
        reload_data, self.count = self.load_cache()
        if not self.count:
            #not cached yet, reset counts
            self.count = {}

        #dict with positive and negative words that are matched
        self.words = {}

        #load wordlists
        self._load_words()
예제 #35
0
파일: analyse.py 프로젝트: akellne/toolshed
    def __init__(self,
                 ircbot,
                 cache_time=datetime.timedelta(days=1),
                 random_message=[None, None]):
        Plugin.__init__(self, ircbot, cache_time, random_message)

        #get data from cache
        reload_data, self.count = self.load_cache()
        if not self.count:
            #not cached yet, reset counts
            self.count = {}

        #dict with positive and negative words that are matched
        self.words = {}

        #load wordlists
        self._load_words()
예제 #36
0
파일: bahn.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!bahn"):
            self.ircbot.switch_personality(nick="DB")
            if msg == "!bahn+berlin":
                message = self._get_bahn(to_="Berlin")
            elif msg == "!bahn+hannover":
                message = self._get_bahn(to_="Hannover")
            else:
                message = "unknown destination"

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #37
0
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg == "!fastfood":
            #get data from cache
            self.ircbot.switch_personality(nick="bkismyway")

            reload_data, message = self.load_cache()
            if reload_data:
                #reload the data, if too old
                message = self._get_king_of_the_month()
                self.save_cache(data=message)
            else:
                message = message.encode("utf-8")

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()
예제 #38
0
def get_plugins():
    """
    find all files in the plugin directory and import them
    """
    #get plugin directory and add it to the path
    plugin_dir = os.path.relpath(os.path.dirname(__file__))

    #get plugin files
    plugin_files = [
        filename
        for filename in glob.glob("%s/*.py" % plugin_dir )
        if not filename.endswith("__init__.py")
    ]

    #import all plugins (except base plugin)
    for plugin_file in plugin_files:
        plugin = os.path.splitext(plugin_file)[0].replace("/", ".")
        if not plugin.endswith("base"):
            mod = __import__(plugin)

    return Plugin.__subclasses__()
예제 #39
0
def make_plugin():
    return Plugin(AddrEncoder)
예제 #40
0
 def __init__(self, paginated, *args, **opts):
     self.paginated = paginated
     Plugin.__init__(self, *args, **opts)
예제 #41
0
def make_plugin():
    return Plugin(StackEval)
예제 #42
0
파일: analyse.py 프로젝트: akellne/toolshed
    def on_quit(self):
        Plugin.on_quit(self)

        #save all results in the cache
        self.save_cache(data=self.count)
예제 #43
0
파일: wm.py 프로젝트: akellne/toolshed
 def __init__(self,
              ircbot,
              cache_time=datetime.timedelta(minutes=1),
              random_message=[None, None]):
     Plugin.__init__(self, ircbot, cache_time, random_message)
예제 #44
0
파일: wm.py 프로젝트: akellne/toolshed
 def __init__(
     self, ircbot, cache_time=datetime.timedelta(minutes=1),
     random_message=[None, None]
 ):
     Plugin.__init__(self, ircbot, cache_time, random_message)
예제 #45
0
 def __init__(
     self, ircbot, cache_time=None,
     random_message=[4 * 60 * 60, 8 * 60 * 60] # between 4 h and 8 h
 ):
     Plugin.__init__(self, ircbot, cache_time, random_message)
예제 #46
0
파일: bahn.py 프로젝트: akellne/toolshed
 def __init__(
     self, ircbot, cache_time=None,
     random_message=[None, None]
 ):
     Plugin.__init__(self, ircbot, cache_time, random_message)
예제 #47
0
def make_plugin():
    return Plugin(ScriptGenerator)
예제 #48
0
def make_plugin():
    return Plugin(Variables)
예제 #49
0
 def __init__(
     self, ircbot, cache_time=None,
     random_message=[6 * 60 * 60, 24 * 60 * 60] # between 6 h and 24 h
 ):
     Plugin.__init__(self, ircbot, cache_time, random_message)
예제 #50
0
def make_plugin():
    return Plugin(TxBuilder)
예제 #51
0
def make_plugin():
    p = Plugin(ChainParams)
    p.has_gui = False
    return p
예제 #52
0
파일: analyse.py 프로젝트: akellne/toolshed
    def on_privmsg(self, msg, *params):
        Plugin.on_privmsg(self, msg, *params)

        if not self.is_in_channel(params[0]):
            #plugin not available in the channel => return
            return

        if msg.startswith("!analyse"):
            #react to command

            self.ircbot.switch_personality("yogeshwar")

            message =  "--- sentiment analysis ---\n"
            total = {
                "positive" : 0.0,
                "positive_score" : 0.0,
                "negative" : 0.0,
                "negative_score" : 0.0,
                "neutral" : 0.0,
            }
            for k in sorted(self.count.keys()):
                dt = datetime.datetime.strptime(k, "%Y%m%d")
                total["positive"] += (
                    self.count[k]["positive"] / 
                    float(self.count[k]["total"]) * 100
                ) / len(self.count.keys())
                total["positive_score"] += self.count[k]["positive_score"]
                total["negative"] += (
                    self.count[k]["negative"] / 
                    float(self.count[k]["total"]) * 100
                ) / len(self.count.keys())
                total["negative_score"] += self.count[k]["negative_score"]
                total["neutral"] += (
                    self.count[k]["neutral"] / 
                    float(self.count[k]["total"]) * 100
                ) / len(self.count.keys())
                
            from_ = datetime.datetime.strptime(self.count.keys()[0], "%Y%m%d")
            to_   = datetime.datetime.strptime(self.count.keys()[-1], "%Y%m%d")
            message = "--- sentiment analysis from %s to %s ---\n" \
                      "positive: %2.2f%% [score: %2.2f]\n" \
                      "negative:  %2.2f%% [score: %2.2f]\n" \
                      "neutral:  %2.2f%% (unknown)\n" % (
                          from_.strftime("%d/%m/%Y"),
                          to_.strftime("%d/%m/%Y"),
                          total["positive"], total["positive_score"],
                          total["negative"], total["negative_score"],
                          total["neutral"]
                      )

            #finally, send the message with the
            self.ircbot.privmsg(params[0], message)

            self.ircbot.reset_personality()

        else:
            #not a command => analyse message

            #get current date and use it as key for storing counts
            dt = datetime.datetime.now().strftime("%Y%m%d")
            if dt not in self.count:
                self.count[dt] = {
                    "positive"       : 0,
                    "negative"       : 0,
                    "positive_score" : 0.0,
                    "negative_score" : 0.0,
                    "neutral"        : 0,
                    "total"          : 0,
                }


            #remove some characters
            for s in (".", ",", "!"):
                msg = msg.replace(s, "")

            #split message by spaces
            words = msg.lower().split(" ")
            for w in words:
                #increase counts depending on word type
                self.count[dt]["total"] += 1
                if w in self.words["positive"]:
                    self.count[dt]["positive"] += 1
                    self.count[dt]["positive_score"] += self.words["positive"][w]
                elif w in self.words["negative"]:
                    self.count[dt]["negative"] += 1
                    self.count[dt]["negative_score"] += self.words["negative"][w]
                else:
                    self.count[dt]["neutral"] += 1
예제 #53
0
def make_plugin():
    return Plugin(BlockAnalyzer)
예제 #54
0
def make_plugin():
    p = Plugin(ItemsPlugin)
    p.has_gui = False
    p.instantiate_item = instantiate_item
    p.get_item_actions = get_actions
    return p