-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin Builder.py
91 lines (76 loc) · 1.8 KB
/
Plugin Builder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
#Store the core file requirements in original var
original = '''<?php
/**
* %name% Core Plugin File
*
* %description%
*
* @package %name%
* @author %author%
* @version 1.0.0
*/
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.");
}
$plugins->add_hook( 'hook_name','hook_function');
function %plugin-name%_info()
{
return array(
"name" => "%name%",
"description" => "%description%",
"website" => "%website%",
"author" => "%author%",
"version" => "1.0",
"compatibility" => "*"
);
}
function %plugin-name%_install()
{
global $db;
}
function %plugin-name%_is_installed()
{
global $db;
}
function %plugin-name%_uninstall()
{
global $db;
}
function %plugin-name%_activate()
{
global $db;
}
function %plugin-name%_deactivate()
{
global $db;
}
'''
logo = input("""\
Press Enter to Start
""")
#Grab the user input
author = input("Author Name: ")
name = input("Info Plugin Name: ")
website = input("Website: ")
plugin = input("Plugin name(used on functions): ")
description = input("Plugin Description: ")
#Replace the content with the user input
original = original.replace("%author%",author)
original = original.replace("%name%",name)
original = original.replace("%website%",website)
original = original.replace("%plugin-name%",plugin)
original = original.replace("%description%",description)
#If inc directory does not exist create directory
if not os.path.exists("inc"):
os.makedirs("inc")
#If plugins directory does not exist create directory
if not os.path.exists("inc/plugins"):
os.makedirs("inc/plugins")
#Create the file name inside inc/plugins/ from the user input
f = open("inc/plugins/" + plugin + ".php","w")
#Write the updated original var to the file
f.write(original)
f.close()