1.0.6 • Published 3 years ago

onchejs v1.0.6

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
3 years ago

OncheJS

Faîtes des bots pour onche.org (onche.party v3) !

Documentation

Exemple basique

const {postMsg, getMsg} = require("onchejs");

const config = {
	"auth": "<auth_cookie>",
	"sess": "<sess_cookie>",
	"topic": "<topic_url>"
}; //Utilisez un fichier config.json, c'est mieux.

async function main()
{
	setInterval(async()=>{
		console.log("Check du dernier message...");

		var msg = await getMsg(config.topic, config.auth, config.sess);
		var args = msg.split(" ");
		var cmd = args.shift();

		switch(cmd)
		{
			case "!echo":
				console.log("[Echo]");
				await postMsg(args.join(" "), config.topic, config.auth, config.sess);
				break;

			case "!date":
				console.log("[Date]");
				await postMsg(Date().toString(), config.topic, config.auth, config.sess);
				break;

			default:
				if(cmd.startsWith("!"))
				{
					console.log("[PATH-ERROR]");
					await postMsg("Commande non reconnue :(", config.topic, config.auth, config.sess);
				};
		};

		console.log("Fin du check !");
	}, 10000);
};

main();

Bonne chance :)

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago