Giter VIP home page Giter VIP logo

yaylib's Introduction

      ___           ___           ___       ___       ___
     /\__\         /\  \         /\__\     /\__\     /\  \
    /:/  /        /::\  \       /:/  /    /:/  /    /::\  \
   /:/__/        /:/\:\  \     /:/  /    /:/  /    /:/\:\  \
  /::\  \ ___   /::\~\:\  \   /:/  /    /:/  /    /:/  \:\  \
 /:/\:\  /\__\ /:/\:\ \:\__\ /:/__/    /:/__/    /:/__/ \:\__\
 \/__\:\/:/  / \:\~\:\ \/__/ \:\  \    \:\  \    \:\  \ /:/  /
      \::/  /   \:\ \:\__\    \:\  \    \:\  \    \:\  /:/  /
      /:/  /     \:\ \/__/     \:\  \    \:\  \    \:\/:/  /
     /:/  /       \:\__\        \:\__\    \:\__\    \::/  /
     \/__/         \/__/         \/__/     \/__/     \/__/
┌──┤ WHOAMI ├─────────▰▰▰
│
├─▣ ekkx
├─▣ Backend dev from Tokyo
├─▣ Blog
│
└───────────────────────────────▰▰▰

⏳ 2024: { █████████████████████▁▁▁▁▁▁▁▁▁ } 70.29 %

⏰ Updated on Sat Sep 14 2024

yaylib's People

Contributors

ekkx avatar kohnoselami avatar popo-nyan avatar techfish-11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

yaylib's Issues

自動テスト&デプロイ

めんどくさい作業を CI/CD 化する。

自動テスト

pre commit で走らせてもいいが、Docker を利用していない場合を想定して GitHub Actions 上で行う。
トリガーはプルリクエスト?違う Python のバージョンをテストしたい場合はどうする?

自動デプロイ

master ブランチにマージされたタイミングで PyPI にアップロードしよう。

docstring 追加

サーバー側の仕様変更に耐えられるよう API 関数の引数に keyword args を使用する。
そのためには、docstring で必要な引数を示す必要がある。(利用者に混乱を招くため)

reduce_kenta_penaltyでのエラー

reduce_kenta_penaltyを実行した時にエラーが出る

実行した関数
reduce_kenta_penalty
エラー内容
[Errno 11001] getaddrinfo failed

feat: 非同期処理

  • aiohttp の導入
  • ステートの保存に SQLite を使用
  • 同期リクエストも行えるようにする

aiohttp の導入

httpx で非同期 HTTP リクエストを行うことはできるが、ws には対応していない。
aiohttp であれば ws も使用可能なため、依存関係を減らすことができる。

ステートの保存に SQLite を使用

現状は JSON ファイルに認証情報などのステートを保存しているが非同期リクエストを導入する場合、I/O 処理の排他制御が必要になる。SQLite であれば内部的に排他制御を提供しているので自前で実装する必要がない。また、Python は標準ライブラリ (sqlite3) として提供している。

同期リクエストも行えるようにする

破壊的な変更をできるだけ防ぐため、今までの仕様は可能な限り残しておく。

Client インスタンスから関数に直接アクセスする場合は同期リクエストを行う。
Client インスタンスの API フィールド経由の場合は非同期リクエストを行う。

client = yaylib.Client()

client.get_timeline() # 同期リクエスト
client.post.get_timeline() # 非同期リクエスト

リクエスト毎のランダムな遅延は同期処理にのみ取り入れる。認証情報の更新やレート制限の待機時間の挿入などは共通処理として非同期リクエスト関数に実装する。

イベントリスナーのドキュメントを作成する

import yaylib

api = yaylib.Client()

api.login(email, password)


class MyChatListener(yaylib.ChatEventListener):
    def on_message(self, chat_room):
        print(chat_room.id, chat_room.last_message.text)


ws_token = api.get_web_socket_token()

bot = MyChatListener()
bot.run(ws_token)

remove_chat_roomsでのエラー

指定したroom_idを削除しようとするとエラーが出る

実行した関数
remove_chat_rooms
エラー内容
ERROR - Request failed with status code 500. Retrying...
NoneType: None

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.