Skip to content

plugins_usage

VYCKTOR HUGO STARK edited this page Jul 4, 2018 · 4 revisions

how to create plugin in my base

well, first of all you should import the dependencies of the project, so in the first line write: from main import *, and create a function, and below this function you must assemble a diagram with data of the plugin - I will leave examples below

#Exemple:
from main import *
def any():
  api.sendMessage(chat_id=11093123, text='this is an example of text')
  return False
plugin = {
	'patterns': [
		"^/(any)$"
	],
	'function': any,
	'name': "any",
	'sudo': False,
	}

But there are other ways to create your plugin, one is, regardless of dependency - I'll leave below an example of how to do:

#Exemple:
def any():
  return 'this is an example of text'
plugin = {
	'patterns': [
		"^/(any)$"
	],
	'function': any,
	'name': "any",
	'sudo': False,
	}

The other way is to import exactly what you're going to use - I'll leave below an example of how to do

#Exemple:
from main import api
def any():
  api.sendMessage(chat_id=11093123, text='this is an example of text')
  return False

plugin = {
	'patterns': [
		"^/(any)$"
	],
	'function': any,
	'name': "any",
	'sudo': False,
	}

But, why do I have to create this plugins diagram?

Basically, the diagram of each item is for the base identify what to do, for example, in 'function' identifies what the function will do, in 'name' the help will identify the names of each plugin to give a help to the user, and 'sudo' will identify if it is a command that only admin can use, and in 'patterns' will indicate which command is the specificity for that plugin.

Note: When creating a plugin, the name you put in the diagram you have to create another diagram in the 'languages.py' file that is in the langs folder, since that is where 'help.py' will pull the information for it - I am going too leave an example below, what you should do in each language, this example will be in English and the rest should do it yourself.

'any': [{
			'usage': '<code>/any</code> : for anything to do something', # any.py
}],

base commands already exist how to use?

This table below with name, parameters and description of each plugin will explain better how to use commands already created in chats

Name Parameters Description
help /help /help name If the command is sent integer, you must return the plugin options. But if it is sent with a text complement being it the name of the plugin or id of it it will return an information of that plugin
about /about if the command is sent it will return information about the bot
ping /ping if the command is sent, it will return a quick message in the case of "pong"
admin /sudo Commands sudo without Description