Exemple #1
0
def load_plugins(plugins_folder, verbose=True):
    """Import all plugins from target folder recursively."""

    found_plugins = []

    for pack in os.walk(plugins_folder):
        for filename in pack[2]:
            if "_" == filename[:1] or ".py" != filename[-3:]:
                continue

            path_to_module = os.path.join(pack[0], filename)

            if verbose:
                logger.info("Loading plugin \"{}\"".format(path_to_module))

            found_plugins.append(
                import_plugin(path_to_module, path_to_module)
            )

    return found_plugins
Exemple #2
0
    async def get_receiver_coroutine_function(self):
        if not self.session:
            self.session = aiohttp.ClientSession()

        current_group_s = await self.raw_request("groups.getById")

        if current_group_s.error or not current_group_s.response[0].get("id"):
            raise ValueError("Couldn't get group information\n{}".format(
                current_group_s.errors))

        self.group_id = current_group_s.response[0]["id"]

        await self.raw_request("groups.setLongPollSettings",
                               group_id=self.group_id,
                               api_version=self.version,
                               enabled=1,
                               **{
                                   **dict(message_new=1,
                                          message_reply=0,
                                          message_allow=0,
                                          message_deny=0,
                                          message_edit=0,
                                          photo_new=0,
                                          audio_new=0,
                                          video_new=0,
                                          wall_reply_new=0,
                                          wall_reply_edit=0,
                                          wall_reply_delete=0,
                                          wall_reply_restore=0,
                                          wall_post_new=0,
                                          wall_repost=0,
                                          board_post_new=0,
                                          board_post_edit=0,
                                          board_post_restore=0,
                                          board_post_delete=0,
                                          photo_comment_new=0,
                                          photo_comment_edit=0,
                                          photo_comment_delete=0,
                                          photo_comment_restore=0,
                                          video_comment_new=0,
                                          video_comment_edit=0,
                                          video_comment_delete=0,
                                          video_comment_restore=0,
                                          market_comment_new=0,
                                          market_comment_edit=0,
                                          market_comment_delete=0,
                                          market_comment_restore=0,
                                          poll_vote_new=0,
                                          group_join=0,
                                          group_leave=0,
                                          group_change_settings=0,
                                          group_change_photo=0,
                                          group_officers_edit=0,
                                          user_block=0,
                                          user_unblock=0),
                                   **self.longpoll_settings
                               })

        await self.update_longpoll_data()

        logger.info("logged in as \"{}\" ( https://vk.com/club{} )".format(
            current_group_s.response[0]["name"],
            current_group_s.response[0]["id"]))

        return self.receiver