Meow
API documentation for meow-app. Meow is a twitter like (but peer to peer) application built on top of
zChain
. This means that the application "extends" upon the zChain core functionality in terms of message passing and persistance accross nodes. Implementation can be found at https://github.com/zer0-os/zChain/tree/main/apps/meow.- Initialize a meow
init(zIdName, listenAddrs?)
- Public Instance Methods
meow.sendMeow(message, publishOnTwitter = false, network?)
meow.sendMessage (message: string, channel: string, network?: string)
meow.setDisplayName(peerId, name, force)
meow.followZId(peerIdOrName)
meow.unfollowZId(peerIdOrName)
meow.getPeerFeed(peerIdOrName, n)
meow.getFollowedPeers()
meow.followChannel(channel)
meow.unFollowChannel(channel)
meow.getFollowedChannels()
meow.getChannelFeed(channel, n)
meow.listDBs()
meow.enableTwitter(force)
meow.disableTwitter()
meow.help()
meow.createNetwork(networkName: string, channels: string[])
meow.getNetworkMetadata(networkName: string)
meow.addChannelInNetwork(networkName: string, channel: string)
meow.joinNetwork(networkName: string)
meow.leaveNetwork(networkName: string)
meow.getNetworkList()
meow.getMyNetworks()
const meow = new MEOW();
await meow.init('node-a', [ '/ip4/0.0.0.0/tcp/0', .. ]);
Under the hood it's using the
zchain.initialize(..)
method to initialize an ipfs node and the databases. Check zChain.initialize()
method in zchain API documentation for more details. Along with initializing zChain, we:- Intialize the meow storage (built/extended on top of zChain storage)
- Intialize twitter client (if enabled)
- Logic for following/unfollowing peer :: After connecting, check in the database if we're following this peer, if yes, then open (load) that peer's yDoc from level-db storage.
- Logic for following/unfollowing channel :: Check in the database for all channels we're following and open (load) that channel's yDoc from level-db storage.
Arguments | Descriptions |
---|---|
zIdName (string) | zId Name assigned to this node by the end user |
listenAddrs (string[], optional) | Additional multiaddrs this node can listen to. |
Send a meow (a message), across hashtags on a network. By default each message is published on
#everything
channel. A node will receive all messages if it's following the #everything
channel (becoming a super node). Additionally, if twitter is enabled, then the message will also be published on #zero
channel.NOTE: If
network
name is not passed, then default network 0://default.network
will be used.Arguments | Descriptions |
---|---|
message (string) | The message to publish. |
publishOnTwitter (boolean, optional) | This is set to false by default. If twitter is enabled and this is set to true , then the message will also be published on twitter. |
network (string, optional) | Network name. |
Usage:
// publishes message on #fairtoplay, #ucl, #everything at default network
await meow.sendMeow(`Thrilled to join the football gaming revolution
with @UFLgame bringing the new #fairtoplay experience to
football gamers worldwide! See you in the Game soon! #ucl`);
Send a message (allowed up to 280 char) on a channel at a network. The published message is stored in the zchain feed database, and the public topic database of orbit-db.
NOTE: If
network
name is not passed, then default network 0://default.network
will be used.Arguments | Descriptions |
---|---|
message (string) | The message to publish. |
channel (string) | The channel name (must be present in network). |
network (string, optional) | Network name. |
Usage:
// send message
await meow.sendMessage(`Hello Friend`, '#zero', '0://wilder.team');
Sets a name of the peerId in the local address book. Throws an error if force is
false
and a display name is already present for a peerID.Arguments | Descriptions |
---|---|
peerId (string) | The peerID (as base58 encoded string). |
name (string) | Display name to set for this peerID. |
force (boolean, optional) | If true , updates the displayName for a peer, if it has already set previously. |
Usage:
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
// set display name for ratik peerID in local address book
await meow.setDisplayName(ratikId, "ratik");
// update display name to new one for the peer
await meow.setDisplayName(ratikId, "ratik-new", true);
Follow a zId (peerID). After you follow a peer, an entry is saved to
followingzIds
databases. And upon establishing connection with the peer you follow, that peer's feed yDoc is "synced" with our local yDoc (copy of the peer's feed after following it). This way we sync up on the messages published by that peer (as we have a local copy of it's peer database now).Arguments | Descriptions |
---|---|
peerIdOrName (string) | The peerID (as base58 encoded string) or the display name from the local address book. |
Usage:
// follow ratik
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
await meow.followZId(ratikId);
// or follow by name
await meow.set(ratikId, "ratik"); // set in local address book
await meow.followZId("ratik");
Unfollow a zId (peerID). After you unfollow a peer, entry of the peer is removed from
followingZIds
database, and local feed database of the peer we have unfollowed is dropped.Arguments | Descriptions |
---|---|
peerIdOrName (string) | The peerID (as base58 encoded string) or the display name from the local address book. |
Usage:
// unfollow ratik
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
await meow.unfollowZId(ratikId);
// or unfollow by name
await meow.set(ratikId, "ratik"); // set in local address book
await meow.unfollowZId("ratik");
Displays last "n" messages published by a peer. Please note that you must be "following" the peer and established connection to it atleast once (so that you have that peer's feed unique database address).
Arguments | Descriptions |
---|---|
peerIdOrName (string) | The peerID (as base58 encoded string) or the display name from the local address book. |
n (number) | Number of messages to display. |
Usage:
const ratikId = 'QmTsUsXsRsUpvHxRNXWJKmw3RvSPN3c8Noa95Kpduu5Wcv';
await meow.set(ratikId, "ratik"); // set in local address book
// display last 5 messages followed by ratik
await meow.getPeerFeed("ratik", 5);
Returns the peers(zId's) this node is following. If a display name is set for any peer, that will be returned as well.
// list following peers
const peers = meow.getFollowedPeers();
console.log('peers: ', peers);
Follow a channel on a network. After following a channel, any message published on that channel will be received by this node. You also initialize channel ydoc of the channel feed (so we start replicating with other nodes that are online).
NOTE: If
network
name is not passed, then default network 0://default.network
will be used.Arguments | Descriptions |
---|---|
channel (string) | Name of the channel (must be present in network) to follow |
network (string, optional) | Name of the network. |
Usage:
// follow a channel in network 0://wilder.team
await meow.followChannel('#fairtoplay', '0://wilder.team');
Unfollow a channel on a network. After unfollowing a channel, you will no longer receive any message published on that channel. The public database of that channel is also dropped from the local system.
NOTE: If
network
name is not passed, then default network 0://default.network
will be used.Arguments | Descriptions |
---|---|
channel (string) | Name of the channel (must be present in network) to unfollow |
network (string, optional) | Name of the network. |
Usage:
// unfollow a channel
await meow.unFollowChannel('#fairtoplay', '0://wilder.team');
Returns a list of the channels this node is following.
// list the channels this node is following
const channels = meow.getFollowedChannels();
console.log('channels: ', channels);
Returns last "n" messages published "on" a channel in a network. Please note that you must be "following" the channel in order to view it's feed.
NOTE: If
network
name is not passed, then default network 0://default.network
will be used.Arguments | Descriptions |
---|---|
channel (string) | Name of the channel (must be present in network) to display feed of. |
n (number) | Number of messages to display. |
network (string, optional) | Name of the network. |
Usage:
// display last 3 messages on channel #ucl on network 0://wilder.team
const feed = await meow.getChannelFeed('#ucl', 3, '0://wilder.team');
console.log('Channel Feed: ', feed);
Lists all the databases in an object and the no. of entries. Databases listed are:
followingZIds
: key value store for storing following peersfollowingChannels
: key value store for storing the channels we're following.Peer Feeds
: List of feed databases (address, entries) for each peer we're following.Channel feeds
: List of channel databases (address, entries) for each channel we're following.
await meow.listDBs()
Enables twitter. A window is open first on the browser, where the user is asked to authorize meow app to tweet of behalf of the user. After authorization by user, the meow app has read & write permissions for tweets from your twitter account. The config for twitter account is saved at
~/.zchain/twitter-config.json
.If you want to "tweet" from a
meow
, pass true
with sendMeow
function (eg below).Arguments | Descriptions |
---|---|
force (boolean) | If passed, user is asked to authorize again. |
Usage:
await meow.enableTwitter();
// send message to zchain + post a tweet to twitter.
await meow.sendMeow("post from zchain", true);
Disables twitter. Simply removes config at
~/.zchain/twitter-config.json
await meow.disableTwitter();
Displays a list of available functions withing the meow API.
Creates a new network, with an initial list of channels. By default channel
#general
is added to each network. You automatically subscribe to all channels associated with the network after it's creation.
Each network must be "globally unique". To ensure this, the peerID adding the new network, must have an ethereum address and signature added in zchain. And the name must be a valid ZNA, from the list of ZNA's associated with the peer's ethereum address. This will soon be replaced by ZNS.Arguments | Descriptions |
---|---|
networkName (string) | Name of the network to create. |
channels (string[]) | List of channels associated with this network. |
Usage:
// create a new network
meow.createNetwork('0://wilder.team', [ "#zero", "#random" ]);
Get the data associated with the network. Returns the associated list of channels with this network, and the associated peerID.
Arguments | Descriptions |
---|---|
networkName (string) | Name of the network to get meta data of. |
Usage:
const metaData = meow.getNetworkMetadata('0://wilder.team');
console.log("meta: ", metaData);
Add a new channel in network. Returns `void` if channel is already present in network.
Arguments | Descriptions |
---|---|
networkName (string) | Name of the network to add a new channel in. |
channel (string) | Channel to add. |
Usage:
await meow.addChannelInNetwork('0://wilder.team', "#announcements");
Join a new network. As a join, you also subsribe/follow all the channels present in the network.
Arguments | Descriptions |
---|---|
networkName (string) | Name of the network to join. |
Usage:
await meow.joinNetwork('0://wilder.team');
Leave a network. As a leave, you also unsubsribe/unfollow all the channels present in the network.
Arguments | Descriptions |
---|---|
networkName (string) | Name of the network to leave. |
Usage:
await meow.leaveNetwork('0://wilder.team');
Returns a list of "all" networks + associated channels.
const allNetworks = await meow.getNetworkList();
console.log("All Networks: ", allNetworks);
Returns a list of network + associated channels "this" peer is following.
const myNetworks = await meow.getMyNetworks();
console.log("My Networks: ", myNetworks);
Last modified 1yr ago