Giter Club home page Giter Club logo

yaylib's Introduction


Logo

yaylib

同世代とつながる通話コミュニティ - Yay!(イェイ)の API ライブラリ
あらゆる操作の自動化や、ボットの開発が可能です。

ドキュメントはこちらから »

Report Bug · Request Feature · Join the discord

Table of Contents
  1. インストール
  2. 使用例
  3. yaylib で誕生したロボットたち
  4. 共同開発について
  5. Buy me a coffee
  6. 免責事項
  7. 利用許諾

Installation

※ Python 3.10 以上のバージョンが必要です。

「yaylib」をインストールするには、以下のコマンドをターミナル上で実行します:

pip install yaylib

Note 開発バージョンをインストールする場合は、以下の手順を実行します:

git clone https://github.com/qvco/yaylib.git

cd yaylib

pip install -r requirements.txt

pip install -e .

「yaylib」の始め方については、こちら を確認してください。

Quick Example

✨ 投稿を作成する

import yaylib

api = yaylib.Client()
api.login(email="your_email", password="your_password")

api.create_post("Hello with yaylib!")

✨ 埋め込みリンクの投稿を作成する

import yaylib

api = yaylib.Client()
api.login(email="your_email", password="your_password")

api.create_post("Hello with yaylib!", shared_url="https://github.com/qvco/yaylib")

✨ 画像と一緒に投稿を作成する

import yaylib

api = yaylib.Client()
api.login(email="your_email", password="your_password")

# 画像のパスを指定
image_paths = [
    "./test1.jpg",
    "./test2.jpg",
    "./test3.jpg",
]

# 画像の使い道を指定
image_type = yaylib.IMAGE_TYPE_POST

# サーバー上にアップロード
attachments = api.upload_image(image_paths, image_type)

# サーバー上のファイル名を指定する
# attachmentsが一つ飛ばしなのはオリジナル品質の画像のみを指定するため
api.create_post(
    "Hello with yaylib!",
    attachment_filename=attachments[0].filename,
    attachment_2_filename=attachments[2].filename,
    attachment_3_filename=attachments[4].filename,
)

✨ タイムラインを 100 件取得する

import yaylib

api = yaylib.Client()

timeline = api.get_timeline(number=100)

for post in timeline.posts:
    print(post.user.nickname)  # 投稿者名
    print(post.text)  # 本文
    print(post.likes_count)  # いいね数
    print(post.reposts_count)  # (´∀`∩)↑age↑の数
    print(post.in_reply_to_post_count)  # 返信の数

✨ タイムラインをキーワードで検索して「いいね」する

import yaylib

api = yaylib.Client()
api.login(email="your_email", password="your_password")

timeline = api.get_timeline_by_keyword(
    keyword="プログラミング",
    number=15
)

for post in timeline.posts:
    api.like(post.id)

✨ 新規ユーザーをフォローする

import yaylib

api = yaylib.Client()
api.login(email="your_email", password="your_password")

new_users = api.search_users(recently_created=True)

for new_user in new_users.users:
    api.follow_user(new_user.id)

✨ リアルタイムでチャットを取得する

import yaylib


class ChatBot(yaylib.ChatRoomEventHandler):
    def __init__(self, api: yaylib.Client):
        self.api = api

    def on_request(self, total_count: int):
        # チャットリクエストを承認する
        chat_rooms = self.api.get_chat_requests()
        for room in chat_rooms.chat_rooms:
            self.api.accept_chat_requests(chat_room_ids=[room.id])
        self.on_message(chat_rooms.chat_rooms[0])

    def on_message(self, chat_room):
        # 受信したメッセージをオウム返しする
        self.api.send_message(
            chat_room_id=chat_room.id,
            message_type=chat_room.last_message.message_type,
            text=chat_room.last_message.text,
            font_size=chat_room.last_message.font_size,
        )


api = yaylib.Client()
api.login(email="your_email", password="your_password")

ws_token = api.get_web_socket_token()

bot = ChatBot(api)
bot.run(ws_token)

より詳しい使用例については、こちら を参照してください。

(トップに戻る)

👑 yaylib で誕生したロボットたち

「yaylib」を用いて開発したロボットがある場合は、ぜひ教えてください!

MindReader AI 香ばしいボット GIGAZINE

開発者: 毛の可能性


開発者: tori


開発者: ぺゅー

🤝 共同開発について

私たちと開発することに興味を持っていただけているなら、ぜひ参加して頂きたいです!

のいずれかの方法で繋がりましょう。詳しくはこちらから

Buy me a coffee

このライブラリが気に入っていただけたら、リポジトリにスターをお願いします(⭐)
また、Buy Me a Coffee からご支援いただけますと幸いです。

Buy Me A Coffee

免責事項

yaylib は、API の公式なサポートやメンテナンスを提供するものではありません。このクライアントを使用する場合、利用者はリスクや責任を自己負担できるものとします。このクライアントによって提供される情報やデータの正確性、信頼性、完全性、適時性について、いかなる保証も行いません。また、このクライアントの使用によって生じた損害や不利益について、一切の責任を負いかねます。利用者は自己の責任において、このクライアントを使用し、API にアクセスするものとします。なお、この免責事項は予告なく変更される場合があります。

ライセンス

MIT © Qvco & Konn

フルライセンスは こちら からご確認いただけます。
このプロジェクトは、 【MIT ライセンス】 の条件の下でライセンスされています。

(トップに戻る)

yaylib's People

Contributors

ekkx avatar iruka541 avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.