Skip to main content

Sun Weverse seeks to provide developers with a tool that allows them to make a bot that is able to retrieve Weverse Posts in semi real-time with relative ease.

Project description

Sun Weverse

Sun Weverse is a Python API Wrapper that interacts with Weverse's private API.

Intended Use

Sun Weverse seeks to provide developers with a tool that allows them to make a bot that is able to retrieve Weverse Posts in semi real-time with relative ease.

Installation

You can install Sun Weverse by using a terminal of your choice, and typing pip install sun-weverse.
Alternatively, you can install from source by typing pip install git+https://github.com/Anson-Quek/sun-weverse.git.

Disclaimer

As this is my first ever serious project, coupled with my lack of the necessary coding experience, I seek your understanding that there could be many aspects that are lacking.
Any tips, advices and constructive criticisms that seeks to make this project a better project, and me a better coder will be greatly appreciated.

Example Usage

from sunverse.sunverse import SunverseClient


# Create your own class that subclasses from SunverseClient
class WeverseClient(SunverseClient):
    def __init__(self, email: str, password: str):
        super().__init__(email, password)

    # This method is called every time there is a new
    # notification detected. The likelihood of you actually
    # using this method is highly unlikely as there are more
    # specialised methods that are called that should achieve
    # what you want.
    async def on_new_notification(self, notification: Notification) -> None:
        # Do what you want with the notification.
        print(notification.title)

    # This method is called every time there is a new
    # comment detected.
    async def on_new_comment(self, comment: Comment) -> None:
        # Do what you want with the comment.
        print(comment.body)

    # This method is called every time there is a new
    # post detected.
    async def on_new_post(self, post: Post) -> None:
        # Do what you want with the post.
        print(post.plain_body)

    # This method is called every time there is a new
    # media detected.
    async def on_new_media(self, media: ImageMedia | WeverseMedia | YoutubeMedia) -> None:
        # Since the media parameter will return either ImageMedia,
        # WeverseMedia or YoutubeMedia, isinstance should be used to
        # determine the type of object the media is.
        if isinstance(media, ImageMedia):
            # Do what you want with the Image Media.
            print(media.photos)

        elif isinstance(media, WeverseMedia):
            # Do what you want with the Weverse Media.
            print(media.internal_video_id)

        else:
            # Do what you want with the Youtube Media.
            print(media.youtube_url)

    # This method is called every time there is a new live
    # broadcast detected.
    async def on_new_live(self, live: Live) -> None:
        # Do what you want with the Weverse Live Broadcast.
        print(live.message_count)

    # This method is called every time there is a new notice
    # detected
    async def on_new_notice(self, notice: Notice) -> None:
        # Do what you want with the Weverse Notice.
        print(notice.photos)

    # This method is called every time there is a new moment
    # detected.
    async def on_new_moment(self, moment: Moment | OldMoment) -> None:
        # Since the moment parameter will return either Moment
        # or OldMoment, isinstance should be used to determine
        # the type of object the moment is.
        if isinstance(moment, Moment):
            # Do what you want with the Moment.
            print(moment.video)

        else:
            # Do what you want with the OldMoment. (Old Moment
            # refers to moments that were created before the Weverse
            # remake which happened somewhere in July or August)
            print(moment.photo)

if __name__ == "__main__":
    client = WeverseClient(
        email="the email of the account you want to sign in with",
        password="the password of the account you want to sign in with"
    )
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    loop.run_until_complete(client.start())
    loop.run_forever()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Sun Weverse-1.0.0.6.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Sun_Weverse-1.0.0.6-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file Sun Weverse-1.0.0.6.tar.gz.

File metadata

  • Download URL: Sun Weverse-1.0.0.6.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for Sun Weverse-1.0.0.6.tar.gz
Algorithm Hash digest
SHA256 9bba66c6b9587e6e834481ab14ec98a88199c0f270a2874d6e1bdfb6ca219905
MD5 7cab52dc2bceaa0bc0fc9013253fccbb
BLAKE2b-256 0205248633d2e50055e0996cb7228ec0f257296064afe7f3ee97098cb110b221

See more details on using hashes here.

File details

Details for the file Sun_Weverse-1.0.0.6-py3-none-any.whl.

File metadata

  • Download URL: Sun_Weverse-1.0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for Sun_Weverse-1.0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d696d21b20baa74bfa4d6b3cf6b047ff3d2bdb34ed9cc65de7a4094b6c2ca455
MD5 31da5cfaddbebffaa18e22a1b936231a
BLAKE2b-256 96de0f89d46a5fa75875695c93e4cd53b540a661beacfd550794e81cb4ad6cb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page