예제 #1
0
    def __init__(self):
        PluginBase.__init__(self)
        self.name = 'Trivia'
        self.logger = logging.getLogger('teslabot.plugin.trivia')
        self.alive = True

        try:
            self.channel = Config().get(self.name.lower(), 'channel')
        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
            self.logger.warn('Unable to load trivia plugin. Channel name is missing.')
            # This ensures this plugin is never called
            self._callbacks = []
            return

        # Number of 5 second intervals between asking a question or giving a hint
        self.askpause = 2
        # Default number of questions to ask in a round
        self.defaultnumquestions = 10

        self.startingmsg = u"Trivia starting. Questions: {0}"
        self.stoppingmsg = u"Trivia stopping."
        self.questionmsg = u"Q{2}. [{0}] {1}"
        self.okanswermsg = u"{0} got it for {1} points. Total: {2}, streak: {3}. " \
                           + u"Answer: {4}"
        self.noanswermsg = u"No one got it. The answer was: {0}"
        self.rankingsmsg = u"{0} wins! Final scores: {1}"
        self.skippingmsg = u'Skipping this terrible question.'
        self.nextvotemsg = u'{0} voted to skip this question. {1} more votes needed.'
        self.roundendmsg = u"Round of trivia complete. '.trivia [number]' to start " \
                           + u"playing again."

        self.questions = load_questions(os.path.abspath('plugins/trivia'))
        self.logger.info("Loaded {0} trivia questions.".format(len(self.questions)))

        self.reset()
예제 #2
0
    def __init__(self):
        PluginBase.__init__(self)
        self.name = 'WebTools'
        self.logger = logging.getLogger('teslabot.plugin.webtools')

        # Load imageboard URL parser settings
        try:
            self.imageboard_urls = Config().get(self.name.lower(),
                                                'imageboard').split()
        except ConfigParser.NoSectionError:
            self.logger.debug('Imageboard settings not found.')
            self.imageboard_urls = []

        self.news = {
            'lupdate': None,
            'uinterval': 60 * 5,
            'cur_ed': 'us',
            'set': False,
        }
        self.strings.URL_GOOGLE = 'https://news.google.com/news?edchanged=1&ned={0}&authuser=0'
        self.strings.URL_GOOGLE_SEARCH = 'https://www.google.com/search?hl=en&gl=us&tbm=nws&authuser=0&q={0}'
        self.strings.NO_NEWS_SET = 'There is no news set currently selected. Type news help ' \
            'for more information.'
        self.strings.KEYWORD_NOT_FOUND = 'No news items found.'
        self.strings.NEWS_SET_REFRESHED = 'The news set has been updated!'
예제 #3
0
파일: xdcc.py 프로젝트: rkuchimpos/teslabot
    def __init__(self):
        PluginBase.__init__(self)

        self.name = 'XDCC'
        self.logger = logging.getLogger('teslabot.plugin.XDCC')
        self._qtimeout = 1

        self._dcc_port = 6500
        self._dcc_ip = None
        self.working_dir = None

        try:
            self._dcc_ip = Config().get(self.name.lower(), 'ip')
        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
            pass

        try:
            self._dcc_port = Config().get(self.name.lower(), 'port')
        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
            pass

        try:
            self.working_dir = Config().get(self.name.lower(), 'directory')
            if not os.path.isdir(self.working_dir):
                self.working_dir = None
                self.logger.debug('Provided directory path is not valid.')
        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
            pass
        finally:
            if self.working_dir == None:
                # Cannot load directory path; disable XDCC commands
                self.chat_commands = []
                self.logger.debug('Cannot load directory path. XDCC commands disabled.')

        self._sessions = FileSessionManager(self.working_dir)
        self._server = None
        # A list of DCCSocket clients. They may or may not be active.
        self._manager = DCCSocketManager()
        # Number of activate file transfers
        self._transfers_active = 0
        # Maximum number of file transfers
        self.max_conns = 5
        # Time to wait (in secs) before closing the server to new connections
        self.new_conn_timeout = 20
        # Last time (in UNIX secs) that a new server connection was expected
        self._last_request = None

        self.strings.TRANSFER_FAILURE = u'[{0}] failed!'
        self.strings.TRANSFER_SUCCESS = u'[{0}] was successful!'
        self.strings.QUEUE_FULL = u'There is currently a file transfer ' \
            u'waiting to be accepted. Please try again in a few seconds.'
        self.strings.ACTIVE_CONN_PLURAL = u'There are currently {0} active ' \
            u'connections.'
        self.strings.ACTIVE_CONN_SINGULAR = u'There is currently one active ' \
            u'connection.'
        self.strings.ACTIVE_CONN_NONE = u'There are no active connections.'
예제 #4
0
 def __init__(self):
     PluginBase.__init__(self)
     self.name = 'Statistics'
     self.logger = logging.getLogger('teslabot.plugin.statistics')
     self.conn = None
     self.alive = True
     
     self.path_schema = os.path.abspath('plugins/statistics/schema.sql')
     self.path_statsdb = os.path.abspath('plugins/statistics/stats.sqlite3')
     
     self.channels = {}
     self.users = {}
예제 #5
0
 def __init__(self):
     PluginBase.__init__(self)
     self.name = 'Paulcon'
     self.logger = logging.getLogger('teslabot.plugin.paulcon')
     
     self.LEVEL_MSG = [["IT'S OVER", C_BLACK],
                    ["IT'S HAPPENING", C_RED],
                    ["IT'S TOO LATE", C_RED],
                    ["YOU CAN'T STOP IT", C_BROWN],
                    ["YOU ASKED FOR THIS", C_BROWN],
                    ["YOU COULD HAVE PREVENTED THIS", C_YELLOW],
                    ["WHY DIDN'T YOU LISTEN?", C_YELLOW],
                    ["YOU DIDN'T LISTEN", C_YELLOW],
                    ["IT BEGINS", C_YELLOW],
                    ["IT HASN'T EVEN BEGUN", C_GREEN]]
     self.cur_level = 9
     self.cur_time = datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M')
예제 #6
0
    def __init__(self):
        PluginBase.__init__(self)
        self.name = 'Paulcon'
        self.logger = logging.getLogger('teslabot.plugin.paulcon')

        self.LEVEL_MSG = [["IT'S OVER", C_BLACK], ["IT'S HAPPENING", C_RED],
                          ["IT'S TOO LATE", C_RED],
                          ["YOU CAN'T STOP IT", C_BROWN],
                          ["YOU ASKED FOR THIS", C_BROWN],
                          ["YOU COULD HAVE PREVENTED THIS", C_YELLOW],
                          ["WHY DIDN'T YOU LISTEN?", C_YELLOW],
                          ["YOU DIDN'T LISTEN", C_YELLOW],
                          ["IT BEGINS", C_YELLOW],
                          ["IT HASN'T EVEN BEGUN", C_GREEN]]
        self.cur_level = 9
        self.cur_time = datetime.fromtimestamp(int(
            time.time())).strftime('%Y-%m-%d %H:%M')
예제 #7
0
 def __init__(self):
     PluginBase.__init__(self)
     
     self.name = 'CoreCommands'
     self.logger = logging.getLogger('teslabot.plugin.corecommands')
     
     self.set_cmd('kick', self.CMD_CHANNEL)
     self.set_cmd('kickban', self.CMD_CHANNEL)
     self.set_cmd('ban', self.CMD_CHANNEL)
     self.set_cmd('unban', self.CMD_CHANNEL)
     self.admin_commands = ['reload', 'say', 'action', 'join', 'leave', 'quit', 'nick', 'plugins']
     
     self.lang_001 = 'Plugins: {0}'
     self.lang_002 = 'Type \x0310{0}commands\x03 for a list of available commands. Type \x0310{0}(command) help\x03 ' \
                     'to view the help text of a specific command. Note that the parentheses should not be included.'
     self.lang_003 = 'Goodbye.'
     
     self.users = {}
예제 #8
0
    def __init__(self):
        PluginBase.__init__(self)
        self.name = 'Trivia'
        self.logger = logging.getLogger('teslabot.plugin.trivia')
        self.alive = True

        try:
            self.channel = Config().get(self.name.lower(), 'channel')
        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
            self.logger.warn(
                'Unable to load trivia plugin. Channel name is missing.')
            # This ensures this plugin is never called
            self._callbacks = []
            return

        # Number of 5 second intervals between asking a question or giving a hint
        self.askpause = 2
        # Default number of questions to ask in a round
        self.defaultnumquestions = 20

        self.startingmsg = u"Starting round of trivia. Questions: {0}"
        self.stoppingmsg = u""
        self.questionmsg = u"{2}. {0}: {1}"
        self.okanswermsg = u"Winner: {0}; Answer: {4}; Time: {5}s; Streak: {3}; " \
                           + u"Points: {1}; Total: {2}"
        self.noanswermsg = u"Time's up! The answer was: {0}"
        self.rankingsmsg = u"{0} wins! Final scores: {1}"
        self.skippingmsg = u'Skipping this terrible question.'
        self.nextvotemsg = u'{0} voted to skip this question. {1} more votes needed.'
        self.roundendmsg = u"Round of trivia complete. '.trivia [number]' to start " \
                           + u"playing again."

        self.overallrankmsg = u"{0} is currently ranked #{1} with {2} points, {3} points behind {4}."
        self.overallrankmsg_alt = u"{0} is currently ranked #{1} with {2} points."

        self.questions = load_questions(os.path.abspath('plugins/trivia'))
        self.logger.info("Loaded {0} trivia questions.".format(
            len(self.questions)))

        self.reset()
예제 #9
0
    def __init__(self):
        PluginBase.__init__(self)
        self.name = 'WebTools'
        self.logger = logging.getLogger('teslabot.plugin.webtools')

        # Load imageboard URL parser settings
        try:
            self.imageboard_urls = Config().get(self.name.lower(), 'imageboard').split()
        except ConfigParser.NoSectionError:
            self.logger.debug('Imageboard settings not found.')
            self.imageboard_urls = []

        self.news = {
            'lupdate': None,
            'uinterval': 60*5,
            'cur_ed': 'us',
            'set': False,
        }
        self.strings.URL_GOOGLE = 'https://news.google.com/news?edchanged=1&ned={0}&authuser=0'
        self.strings.URL_GOOGLE_SEARCH = 'https://www.google.com/search?hl=en&gl=us&tbm=nws&authuser=0&q={0}'
        self.strings.NO_NEWS_SET = 'There is no news set currently selected. Type news help ' \
            'for more information.'
        self.strings.KEYWORD_NOT_FOUND = 'No news items found.'
        self.strings.NEWS_SET_REFRESHED = 'The news set has been updated!'