-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1c6042
commit 8c85da2
Showing
2 changed files
with
57 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,57 @@ | ||
from main import * # import variables and functions from head script | ||
|
||
################# | ||
## import config | ||
## only if you want to have an external config file, if no | ||
import os | ||
import importlib.util | ||
|
||
def load_config(): | ||
config_path = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "plugins","example-plugin","config.py") | ||
spec = importlib.util.spec_from_file_location("config", config_path) | ||
config_module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(config_module) | ||
return config_module | ||
|
||
config = load_config() | ||
## end of config import | ||
################# | ||
|
||
######################## | ||
## your logic and stuff | ||
## you should be able to use every variable and function from the head script | ||
if matrix_received_message == "Hello": | ||
func_send_message(config.message_test) | ||
# This is an example plugin, so its better to understand the way the bot handles plugins/external scripts. | ||
# So make sure youve named this file main.py and put it in its own folder in the plugins directory. | ||
# | ||
# When programming on a plugin you dont need to restart the bot, because of the way the bot handels the plugins. | ||
|
||
|
||
# needed for getting the variables that are being parsed by the bot | ||
import sys | ||
|
||
# | ||
# structur of possible values | ||
# | ||
|
||
# sys.argv[1] = "Hello" | ||
# - Description: the message the bot got | ||
|
||
# sys.argv[2] = "@ae5vjqrumaladsjkflklöajdsfacg4j5pfquk3bt55z5i===:chat.teamspeak.com" | ||
# - Description: Contains the matrix user id (MXID), is unique for every user | ||
|
||
# sys.argv[3] = "!" | ||
# - Description: Contains the used command prefix that is in the config of the bot | ||
|
||
# sys.argv[4] = "user" | ||
# - Description: Delivers the rank of the user, if the users matrix identifier is in the admin array the value "admin" will be send else only "user" | ||
|
||
|
||
# or if you like it smart | ||
# name the variables what you want, so they fit your handwriting | ||
message = sys.argv[1] | ||
message_sender = sys.argv[2] | ||
command_prefix = sys.argv[3] | ||
user_rank = sys.argv[4] | ||
|
||
|
||
|
||
# !! READ THIS !! | ||
# TLDR; | ||
# print out what you want the bot to send as an answer | ||
# | ||
# | ||
# Explanation: | ||
# The bot executes the plugins one by one, as soon he gets an value returend, | ||
# he will stop further execution of plugins and sends the value to the chat as the answer. | ||
# If multiple values are printed by your plugin in diffrent print's they will be send together. | ||
# | ||
|
||
# | ||
# If any values you need are missing, then open an issue on github and i will look if its possible to put it in. | ||
# https://github.com/Wargamer-Senpai/teampy/issues | ||
# | ||
# Have fun | ||
|
||
|
||
|
||
# your script logic here | ||
if sys.argv[1] == sys.argv[3]+"Hello": | ||
print("Hello World") |