Skip to content

xct007/SuryaRB

Repository files navigation

SURYA
EXCLUSIVE

___________________________
PERFECTION REDEFINED

Surya Exclusive MD

PT Perusahaan Rokok Tjap Gudang Garam Tbk (Republican spelling Indonesian for "Salt Warehouse brand Cigarette Company plc"), trading as PT Gudang Garam Tbk, is an Indonesian tobacco company, best known for its kretek (clove cigarette) products. It is Indonesia's second-largest tobacco manufacturer, with a market share of about 20%. The company was founded on 26 June 1958 by Tjoa Ing Hwie, who changed his name to Surya Wonowidjojo (1923–1985). In 1984, control of the company was passed to Wonowidjojo's son, Cai Daoheng/Tjoa To Hing (Rachman Halim), who subsequently became the richest man in Indonesia. Halim headed the company until his death at the age of 60 in 2008.

Table of Contents

Requirements

Installation

  1. Clone the repository

    git clone https://github.com/xct007/SuryaRB.git
  2. Install the dependencies

    npm install
  3. Create or rename the .env.example file to .env

    ITSROSE_APIKEY=PASTE_YOUR_APIKEY_HERE

    Get your API key from API Dashboard

  4. Edit the config.js file

    export const Config = {
    	// The bot's phone number
    	// required if use pairing code
    	phone_number: "628385818401",
    
    	// Owner's phone number
    	owners: ["628385818401"],
    
    	// use pairing or not
    	use_pairing_code: true,
    
    	// Wait time for requesting pairing (in milliseconds)
    	pairing_wait: 1000 * 6,
    
    	// prefix for commands
    	prefix: ["!", "."],
    
    	// use .env file for API key
    	itsrose_apikey: process.env.ITSROSE_APIKEY,
    
    	// timezone
    	timezone: "Asia/Jakarta",
    
    	// Database settings
    	database: {
    		// use mongo or not
    		use_mongo: true,
    		mongo_url: "mongodb://localhost:27017/database",
    
    		// Path to the database file
    		path: "./database.json",
    
    		// Save interval (in milliseconds)
    		save_interval: 10_000,
    
    		// show database save logs
    		debug: false,
    	},
    };
  5. Run the application:

    node index.js / npm start / yarn start

    or using pm2:

    pm2 start index.js --name "SuryaRB"
    pm2 logs SuryaRB

Creating features/plugins

Create new file in Message/Features folder with the following template

export default {
	// Command to trigger the execution
	// Can be an array of strings to have multiple triggers
	command: ["command", "command2"],
	// Description of the command, displayed in the menu
	description: "The description of the command",
	// Category as header in the menu
	category: "My Category",

	// If true, only the owner listed in config.js can call the command
	owner: false,
	// Only admin in the group can call the command
	admin: false,
	// If hidden, the command will not be shown in the menu
	hidden: false,
	// If true, user limit will be checked before executing the command
	// If the limit is reached, the command will not be executed
	limit: false,

	// If true the command only can be call in group chat
	group: false,
	// If true the command only can be call in private chat
	private: false,

	/**
	 * Handler function to execute the command
	 * @param {import("../../Utils/Messages").ExtendedWAMessage} m - The message object.
	 * @param {import("../Handler").miscOptions} options - The options.
	 */
	execute: async function (
		m,
		{
			args,
			sock,
			conn,
			api,
			groupMetadata,
			isOwner,
			isAdmin,
			command,
			text,
			usedPrefix,
			db,
		}
	) {
		// Single reply
		m.reply("Hello World");

		// Single reply with fancy text
		// 2nd parameter is the style of the text listed in Config/Fonts.js
		m.reply("Hello World", "funky");

		// Reply then update message
		m.replyUpdate("previous message", async (update) => {
			// do something
			//...
			// update the message
			update("new message");
		});
		// or
		const update = await m.replyUpdate("Hi");
		// do something
		update("Hi again");

		// react to the message
		m.react("👍");

		// delete the message (if the bot has the permission to do so)
		m.delete();

		// Download media (image, video, audio)
		const media = m?.download?.().catch(() => null);
		if (media) {
			// Do something with the media buffer
		}

		// Make a request to the ITSROSE API (Axios instance)
		// api.get() and api.post() are the same as axios.get() and axios.post()
		// 1st parameter is the path to the endpoint (without the base URL)
		// 2nd parameter is the request body or query parameters (optional)
		// See Utils/ApiRequest.js for more information
		const response = await api.get("/path/to/endpoint", { param: "value" });
		if (response.data.status) {
			// Do something with the response
			const data = response.data;
			m.reply(data);
		}
	},

	// Message to display when the command execution fails
	// %cmd alias for the command, %error alias for the error
	failed: "Failed to execute the %cmd command\n\n%error",

	// Message to display while waiting for the command to finish (useless for now)
	// aliase:
	// %name = user pushName
	// %tag = tag the user
	// %group = group subject/name
	wait: null, // null | string | string[] | any
	// wait: ["Please wait %tag", "Hold on %tag, fetching response"], // random if array

	// Message to display when the command execution is done (useless for now)
	// aliase:
	// %name = user pushName
	// %tag = tag the user
	// %group = group subject/name
	// %exec = speed the execution time "12.345 ms"
	done: null, // null | string | string[] | any
	// done: "Success %exec" // random if array
};

Contributing

You can contribute to the development of this project by submitting a pull request. If you find any bugs, please report them by creating an issue.

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/feature-name)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin feature/feature-name)
  6. Create a new Pull Request
  7. Get your PR reviewed and merged

License

This project is licensed under the MIT License.

Contributors