Esempio n. 1
0
 def __init__(self, stop_event=None):
     """
     Creates BotSignatures for every account in praw.ini, and initializes a Dispatch.
     :param stop_event: A threading.Event used to stop the Dispatch.
     """
     signatures = [_generate_bot_signature(name) for name in praw_config.get_all_site_names()]
     super(GlobalDispatch, self).__init__(signatures, stop_event)
Esempio n. 2
0
 def __init__(self, stop_event=None):
     """
     Creates BotSignatures for every account in praw.ini, and initializes a Dispatch.
     :param stop_event: A threading.Event used to stop the Dispatch.
     """
     signatures = [
         _generate_bot_signature(name)
         for name in praw_config.get_all_site_names()
     ]
     super(GlobalDispatch, self).__init__(signatures, stop_event)
Esempio n. 3
0
 def __init__(self, stop_event=None):
     """
     Creates BotSignatures for every account in praw.ini, and initializes a Dispatch.
     :param stop_event: A threading.Event used to stop the Dispatch.
     """
     signatures = [BotSignature(classname=praw_config.get_bot_class_name(name),
                                username=name,
                                permissions=praw_config.get_reddit_oauth_scope(name))
                   for name in praw_config.get_all_site_names()]
     super(GlobalDispatch, self).__init__(signatures, stop_event)
Esempio n. 4
0
def main():
    from argparse import ArgumentParser
    parser = ArgumentParser("Running EventBot by itself")
    parser.add_argument(
        "-a",
        "--account",
        dest="reddit_account",
        required=True,
        choices=get_all_site_names(),
        help="Specify which Reddit account entry from praw.ini to use.")
    args = parser.parse_args()
    test = EventBot(args.reddit_account, run_once=True)
    test.start()
    test.stop_event.wait()
Esempio n. 5
0
import newsbot  # you must import your bot file here, even if you don't use it
import eventbot
import ticketbot
import config
from config import praw_config, bot_config
from bots import InvalidBotClassName, BotSignature, RedditBot


# If you declare your own RedditBot subclass in its own file,
# you must import it or else it will not be added to BOT_CLASSES.
BOT_CLASSES = {cls.__name__: cls for cls in RedditBot.get_subclasses()}

logger = config.getLogger()
parser = ArgumentParser(description="FAUbot options")
parser.add_argument("-a", "--account", dest='account', choices=praw_config.get_all_site_names(),
                    help="Specify which Reddit account configured in praw.ini will be used to launch bots.")


# region DISPATCH
class Dispatch(threading.Thread, metaclass=ABCMeta):
    """
    An object used to create, launch, and terminate bots.
    """
    def __init__(self, bot_signatures, stop_event=None):
        """
        Initializes a Dispatch object, and creates a pool of bots.
        :param bot_signatures: A list of BotSignatures used to create the new bots
        :param stop_event: A threading.Event used to keep the Dispatch alive and tell it when to close.
        """
        super(Dispatch, self).__init__()
Esempio n. 6
0
def main():
    from config.praw_config import get_all_site_names
    from argparse import ArgumentParser
    parser = ArgumentParser("Running TicketBot by itself")
    parser.add_argument("-a", "--account", dest="reddit_account", required=True, choices=get_all_site_names(),
                        help="Specify which Reddit account entry from praw.ini to use.")
    args = parser.parse_args()
    test = TicketBot(args.reddit_account, run_once=True)
    test.start()
    test.stop_event.wait()
Esempio n. 7
0
import ticketbot
import config
from config import praw_config, bot_config
from bots import InvalidBotClassName, BotSignature, RedditBot

# If you declare your own RedditBot subclass in its own file,
# you must import it or else it will not be added to BOT_CLASSES.
BOT_CLASSES = {cls.__name__: cls for cls in RedditBot.get_subclasses()}

logger = config.getLogger()
parser = ArgumentParser(description="FAUbot options")
parser.add_argument(
    "-a",
    "--account",
    dest='account',
    choices=praw_config.get_all_site_names(),
    help=
    "Specify which Reddit account configured in praw.ini will be used to launch bots."
)


# region DISPATCH
class Dispatch(threading.Thread, metaclass=ABCMeta):
    """
    An object used to create, launch, and terminate bots.
    """
    def __init__(self, bot_signatures, stop_event=None):
        """
        Initializes a Dispatch object, and creates a pool of bots.
        :param bot_signatures: A list of BotSignatures used to create the new bots
        :param stop_event: A threading.Event used to keep the Dispatch alive and tell it when to close.