npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fishpi

v0.0.63

Published

A Package to use API of fishpi.

Downloads

553

Readme

摸鱼派 API Package

摸鱼派社区 (https://fishpi.cn/) 的 API Package,可以快速开发出一款应用支援社区功能。

支援

  • 用户信息;
  • 聊天室;
    • 话题编辑;
    • 红包收发;
  • 自定义表情包;
  • 文件上传;
  • 通知信息;
  • 清风明月;
  • 文章读写;
  • 评论点赞;
  • 私聊功能;

安装

npm install fishpi

用例

import FishPi from 'fishpi';

// 登录获取 apiKey
let apiKey = '';
let fish = new FishPi();
let rsp = await fish.login({ 
    username: 'username', 
    passwd: 'password123456' 
});
if (rsp.code == 0) apiKey = rsp.Key;

// 通过 apiKey 获取登录用户信息
let fish = new FishPi(apiKey);
console.dir(await fish.account.info());

// 获取用户自定义表情包
let emojis = await fish.emoji.get();
// 获取默认表情包
let defaultEmoji = fish.emoji.default;

// 监听聊天室消息
fish.chatroom.addListener(({ msg }) => console.dir(msg));
// 向聊天室发送信息(需要登录)
await fish.chatroom.send('Hello World!');
// 向聊天室发送红包
await fish.chatroom.redpacket.send({
    type: 'random';
    money: 32;
    count: 2;
    msg: '摸鱼者,事竟成!';
    recivers: [];
})

// 私聊历史获取
let chatHistory = await fish.chat.get({ user: 'username', autoRead: false })
// 监听私聊新消息
fishpi.chat.addListener(async ({ msg }: { msg: NoticeMsg }) => {
    switch (msg.command) {
        // 私聊未读数更新
        case 'chatUnreadCountRefresh':
            if(msg.count! > 0) {
                let unreadMsgs = await fishpi.chat.unread();
            }
            break;
        // 新私聊消息
        case 'newIdleChatMessage':
            // msg 就是新的私聊消息
            console.log(msg.senderUserName, '说:', msg.preview);
            break;
        // 有新的消息通知
        case 'refreshNotification':
            console.log('你有新消息【', await fishpi.notice.count(), '】')
            break;
    }
});
// 监听指定用户的私聊消息
fishpi.chat.addListener(({ msg }: { msg: ChatData }) => {
    console.log(msg.senderUserName, '[', msg.time, ']:', msg.content);
}, 'username');
// 给指定用户发私聊消息
fishpi.chat.send('username', 'Hi~');

// 金手指
import { Finger, FingerTo } from 'fishpi';

// 一次性金手指
await FingerTo('GoldenFingerKey').queryLatestLoginIP('username')

// 金手指实例
const finger = new Finger(apiKey);
await finger.queryLatestLoginIP('username');

注意事项

API 库使用 fetch 做 API 请求,浏览器环境可以直接使用。在 Node 环境需要安装 node-fetch 2.x 版本的库。执行如下代码设置 fetch 函数:

import fetch from 'node-fetch'
globalThis.fetch = fetch as any;