Last active
January 16, 2021 05:52
-
-
Save DiscordLinuxBot/599d41ae3e0d3c40080cb2c3310d47a9 to your computer and use it in GitHub Desktop.
libbash.bbtag
This file contains hidden or 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
{//;Function to set export variables bash style} | |
{//;{function;export;{switch;{guildid};["204061452707954688","96230004047740928"];{if;{length;{split;{params};=}};<;2;{exec;Echo;Usage: '{lb}func.export{semi}VARIABLE=stuff here{rb}'};{set;@libbash.var.${jget;{split;{params};=};0};{if;{jget;{split;{params};=};1};!=;;{join;{slice;{split;{regexreplace;{params};/"/g;};=};1};=}}}{push;@libbash.variable.list;Var: {jget;{split;{params};=};0} - Value: {join;{slice;{split;{regexreplace;{params};/"/g;};=};1};=} - User: {username}}{reactadd;{messageid};<:SeemsGood:478441196755091461>}};{exec;Echo;bash: {lb}func.export{rb}: Permission denied}}}} | |
{function;export;{if;{length;{split;{params};=}};<;2;{exec;Echo;Usage: '{lb}func.export{semi}VARIABLE=stuff here{rb}'};{switch;{jget;{split;{params};=};0};["LANG","HOSTNAME","USER","PWD","HOME","SHELL","RUNNER_USER","SHLVL","PATH","_"];{exec;Echo;export {params}{newline}export {params}: Permission denied};{if;{get;@{guildid}.bash.var.array};==;{null};{set;!@{guildid}.bash.var.array;[]}}{push;@{guildid}.bash.var.array;{params}}{reactadd;{messageid};<:SeemsGood:478441196755091461>}}}} | |
{//;Function to replace bash style variables with exported variables if they exist in input text} | |
{//;{function;echo;{trim;{foreach;~word;{split;{regexreplace;{params};/(\\n)/gm;{space}{newline}{space}};{space}};{if;{get;~word};!=;;{if;{get;@libbash.var.{get;~word}};!=;;{get;@libbash.var.{get;~word}};{if;{get;@libbash.var.{regexreplace;{get;~word};/"/g;}};!=;;{get;@libbash.var.{regexreplace;{get;~word};/"/g;}};{get;~word}}}{space}}}}}} | |
{function;echo;{set;!~libbashechoout;{params}}{set;!~libbashvars;{regexmatch;{get;~libbashechoout};/\$\w+/g}}{foreach;~libbashvar;{get;~libbashvars};{if;{get;@libbash.var.{get;~libbashvar}};!=;{null};{set;!~libbashechoout;{replace;{get;~libbashechoout};{get;~libbashvar};{get;@libbash.var.{get;~libbashvar}}}}}}{get;~libbashechoout}} | |
{//;Function to set aliases to run other tags/ccs} | |
{function;alias;{if;{isstaff;{userid}};{if;{length;{split;{params};=}};<;2;{exec;Echo;Usage: '{lb}func.alias{semi}myalias=exec sometag{rb}'};{set;!_libbash.alias.{jget;{split;{params};=};0};{if;{jget;{split;{params};=};1};!=;;{split;{join;{slice;{split;{regexreplace;{params};/"/g;};=};1};=};{space}}}}{reactadd;{messageid};<:SeemsGood:478441196755091461>}};{exec;Echo;bash: alias: Permission denied}}} | |
{//;Function to export bash functions for use with rextester API} | |
{function;exportf;{if;{isstaff;{userid}};{if;{length;{paramsarray}};<;2;{exec;_echo;export -f{newline}Usage: export -f <bash script function>};{set;!_libbash.function.{params;0};{params;1;n}}{reactadd;{messageid};<:SeemsGood:478441196755091461>}};{exec;Echo;bash: export -f: Permission denied}}} | |
{//;Function to execute aliases} | |
{function;exec;{if;{get;_libbash.alias.{params;0}};==;{//;empty};{exec;Echo;Usage: '{lb}func.exec{semi}<alias>{semi}[args]{rb}'};{apply;{get;_libbash.alias.{params;0};0};{split;{func.echo;{join;{slice;{get;_libbash.alias.{params;0}};1};{space}}};{space}};{if;{params;1};startswith;`Not;;{func.echo;{params;1;n}}}}}} | |
{//;{function;exec;{if;{get;_libbash.alias.{params;0}};==;{//;empty};{exec;Echo;Usage: '{lb}func.exec{semi}<alias>{semi}[args]{rb}'};{apply;{get;_libbash.alias.{params;0};0};{slice;{get;_libbash.alias.{params;0}};1};{if;{params;1};startswith;`Not;;{params;1;n}}}}}} | |
{//;Function to check if alias exists} | |
{function;type;{if;{length;{paramsarray}};==;1;{if;{get;_libbash.alias.{params;0}};==;;{exec;Echo;{params;0} not found};{exec;Echo;{params;0} is an alias for {join;{jget;{get;_libbash.alias.{params;0}};v};{space}}}};{exec;Echo;Usage: '{lb}func.type{semi}<alias>{rb}'}}} | |
{//;Function to run bash script using rextester API} | |
{function;test;{exec;rextester-bash;{params}}} | |
{//;{function;test;{switch;{guildid};["204061452707954688","96230004047740928"];{if;{params};startswith;`Not;{exec;Echo;Usage: '{lb}func.test{semi}<commands>{rb}'};{set;!~url;https://api.jdoodle.com/v1/execute}{set;!~data;{jset;{jset;{json;{"clientId":"6be500954e4a3ea7795165d21ce5247e","language":"bash","versionIndex":"2"}};clientSecret;{get;@simon.jdoodle.clientSecret}};script;{params}}}{fallback;Error running '{params}'}{exec;Echo;{jget;{apply;request;{get;~url};{json;{"method":"POST","headers":{"Content-Type":"application/json"}}};{get;~data}};body.output}}};{exec;Echo;bash: {lb}func.test{rb}: Permission denied}}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment