0.2.43 • Published 8 months ago

sphinx-bot v0.2.43

Weekly downloads
387
License
ISC
Repository
-
Last release
8 months ago

npm.io

The Sphinx Javascript bot framework is inspired by Discord's bot creation library. So far we have only implemented simple Message creation, but there are exciting times ahead for bot developers on Sphinx!

How it works

npm.io

MotherBot

Every sphinx-relay instance has a built-in bot called MotherBot. MotherBot is how you can search, install, and uninstall bots.

  • /bot search Bitcoin
  • /bot install btc
  • /bot uninstall btc

Creating a bot

Bots can be created on your sphinx-relay instance. By creating a bot, you are generating a bridge from the Lightning Network to the regular web (http). Bots are secured with a secret key that is generated when a bot is created. HTTPS should be used for all Bot endpoints.

connect your bot

const client = new Sphinx.Client();
client.login(process.env.SPHINX_TOKEN);

create a bot Message

const embed = new Sphinx.MessageEmbed()
  .setAuthor("TestBot")
  .setDescription("Welcome to TestBot!");

respond to a "bot install" message

client.on(msg_types.INSTALL, async (message) => {
  const embed = new Sphinx.MessageEmbed()
    .setAuthor("TestBot")
    .setDescription("Welcome to TestBot!")
    .setThumbnail("<svg></svg>");
  message.channel.send({ embed });
});

respond to a chat message

client.on(msg_types.MESSAGE, async (message) => {
  // do something here!
  const embed = new Sphinx.MessageEmbed()
    .setAuthor("TestBot")
    .setTitle("TestBot Message:")
    .addFields([
      { name: "Item #1:", value: "hello", inline: true },
      {
        name: "Item #2:",
        value: "hello again",
        inline: true,
        color: "#00FF00",
      },
    ])
    .setThumbnail("<svg></svg>");
  message.channel.send({ embed });
});

respond to a chat message outside of the event emitter

client.channels.cache.get(CHANNEL).send(<Sphinx.Msg>{
  content: `This is a message!`,
});

boost a tribe member's message

// you can get CHANNEL from a "message.channel.id"
client.channels.cache.get(CHANNEL).pay(<Sphinx.Msg>{
  amount: 1000,
  reply_id: "xxx", // optional uuid "message.reply_id"
  recipient_id: 1, // id of the tribe member "message.member.id"
});

API

Client

  • new Sphinx.Client()

  • client.login(process.env.SPHINX_TOKEN)

Connecting

  • client.on(msg_types.INSTALL, callback)

  • client.on(msg_types.MESSAGE, callback)

new Sphinx.MessageEmbed()

  • setTitle(title:string)

  • setAuthor(author:string)

  • setColor(color:string)

  • setDescription(desc:string)

  • setThumbnail(thumb:string)

  • setImage(image:string)

  • addField(f:Field)

  • addFields(fs:Field[])

// "fields" are items in a list:
{
  "name": "string",
  "value": "string",
  "inline?": "boolean",
  "color?": "string"
}
0.2.41

9 months ago

0.2.40

9 months ago

0.2.43

8 months ago

0.2.42

8 months ago

0.2.39

10 months ago

0.2.38

1 year ago

0.2.37

1 year ago

0.2.36

3 years ago

0.2.35

3 years ago

0.2.34

3 years ago

0.2.33

3 years ago

0.2.30

3 years ago

0.2.32

3 years ago

0.2.31

3 years ago

0.2.29

3 years ago

0.2.27

3 years ago

0.2.28

3 years ago

0.2.26

3 years ago

0.2.25

3 years ago

0.2.24

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.30

4 years ago

0.1.29

4 years ago

0.1.27

4 years ago

0.1.28

4 years ago

0.1.26

4 years ago

0.1.24

4 years ago

0.1.25

4 years ago

0.1.22

4 years ago

0.1.23

4 years ago

0.1.21

4 years ago

0.1.20

4 years ago

0.1.19

4 years ago

0.1.18

4 years ago

0.1.17

4 years ago

0.1.13

4 years ago

0.1.14

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.8

4 years ago

0.1.9

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago