1.0.2
Plugin Library for Neos.js
Neos.js Plugin - CommandManager
CommandManager
:
const CommandManager = require("neosjs-commands");
const Neos = new (require("@bombitmanbomb/neosjs"))
Command = CommandManager.Create(Neos)
Command.Add("Ping", (Handler)=>{Handler.Reply("Pong")})
Command.SetHelp("Ping", {index:"Ping Pong!", usage:Command.Options.Prefix+"Ping"})
Command.Add("Relay", (Handler, Sender, Args)=>{
if (Args.length<2) return Handler.Usage();
if (!Args[0].startsWith("U-")) return Handler.Reply("First Argument must be a UserID.");
if (!Neos.IsFriend(Args[0])) return Handler.Reply("User is not a Friend of the bot.");
Neos.SendTextMessage(Args.shift(), Args.join(" ")); // Remove first argument (UserID) and join the rest with spaces.
Handler.Reply("Message Sent!")
},
{
index:"Send a message to another user via the bot.",
usage:Command.Options.Prefix+"Relay <User-ID> <Message>"
}, ["U-BotOwner"]);
Neos.on("messageReceived", Command.Run);
(Neos.js)
(any)
(any)
CommandExtended
:
CommandExtended Plugin. Adds more features to CommandHandler
"/"
, HelpCommand: "help"
, UsageCommand:
"usage"
, CommandsCommand: "commands"
,
HelpDefault:
"Get a list of commands with $this.prefix +
$this.CommandsCommand"
})
(CommandHandler)
({Prefix: "/"
, HelpCommand: "help"
,
UsageCommand: "usage"
, CommandsCommand:
"commands"
, HelpDefault:
"Get a list of commands with $this.prefix +
$this.CommandsCommand"
})
const CommandHandler = require("@bombitmanbomb/neosjs/Plugins/CommandHandler")
const CommandExtended = require("@bombitmanbomb/neosjs/Plugins/CommandExtended")
const NEOS = require("@bombitmanbomb/neosjs")
const Neos = new NEOS()
const Command = new CommandExtended(new CommandHandler(Neos),Options);
Command.Add("Ping", (Handler)=>{Handler.Reply("Pong")})
Command.SetHelp("Ping", {index:"Ping Pong!", usage:Command.Options.Prefix+"Ping"})
Command.Add("Relay", (Handler, Sender, Args)=>{
if (Args.length<2) return Handler.Usage();
if (!Args[0].startsWith("U-")) return Handler.Reply("First Argument must be a UserID.");
if (!Neos.IsFriend(Args[0])) return Handler.Reply("User is not a Friend of the bot.");
Neos.SendTextMessage(Args.shift(), Args.join(" ")); // Remove first argument (UserID) and join the rest with spaces.
Handler.Reply("Message Sent!")
},
{
index:"Send a message to another user via the bot.",
usage:Command.Options.Prefix+"Relay <User-ID> <Message>"
}, ["U-BotOwner"]);
Neos.on("messageReceived", Command.Run);
Add a new Command Hook
Parse and run the given message object
(any)
CommandHandler Plugin.
(Class)
Neos.js "this" instance
(String
= "Invalid Command"
)
const NEOS = require("@bombitmanbomb/neosjs")
const Neos = new NEOS()
const CommandHandler = require("@bombitmanbomb/neosjs/Plugins/CommandHandler")
const Command = new Commandhandler(Neos)
Command.Add("Ping", (Handler)=>{Handler.Reply("Pong!")});
Neos.on("messageReceived", (Message)=>{
Command.Run(Message)
})
Add a Command
Run a Message for Commands
({Id, OwnerId, RecipientId, SenderId, MessageType,
Content, SendTime, LastUpdateTime, ReadTime})
(any)