repo_name
stringlengths
6
69
path
stringlengths
6
178
copies
stringclasses
278 values
size
stringlengths
4
7
content
stringlengths
671
917k
license
stringclasses
15 values
anshkumar/yugioh-glaze
assets/script/c70046172.lua
3
1285
--突進 function c70046172.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_ATKCHANGE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(TIMING_DAMAGE_STEP) e1:SetCondition(c70046172.condition) e1:SetTarget(c70046172.target) e1:SetOperation(c70046172.activate) c:RegisterEffect(e1) end function c70046172.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated() end function c70046172.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) end function c70046172.activate(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and tc:IsFaceup() then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END) e1:SetValue(700) tc:RegisterEffect(e1) end end
gpl-2.0
assassinboy208/eagleTG
plugins/face.lua
641
3073
local https = require("ssl.https") local ltn12 = require "ltn12" -- Edit data/mashape.lua with your Mashape API key -- http://docs.mashape.com/api-keys local mashape = load_from_file('data/mashape.lua', { api_key = '' }) local function request(imageUrl) local api_key = mashape.api_key if api_key:isempty() then return nil, 'Configure your Mashape API Key' end local api = "https://faceplusplus-faceplusplus.p.mashape.com/detection/detect?" local parameters = "attribute=gender%2Cage%2Crace" parameters = parameters .. "&url="..(URL.escape(imageUrl) or "") local url = api..parameters local headers = { ["X-Mashape-Key"] = api_key, ["Accept"] = "Accept: application/json" } print(url) local respbody = {} local body, code = https.request{ url = url, method = "GET", headers = headers, sink = ltn12.sink.table(respbody), protocol = "tlsv1" } if code ~= 200 then return "", code end local body = table.concat(respbody) return body, code end local function parseData(data) local jsonBody = json:decode(data) local response = "" if jsonBody.error ~= nil then if jsonBody.error == "IMAGE_ERROR_FILE_TOO_LARGE" then response = response .. "The image is too big. Provide a smaller image." elseif jsonBody.error == "IMAGE_ERROR_FAILED_TO_DOWNLOAD" then response = response .. "Is that a valid url for an image?" else response = response .. jsonBody.error end elseif jsonBody.face == nil or #jsonBody.face == 0 then response = response .. "No faces found" else response = response .. #jsonBody.face .." face(s) found:\n\n" for k,face in pairs(jsonBody.face) do local raceP = "" if face.attribute.race.confidence > 85.0 then raceP = face.attribute.race.value:lower() elseif face.attribute.race.confidence > 50.0 then raceP = "(probably "..face.attribute.race.value:lower()..")" else raceP = "(posibly "..face.attribute.race.value:lower()..")" end if face.attribute.gender.confidence > 85.0 then response = response .. "There is a " else response = response .. "There may be a " end response = response .. raceP .. " " .. face.attribute.gender.value:lower() .. " " response = response .. ", " .. face.attribute.age.value .. "(±".. face.attribute.age.range ..") years old \n" end end return response end local function run(msg, matches) --return request('http://www.uni-regensburg.de/Fakultaeten/phil_Fak_II/Psychologie/Psy_II/beautycheck/english/durchschnittsgesichter/m(01-32)_gr.jpg') local data, code = request(matches[1]) if code ~= 200 then return "There was an error. "..code end return parseData(data) end return { description = "Who is in that photo?", usage = { "!face [url]", "!recognise [url]" }, patterns = { "^!face (.*)$", "^!recognise (.*)$" }, run = run }
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c13944422.lua
7
1751
--グラナドラ function c13944422.initial_effect(c) --recover local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(13944422,0)) e1:SetCategory(CATEGORY_RECOVER) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetTarget(c13944422.rectg) e1:SetOperation(c13944422.recop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e2) local e3=e1:Clone() e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e3) --damage local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(13944422,1)) e4:SetCategory(CATEGORY_DAMAGE) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e4:SetCode(EVENT_TO_GRAVE) e4:SetCondition(c13944422.damcon) e4:SetTarget(c13944422.damtg) e4:SetOperation(c13944422.damop) c:RegisterEffect(e4) end function c13944422.rectg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1000) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,1000) end function c13944422.recop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Recover(p,d,REASON_EFFECT) end function c13944422.damcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_DESTROY) end function c13944422.damtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(2000) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,tp,2000) end function c13944422.damop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Damage(p,d,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c22339232.lua
3
2759
--ワイトメア function c22339232.initial_effect(c) --change code local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_GRAVE) e1:SetCode(EFFECT_CHANGE_CODE) e1:SetValue(32274490) c:RegisterEffect(e1) --to grave local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(22339232,0)) e2:SetCategory(CATEGORY_TOGRAVE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_HAND) e2:SetCost(c22339232.cost) e2:SetTarget(c22339232.tgtg) e2:SetOperation(c22339232.tgop) c:RegisterEffect(e2) --special summon local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(22339232,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_HAND) e3:SetCost(c22339232.cost) e3:SetTarget(c22339232.sptg) e3:SetOperation(c22339232.spop) c:RegisterEffect(e3) end function c22339232.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsDiscardable() end Duel.SendtoGrave(e:GetHandler(),REASON_COST+REASON_DISCARD) end function c22339232.tgfilter(c) local code=c:GetCode() return c:IsFaceup() and (code==32274490 or code==22339232) end function c22339232.tgtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c22339232.tgfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c22339232.tgfilter,tp,LOCATION_REMOVED,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectTarget(tp,c22339232.tgfilter,tp,LOCATION_REMOVED,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0) end function c22339232.tgop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SendtoGrave(tc,REASON_EFFECT+REASON_RETURN) end end function c22339232.spfilter(c,e,tp) local code=c:GetCode() return c:IsFaceup() and (code==36021814 or code==40991587) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c22339232.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and c22339232.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c22339232.spfilter,tp,LOCATION_REMOVED,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c22339232.spfilter,tp,LOCATION_REMOVED,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,1,0,0) end function c22339232.spop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
alireza1998/power
plugins/help1.lua
1
1873
1 do 2 3 -- Returns true if is not empty 4 local function has_usage_data(dict) 5 if (dict.usage == nil or dict.usage == '') then 6 return false 7 end 8 return true 9 end 10 11 -- Get commands for that plugin 12 local function plugin_help(name) 13 local plugin = plugins[name] 14 if not plugin then return nil end 15 16 local text = "" 17 if (type(plugin.usage) == "table") then 18 for ku,usage in pairs(plugin.usage) do 19 text = text..usage..'\n' 20 end 21 text = text..'\n' 22 elseif has_usage_data(plugin) then -- Is not empty 23 text = text..plugin.usage..'\n\n' 24 end 25 return text 26 end 27 28 -- !help command 29 local function telegram_help() 30 local text = "Plugin list: \n\n" 31 -- Plugins names 32 for name in pairs(plugins) do 33 text = text..name..'\n' 34 end 35 text = text..'\n'..'Write "!help [plugin name]" for more info.' 36 text = text..'\n'..'Or "!help all" to show all info.' 37 return text 38 end 39 40 -- !help all command 41 local function help_all() 42 local ret = "" 43 for name in pairs(plugins) do 44 ret = ret .. plugin_help(name) 45 end 46 return ret 47 end 48 49 local function run(msg, matches) 50 if matches[1] == "!help" then 51 return telegram_help() 52 elseif matches[1] == "!help all" then 53 return help_all() 54 else 55 local text = plugin_help(matches[1]) 56 if not text then 57 text = telegram_help() 58 end 59 return text 60 end 61 end 62 63 return { 64 description = "Help plugin. Get info from other plugins. ", 65 usage = { 66 "help: Show list of plugins.", 67 "help all: Show all commands for every plugin.", 68 "help [plugin name]: Commands for that plugin." 69 }, 70 patterns = { 71 "^help$", 72 "^help all", 73 "^help (.+)" 74 }, 75 run = run 76 } 77 78 end
gpl-2.0
chenjiansnail/skynet
lualib/snax/loginserver.lua
42
5057
local skynet = require "skynet" require "skynet.manager" local socket = require "socket" local crypt = require "crypt" local table = table local string = string local assert = assert --[[ Protocol: line (\n) based text protocol 1. Server->Client : base64(8bytes random challenge) 2. Client->Server : base64(8bytes handshake client key) 3. Server: Gen a 8bytes handshake server key 4. Server->Client : base64(DH-Exchange(server key)) 5. Server/Client secret := DH-Secret(client key/server key) 6. Client->Server : base64(HMAC(challenge, secret)) 7. Client->Server : DES(secret, base64(token)) 8. Server : call auth_handler(token) -> server, uid (A user defined method) 9. Server : call login_handler(server, uid, secret) ->subid (A user defined method) 10. Server->Client : 200 base64(subid) Error Code: 400 Bad Request . challenge failed 401 Unauthorized . unauthorized by auth_handler 403 Forbidden . login_handler failed 406 Not Acceptable . already in login (disallow multi login) Success: 200 base64(subid) ]] local socket_error = {} local function assert_socket(service, v, fd) if v then return v else skynet.error(string.format("%s failed: socket (fd = %d) closed", service, fd)) error(socket_error) end end local function write(service, fd, text) assert_socket(service, socket.write(fd, text), fd) end local function launch_slave(auth_handler) local function auth(fd, addr) fd = assert(tonumber(fd)) skynet.error(string.format("connect from %s (fd = %d)", addr, fd)) socket.start(fd) -- set socket buffer limit (8K) -- If the attacker send large package, close the socket socket.limit(fd, 8192) local challenge = crypt.randomkey() write("auth", fd, crypt.base64encode(challenge).."\n") local handshake = assert_socket("auth", socket.readline(fd), fd) local clientkey = crypt.base64decode(handshake) if #clientkey ~= 8 then error "Invalid client key" end local serverkey = crypt.randomkey() write("auth", fd, crypt.base64encode(crypt.dhexchange(serverkey)).."\n") local secret = crypt.dhsecret(clientkey, serverkey) local response = assert_socket("auth", socket.readline(fd), fd) local hmac = crypt.hmac64(challenge, secret) if hmac ~= crypt.base64decode(response) then write("auth", fd, "400 Bad Request\n") error "challenge failed" end local etoken = assert_socket("auth", socket.readline(fd),fd) local token = crypt.desdecode(secret, crypt.base64decode(etoken)) local ok, server, uid = pcall(auth_handler,token) socket.abandon(fd) return ok, server, uid, secret end local function ret_pack(ok, err, ...) if ok then skynet.ret(skynet.pack(err, ...)) else if err == socket_error then skynet.ret(skynet.pack(nil, "socket error")) else skynet.ret(skynet.pack(false, err)) end end end skynet.dispatch("lua", function(_,_,...) ret_pack(pcall(auth, ...)) end) end local user_login = {} local function accept(conf, s, fd, addr) -- call slave auth local ok, server, uid, secret = skynet.call(s, "lua", fd, addr) socket.start(fd) if not ok then if ok ~= nil then write("response 401", fd, "401 Unauthorized\n") end error(server) end if not conf.multilogin then if user_login[uid] then write("response 406", fd, "406 Not Acceptable\n") error(string.format("User %s is already login", uid)) end user_login[uid] = true end local ok, err = pcall(conf.login_handler, server, uid, secret) -- unlock login user_login[uid] = nil if ok then err = err or "" write("response 200",fd, "200 "..crypt.base64encode(err).."\n") else write("response 403",fd, "403 Forbidden\n") error(err) end end local function launch_master(conf) local instance = conf.instance or 8 assert(instance > 0) local host = conf.host or "0.0.0.0" local port = assert(tonumber(conf.port)) local slave = {} local balance = 1 skynet.dispatch("lua", function(_,source,command, ...) skynet.ret(skynet.pack(conf.command_handler(command, ...))) end) for i=1,instance do table.insert(slave, skynet.newservice(SERVICE_NAME)) end skynet.error(string.format("login server listen at : %s %d", host, port)) local id = socket.listen(host, port) socket.start(id , function(fd, addr) local s = slave[balance] balance = balance + 1 if balance > #slave then balance = 1 end local ok, err = pcall(accept, conf, s, fd, addr) if not ok then if err ~= socket_error then skynet.error(string.format("invalid client (fd = %d) error = %s", fd, err)) end socket.start(fd) end socket.close(fd) end) end local function login(conf) local name = "." .. (conf.name or "login") skynet.start(function() local loginmaster = skynet.localname(name) if loginmaster then local auth_handler = assert(conf.auth_handler) launch_master = nil conf = nil launch_slave(auth_handler) else launch_slave = nil conf.auth_handler = nil assert(conf.login_handler) assert(conf.command_handler) skynet.register(name) launch_master(conf) end end) end return login
mit
anshkumar/yugioh-glaze
assets/script/c60946968.lua
3
1052
--異界空間-Aゾーン function c60946968.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --atk def local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_DAMAGE_CALCULATING) e2:SetRange(LOCATION_SZONE) e2:SetOperation(c60946968.adval) c:RegisterEffect(e2) end function c60946968.addown(c,e) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_PHASE+RESET_DAMAGE_CAL) e1:SetValue(-300) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_UPDATE_DEFENCE) c:RegisterEffect(e2) end function c60946968.adval(e,tp,eg,ep,ev,re,r,rp) local a=Duel.GetAttacker() local d=Duel.GetAttackTarget() if not d then return end if a:IsControler(1-tp) and d:IsSetCard(0xc) then c60946968.addown(a,e) end if d:IsControler(1-tp) and a:IsSetCard(0xc) then c60946968.addown(d,e) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c2978414.lua
3
3621
--No.46 神影龍ドラッグルーオン function c2978414.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsRace,RACE_DRAGON),8,2) c:EnableReviveLimit() --spsummon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(2978414,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e1:SetCondition(c2978414.condition) e1:SetCost(c2978414.cost) e1:SetTarget(c2978414.sptg) e1:SetOperation(c2978414.spop) c:RegisterEffect(e1) --control local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(2978414,1)) e2:SetCategory(CATEGORY_CONTROL) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e2:SetCondition(c2978414.condition) e2:SetCost(c2978414.cost) e2:SetTarget(c2978414.cttg) e2:SetOperation(c2978414.ctop) c:RegisterEffect(e2) --effect limit local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(2978414,2)) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e3:SetCondition(c2978414.condition) e3:SetCost(c2978414.cost) e3:SetOperation(c2978414.efop) c:RegisterEffect(e3) end c2978414.xyz_number=46 function c2978414.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetFieldGroupCount(tp,LOCATION_MZONE,0)<=1 end function c2978414.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c2978414.spfilter(c,e,tp) return c:IsRace(RACE_DRAGON) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c2978414.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c2978414.spfilter,tp,LOCATION_HAND,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND) end function c2978414.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c2978414.spfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end function c2978414.ctfilter(c) return c:IsFaceup() and c:IsRace(RACE_DRAGON) and c:IsControlerCanBeChanged() end function c2978414.cttg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and c2978414.ctfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c2978414.ctfilter,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONTROL) local g=Duel.SelectTarget(tp,c2978414.ctfilter,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_CONTROL,g,1,0,0) end function c2978414.ctop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and not Duel.GetControl(tc,tp) then if not tc:IsImmuneToEffect(e) and tc:IsAbleToChangeControler() then Duel.Destroy(tc,REASON_EFFECT) end end end function c2978414.efop(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_TRIGGER) e1:SetTargetRange(0,LOCATION_MZONE) e1:SetTarget(c2978414.actfilter) e1:SetReset(RESET_PHASE+PHASE_END+RESET_OPPO_TURN,1) Duel.RegisterEffect(e1,tp) end function c2978414.actfilter(e,c) return c:IsRace(RACE_DRAGON) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c80161395.lua
3
1223
--神秘の中華なべ function c80161395.initial_effect(c) --recover local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_RECOVER) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCost(c80161395.cost) e1:SetTarget(c80161395.target) e1:SetOperation(c80161395.activate) c:RegisterEffect(e1) end function c80161395.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,nil,1,nil) end local sg=Duel.SelectReleaseGroup(tp,nil,1,1,nil) local tc=sg:GetFirst() local atk=tc:GetAttack() local def=tc:GetDefence() Duel.Release(tc,REASON_COST) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(80161395,0)) local sel=Duel.SelectOption(tp,aux.Stringid(80161395,1),aux.Stringid(80161395,2)) if sel==0 then e:SetLabel(atk) else e:SetLabel(def) end end function c80161395.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(e:GetLabel()) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,e:GetLabel()) end function c80161395.activate(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Recover(p,d,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c6979239.lua
9
1240
--リーフ・フェアリー function c6979239.initial_effect(c) --damage local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(6979239,0)) e1:SetCategory(CATEGORY_DAMAGE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCost(c6979239.cost) e1:SetTarget(c6979239.target) e1:SetOperation(c6979239.operation) c:RegisterEffect(e1) end function c6979239.filter(c,ec) return c:GetEquipTarget()==ec and c:IsAbleToGraveAsCost() end function c6979239.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c6979239.filter,tp,LOCATION_SZONE,LOCATION_SZONE,1,nil,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c6979239.filter,tp,LOCATION_SZONE,LOCATION_SZONE,1,1,nil,e:GetHandler()) Duel.SendtoGrave(g,REASON_COST) end function c6979239.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(500) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,500) end function c6979239.operation(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Damage(p,d,REASON_EFFECT) end
gpl-2.0
freifunk-gluon/luci
libs/nixio/docsrc/nixio.bit.lua
171
2044
--- Bitfield operators and mainpulation functions. -- Can be used as a drop-in replacement for bitlib. module "nixio.bit" --- Bitwise OR several numbers. -- @class function -- @name bor -- @param oper1 First Operand -- @param oper2 Second Operand -- @param ... More Operands -- @return number --- Invert given number. -- @class function -- @name bnot -- @param oper Operand -- @return number --- Bitwise AND several numbers. -- @class function -- @name band -- @param oper1 First Operand -- @param oper2 Second Operand -- @param ... More Operands -- @return number --- Bitwise XOR several numbers. -- @class function -- @name bxor -- @param oper1 First Operand -- @param oper2 Second Operand -- @param ... More Operands -- @return number --- Left shift a number. -- @class function -- @name lshift -- @param oper number -- @param shift bits to shift -- @return number --- Right shift a number. -- @class function -- @name rshift -- @param oper number -- @param shift bits to shift -- @return number --- Arithmetically right shift a number. -- @class function -- @name arshift -- @param oper number -- @param shift bits to shift -- @return number --- Integer division of 2 or more numbers. -- @class function -- @name div -- @param oper1 Operand 1 -- @param oper2 Operand 2 -- @param ... More Operands -- @return number --- Cast a number to the bit-operating range. -- @class function -- @name cast -- @param oper number -- @return number --- Sets one or more flags of a bitfield. -- @class function -- @name set -- @param bitfield Bitfield -- @param flag1 First Flag -- @param ... More Flags -- @return altered bitfield --- Unsets one or more flags of a bitfield. -- @class function -- @name unset -- @param bitfield Bitfield -- @param flag1 First Flag -- @param ... More Flags -- @return altered bitfield --- Checks whether given flags are set in a bitfield. -- @class function -- @name check -- @param bitfield Bitfield -- @param flag1 First Flag -- @param ... More Flags -- @return true when all flags are set, otherwise false
apache-2.0
anshkumar/yugioh-glaze
assets/script/c30741334.lua
7
1452
--熱血指導王ジャイアントレーナー function c30741334.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,nil,8,3) c:EnableReviveLimit() --draw local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DRAW+CATEGORY_DAMAGE) e1:SetDescription(aux.Stringid(30741334,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(3,30741334) e1:SetCost(c30741334.cost) e1:SetTarget(c30741334.target) e1:SetOperation(c30741334.operation) c:RegisterEffect(e1) end function c30741334.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetCurrentPhase()==PHASE_MAIN1 and e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_BP) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c30741334.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c30741334.operation(e,tp,eg,ep,ev,re,r,rp,chk) local ct=Duel.Draw(tp,1,REASON_EFFECT) if ct==0 then return end local dc=Duel.GetOperatedGroup():GetFirst() Duel.ConfirmCards(1-tp,dc) if dc:IsType(TYPE_MONSTER) then Duel.Damage(1-tp,800,REASON_EFFECT) end Duel.ShuffleHand(tp) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c51085303.lua
3
1436
--E・HERO ブルーメ function c51085303.initial_effect(c) c:EnableReviveLimit() --cannot special summon local e1=Effect.CreateEffect(c) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --atk/def local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(51085303,0)) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_BATTLE_DAMAGE) e2:SetCondition(c51085303.adcon) e2:SetOperation(c51085303.adop) c:RegisterEffect(e2) -- local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET) e3:SetRange(LOCATION_MZONE) e3:SetTargetRange(0,LOCATION_MZONE) e3:SetValue(c51085303.atlimit) c:RegisterEffect(e3) end function c51085303.adcon(e,tp,eg,ep,ev,re,r,rp) return ep~=tp end function c51085303.adop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsFaceup() and c:GetDefence()>=200 then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetProperty(EFFECT_FLAG_COPY_INHERIT) e1:SetValue(200) e1:SetReset(RESET_EVENT+0x1ff0000) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_UPDATE_DEFENCE) e2:SetValue(-200) c:RegisterEffect(e2) end end function c51085303.atlimit(e,c) return c:IsFacedown() or not c:IsCode(51085303) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c3701074.lua
5
2051
--ダーク・キュア function c3701074.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --Activate local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(3701074,0)) e2:SetCategory(CATEGORY_RECOVER) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e2:SetRange(LOCATION_SZONE) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetTarget(c3701074.rectg1) e2:SetOperation(c3701074.recop1) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e3) local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(3701074,0)) e4:SetCategory(CATEGORY_RECOVER) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e4:SetRange(LOCATION_SZONE) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetTarget(c3701074.rectg2) e4:SetOperation(c3701074.recop2) c:RegisterEffect(e4) end function c3701074.rectg1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return rp~=tp end Duel.SetTargetCard(eg) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,1-tp,0) end function c3701074.recop1(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local tc=eg:GetFirst() if tc:IsRelateToEffect(e) and tc:IsFaceup() then local rec=tc:GetAttack()/2 Duel.Recover(1-tp,rec,REASON_EFFECT) end end function c3701074.filter(c,e,tp) return c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:GetSummonPlayer()==1-tp and (not e or c:IsRelateToEffect(e)) end function c3701074.rectg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return eg:IsExists(c3701074.filter,1,nil,nil,tp) end Duel.SetTargetCard(eg) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,1-tp,0) end function c3701074.recop2(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=eg:Filter(c3701074.filter,nil,e,tp) if g:GetCount()>0 then if g:GetCount()>1 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) g=g:Select(tp,1,1,nil) end Duel.Recover(1-tp,g:GetFirst():GetAttack()/2,REASON_EFFECT) end end
gpl-2.0
shirat74/sile
languages/da.lua
4
9671
SILE.hyphenator.languages["da"] = {}; SILE.hyphenator.languages["en"].patterns = { ".ae3", ".an3k", ".an1s", ".be5la", ".be1t", ".bi4tr", ".der3i", ".diagno5", ".her3", ".hoved3", ".ne4t5", ".om1", ".ove4", ".po1", ".til3", ".yd5r", "ab5le", "3abst", "a3c", "ade5la", "5adg", "a1e", "5afg", "5a4f1l", "af3r", "af4ri", "5afs", "a4gef", "a4gi", "ag5in", "ag5si", "3agti", "a4gy", "a3h", "ais5t", "a3j", "a5ka", "a3ke", "a5kr", "aku5", "a3la", "a1le", "a1li", "al3k", "4alkv", "a1lo", "al5si", "a3lu", "a1ly", "am4pa", "3analy", "an4k5r", "a3nu", "3anv", "a5o", "a5pe", "a3pi", "a5po", "a1ra", "ar5af", "1arb", "a1re", "5arg", "a1ri", "a3ro", "a3sa", "a3sc", "a1si", "a3sk", "a3so", "3a3sp", "a3ste", "a3sti", "a1ta1", "a1te", "a1ti", "a4t5in", "a1to", "ato5v", "a5tr", "a1tu", "a5va", "a1ve", "a5z", "1ba", "ba4ti", "4bd", "1be", "be1k", "be3ro", "be5ru", "be1s4", "be1tr", "1bi", "bi5sk", "b1j", "4b1n", "1bo", "bo4gr", "bo3ra", "bo5re", "1br4", "4bs", "bs5k", "b3so", "b1st", "b5t", "3bu", "bu4s5tr", "b5w", "1by", "by5s", "4c1c", "1ce", "ce5ro", "3ch", "4ch.", "ci4o", "ck3", "5cy", "3da", "4d3af", "d5anta", "da4s", "d1b", "d1d4", "1de", "de5d", "4de4lem", "der5eri", "de4rig", "de5sk", "d1f", "d1g", "d3h", "1di", "di1e", "di5l", "d3j", "d1k", "d1l", "d1m", "4d1n", "3do", "4dop", "d5ov", "d1p", "4drett", "5d4reve", "3drif", "3driv", "d5ros", "d5ru", "ds5an", "ds5in", "d1ski", "d4sm", "d4su", "dsu5l", "ds5vi", "d3ta", "d1te", "dt5o", "d5tr", "dt5u", "1du", "dub5", "d1v", "3dy", "e5ad", "e3af", "e5ag", "e3ak", "e1al", "ea4la", "e3an", "e5ap", "e3at", "e3bl", "ebs3", "e1ci", "ed5ar", "edde4", "eddel5", "e4do", "ed5ra", "ed3re", "ed3rin", "ed4str", "e3e", "3eff", "e3fr", "3eft", "e3gu", "e1h", "e3in", "ei5s", "e3je", "e4j5el", "e1ka", "e3ke", "e3kl", "4e1ko", "e5kr", "ek5sa", "3eksem", "3eksp", "e3ku", "e1kv", "e5ky", "e3lad", "el3ak", "el3ar", "e1las", "e3le", "e4lek", "3elem", "e1li", "5elim", "e3lo", "el5sa", "e5lu", "e3ly", "e4mad", "em4p5le", "em1s", "en5ak", "e4nan", "4enn", "e4no", "en3so", "e5nu", "e5ol", "e3op", "e1or", "e3ov", "epi3", "e1pr", "e3ra", "er3af", "e4rag", "e4rak", "e1re", "e4ref", "er5ege", "5erhv", "e1ri", "e4rib", "er1k", "ero5d", "er5ov", "er3s", "er5tr", "e3rum", "er5un", "e5ry", "e1ta", "e1te", "etek4s", "e1ti", "e3tj", "e1to", "e3tr", "e3tu", "e1ty", "e3um", "e3un", "3eur", "e1va", "e3ve", "e4v3erf", "e1vi", "e5x", "1fa", "fa4ce", "fags3", "f1b", "f1d", "1fe", "fej4", "fejl1", "f1f", "f1g", "f1h", "1fi", "f1k", "3fl", "1fo", "for1en", "fo4ri", "f1p", "f1s4", "4ft", "f3ta", "f1te", "f1ti", "f5to", "f5tvi", "1fu", "f1v", "3fy", "1ga", "g3art", "g1b", "g1d", "1ge", "4g5enden", "ger3in", "ge3s", "g3f", "g1g", "g1h", "1gi", "gi4b", "gi3st", "5gj", "g3k", "g1l", "g1m", "3go", "4g5om", "g5ov", "g3p", "1gr", "gs1a", "gsde4len", "g4se", "gsha4", "g5sla", "gs3or", "gs1p", "g5s4tide", "g4str", "gs1v", "g3ta", "g1te", "g1ti", "g5to", "g3tr", "gt4s", "g3ud", "gun5", "g3v", "1gy", "g5yd", "4ha.", "heds3", "he5s", "4het", "hi4e", "hi4n5", "hi3s", "ho5ko", "ho5ve", "4h3t", "hun4", "hund3", "hvo4", "i1a", "i3b", "i4ble", "i1c", "i3dr", "ids5k", "i1el", "i1en", "i3er", "i3et.", "if3r", "i3gu", "i3h", "i5i", "i5j", "i1ka", "i1ke", "ik1l", "i5ko", "ik3re", "ik5ri", "iks5t", "ik4tu", "i3ku", "ik3v", "i3lag", "il3eg", "il5ej", "il5el", "i3li", "i4l5id", "il3k", "i1lo", "il5u", "i3mu", "ind3t", "5inf", "ings1", "in3s", "in4sv", "inter1", "i3nu", "i3od", "i3og", "i5ok", "i3ol", "ion4", "ions1", "i5o5r", "i3ot", "i5pi", "i3pli", "i5pr", "i3re", "i3ri", "ir5t", "i3sc", "i3si", "i4sm", "is3p", "i1ster", "i3sti", "i5sua", "i1ta", "i1te", "i1ti", "i3to", "i3tr", "it5re.", "i1tu", "i3ty", "i1u", "i1va", "i1ve", "i1vi", "j3ag", "jde4rer", "jds1", "jek4to", "4j5en.", "j5k", "j3le", "j3li", "jlmeld5", "jlmel4di", "j3r", "jre5", "ju3s", "5kap", "k5au", "5kav", "k5b", "kel5s", "ke3sk", "ke5st", "ke4t5a", "k3h", "ki3e", "ki3st", "k1k", "k5lak", "k1le", "3klu", "k4ny", "5kod", "1kon", "ko3ra", "3kort", "ko3v", "1kra", "5kry", "ks3an", "k1si", "ks3k", "ks1p", "k3ste", "k5stu", "ks5v", "k1t", "k4tar", "k4terh", "kti4e", "kt5re", "kt5s", "3kur", "1kus", "3kut", "k4vo", "k4vu", "5lab", "lad3r", "5lagd", "la4g3r", "5lam", "1lat", "l1b", "ldiagnos5", "l3dr", "ld3st", "1le.", "5led", "4lele", "le4mo", "3len", "1ler", "1les", "4leu", "l1f", "lfin4", "lfind5", "l1go1", "l3h", "li4ga", "4l5ins", "4l3int", "li5o", "l3j", "l1ke", "l1ko", "l3ky", "l1l", "l5mu", "lo4du", "l3op", "4l5or", "3lov", "4l3p", "l4ps", "l3r", "4ls", "lses1", "ls5in", "l5sj", "l1ta", "l4taf", "l1te", "l4t5erf", "l3ti", "lt3o", "l3tr", "l3tu", "lu5l", "l3ve", "l3vi", "1ma", "m1b", "m3d", "1me", "4m5ej", "m3f", "m1g", "m3h", "1mi", "mi3k", "m5ing", "mi4o", "mi5sty", "m3k", "m1l", "m1m", "mmen5", "m1n", "3mo", "mo4da", "4mop", "4m5ov", "m1pe", "m3pi", "m3pl", "m1po", "m3pr", "m1r", "mse5s", "ms5in", "m5sk", "ms3p", "m3ste", "ms5v", "m3ta", "m3te", "m3ti", "m3tr", "m1ud", "1mul", "mu1li", "3my", "3na", "4nak", "1nal", "n1b", "n1c", "4nd", "n3dr", "nd5si", "nd5sk", "nd5sp", "1ne", "ne5a", "ne4da", "nemen4", "nement5e", "neo4", "n3erk", "n5erl", "ne5sl", "ne5st", "n1f", "n4go", "4n1h", "1ni", "4nim", "ni5o", "ni3st", "n1ke", "n1ko", "n3kr", "n3ku", "n5kv", "4n1l", "n1m", "n1n", "1no", "n3ord", "n5p", "n3r", "4ns", "n3si", "n1sku", "ns3po", "n1sta", "n5sti", "n1ta", "nta4le", "n1te", "n1ti", "ntiali4", "n3to", "n1tr", "nt4s5t", "nt4su", "n3tu", "n3ty", "4n1v", "3ny", "n3z", "o3a", "o4as", "ob3li", "o1c", "o4din", "od5ri", "od5s", "od5un", "o1e", "of5r", "o4gek", "o4gel", "o4g5o", "og5re", "og5sk", "o5h", "o5in", "oi6s5e", "o1j", "o3ka", "o1ke", "o3ku", "o3la", "o3le", "o1li", "o1lo", "o3lu", "o5ly", "1omr", "on3k", "ook5", "o3or", "o5ov", "o3pi", "op3l", "op3r", "op3s", "3opta", "4or.", "or1an", "3ordn", "ord5s", "o3re.", "o3reg", "o3rek", "o3rer", "o3re3s", "o3ret", "o3ri", "3orient", "or5im", "o4r5in", "or3k", "or5o", "or3sl", "or3st", "o3si", "o3so", "o3t", "o1te", "o5un", "ov4s", "3pa", "pa5gh", "p5anl", "p3d", "4pec", "3pen", "1per", "pe1ra", "pe5s", "pe3u", "p3f", "4p5h", "1pla", "p4lan", "4ple.", "4pler", "4ples", "p3m", "p3n", "5pok", "4po3re", "3pot", "4p5p4", "p4ro", "1proc", "p3sk", "p5so", "ps4p", "p3st", "p1t", "1pu", "pu5b", "p5ule", "p5v", "5py3", "qu4", "4raf", "ra5is", "4rarb", "r1b", "r4d5ar", "r3dr", "rd4s3", "4reks", "1rel", "re5la", "r5enss", "5rese", "re5spo", "4ress", "re3st", "re5s4u", "5rett", "r1f", "r1gu", "r1h", "ri1e", "ri5la", "4rimo", "r4ing", "ringse4", "ringso4r", "4rinp", "4rint", "r3ka", "r1ke", "r1ki", "rk3so", "r3ku", "r1l", "rmo4", "r5mu", "r1n", "ro1b", "ro3p", "r3or", "r3p", "r1r", "rre5s", "rro4n5", "r1sa", "r1si", "r5skr", "r4sk5v", "rs4n", "r3sp", "r5stu", "r5su", "r3sv", "r5tal", "r1te", "r4teli", "r1ti", "r3to", "r4t5or", "rt5rat", "rt3re", "r5tri", "r5tro", "rt3s", "r5ty", "r3ud", "run4da", "5rut", "r3va", "r1ve", "r3vi", "ry4s", "s3af", "1sam", "sa4ma", "s3ap", "s1ar", "1sat", "4s1b", "s1d", "sdy4", "1se", "s4ed", "5s4er", "se4se", "s1f", "4s1g4", "4s3h", "si4bl", "1sig", "s5int", "5sis", "5sit", "5siu", "s5ju", "4sk.", "1skab", "1ske", "s3kl", "sk5s4", "5sky", "s1le", "s1li", "slo3", "5slu", "s5ly", "s1m", "s4my", "4snin", "s4nit", "so5k", "5sol", "5som.", "3somm", "s5oms", "5somt", "3son", "4s1op", "sp4", "3spec", "4sper", "3s4pi", "s1pl", "3sprog.", "s5r4", "s1s4", "4st.", "5s4tam", "1stan", "st5as", "3stat", "1stav", "1ste.", "1sted", "3stel", "5stemo", "1sten", "5step", "3ster.", "3stes", "5stet", "5stj", "3sto", "st5om", "1str", "s1ud", "3sul", "s3un", "3sur", "s3ve", "3s4y", "1sy1s", "5ta.", "1tag", "tands3", "4tanv", "4tb", "tede4l", "teds5", "3teg", "5tekn", "teo1", "5term", "te5ro", "4t1f", "6t3g", "t1h", "tialis5t", "3tid", "ti4en", "ti3st", "4t3k", "4t1l", "tli4s5", "t1m", "t1n", "to5ra", "to1re", "to1ri", "tor4m", "4t3p", "t4ra", "4tres", "tro5v", "1try", "4ts", "t3si", "ts4pa", "ts5pr", "t3st", "ts5ul", "4t1t", "t5uds", "5tur", "t5ve", "1typ", "u1a", "5udl", "ud5r", "ud3s", "3udv", "u1e", "ue4t5", "uge4ri", "ugs3", "u5gu", "u3i", "u5kl", "uk4ta", "uk4tr", "u1la", "u1le", "u5ly", "u5pe", "up5l", "u5q", "u3ra", "u3re", "u4r3eg", "u1rer", "u3ro", "us5a", "u3si", "u5ska", "u5so", "us5v", "u1te", "u1ti", "u1to", "ut5r", "ut5s4", "5u5v", "va5d", "3varm", "1ved", "ve4l5e", "ve4reg", "ve3s", "5vet", "v5h", "vi4l3in", "1vis", "v5j", "v5k", "vl4", "v3le", "v5li", "vls1", "1vo", "4v5om", "v5p", "v5re", "v3st", "v5su", "v5t", "3vu", "y3a", "y5dr", "y3e", "y3ke", "y5ki", "yk3li", "y3ko", "yk4s5", "y3kv", "y5li", "y5lo", "y5mu", "yns5", "y5o", "y1pe", "y3pi", "y3re", "yr3ek", "y3ri", "y3si", "y3ti", "y5t3r", "y5ve", "zi5o", ".så3", ".ær5i", ".øv3r", "a3tø", "a5væ", "brød3", "5bæ", "5drøv", "dstå4", "3dæ", "3dø", "e3læ", "e3lø", "e3rø", "er5øn", "e5tæ", "e5tø", "e1væ", "e3æ", "e5å", "3fæ", "3fø", "fø4r5en", "giø4", "g4sø", "g5så", "3gæ", "3gø1", "3gå", "i5tæ", "i3ø", "3kø", "3kå", "lingeniø4", "l3væ", "5løs", "m5tå", "1mæ", "3mø", "3må", "n3kæ", "n5tæ", "3næ", "4n5æb", "5nø", "o5læ", "or3ø", "o5å", "5præ", "5pæd", "på3", "r5kæ", "r5tæ", "r5tø", "r3væ", "r5æl", "4røn", "5rør", "3råd", "r5år", "s4kå", "3slå", "s4næ", "5stø", "1stå", "1sæ", "4s5æn", "1sø", "s5øk", "så4r5", "ti4ø", "3træk.", "t4sø", "t5så", "t3væ", "u3læ", "3værd", "1værk", "5vå", "y5væ", "æb3l", "æ3c", "æ3e", "æg5a", "æ4gek", "æ4g5r", "ægs5", "æ5i", "æ5kv", "ælle4", "æn1dr", "æ5o", "æ1re", "ær4g5r", "æ3ri", "ær4ma", "ær4mo", "ær5s", "æ5si", "æ3so", "æ3ste", "æ3ve", "øde5", "ø3e", "ø1je", "ø3ke", "ø3le", "øms5", "øn3st", "øn4t3", "ø1re", "ø3ri", "ørne3", "ør5o", "ø1ve", "å1d", "å1e", "å5h", "å3l", "å3re", "års5t", "å5sk", "å3t", };
mit
anshkumar/yugioh-glaze
assets/script/c96015976.lua
5
2317
--再転 function c96015976.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c96015976.target1) e1:SetOperation(c96015976.operation) c:RegisterEffect(e1) -- local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(96015976,0)) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetRange(LOCATION_SZONE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCode(EVENT_FREE_CHAIN) e2:SetCost(c96015976.cost) e2:SetTarget(c96015976.target2) e2:SetOperation(c96015976.operation) c:RegisterEffect(e2) end function c96015976.target1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c96015976.filter(chkc) end if chk==0 then return true end if Duel.IsExistingTarget(c96015976.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) and Duel.SelectYesNo(tp,94) then e:SetProperty(EFFECT_FLAG_CARD_TARGET) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c96015976.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) e:GetHandler():RegisterFlagEffect(96015976,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) else e:SetProperty(0) end end function c96015976.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():GetFlagEffect(96015976)==0 end e:GetHandler():RegisterFlagEffect(96015976,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) end function c96015976.filter(c) local lv=c:GetLevel() return c:IsFaceup() and lv~=0 and lv~=c:GetOriginalLevel() end function c96015976.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c96015976.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c96015976.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c96015976.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) end function c96015976.operation(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():GetFlagEffect(96015976)==0 then return end local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and tc:IsFaceup() then local dc=Duel.TossDice(tp,1) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CHANGE_LEVEL) e1:SetValue(dc) e1:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e1) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c98891840.lua
3
1310
--休息する剣闘獣 function c98891840.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c98891840.target) e1:SetOperation(c98891840.activate) c:RegisterEffect(e1) end function c98891840.filter(c) return c:IsSetCard(0x19) and c:IsAbleToDeck() end function c98891840.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,3) and Duel.IsExistingMatchingCard(c98891840.filter,tp,LOCATION_HAND,0,2,e:GetHandler()) end Duel.SetTargetPlayer(tp) Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,2,tp,LOCATION_HAND) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,3) end function c98891840.activate(e,tp,eg,ep,ev,re,r,rp) local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) local g=Duel.GetMatchingGroup(c98891840.filter,p,LOCATION_HAND,0,nil) if g:GetCount()<2 then local hg=Duel.GetFieldGroup(p,LOCATION_HAND,0) Duel.ConfirmCards(1-p,hg) Duel.ShuffleHand(p) else Duel.Hint(HINT_SELECTMSG,p,HINTMSG_TODECK) local sg=g:Select(p,2,2,nil) Duel.ConfirmCards(1-p,sg) Duel.SendtoDeck(sg,nil,2,REASON_EFFECT) Duel.ShuffleDeck(p) Duel.BreakEffect() Duel.Draw(p,3,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c45082499.lua
3
2630
--ZW-雷神猛虎剣 function c45082499.initial_effect(c) c:SetUniqueOnField(1,0,45082499) --equip local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(45082499,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCategory(CATEGORY_EQUIP) e1:SetRange(LOCATION_HAND+LOCATION_MZONE) e1:SetCondition(c45082499.eqcon) e1:SetTarget(c45082499.eqtg) e1:SetOperation(c45082499.eqop) c:RegisterEffect(e1) -- local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e2:SetRange(LOCATION_SZONE) e2:SetTargetRange(LOCATION_ONFIELD,0) e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x7e)) e2:SetValue(c45082499.indval) c:RegisterEffect(e2) --destroy sub local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_EQUIP) e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e3:SetCode(EFFECT_DESTROY_SUBSTITUTE) e3:SetValue(c45082499.repval) c:RegisterEffect(e3) end function c45082499.eqcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():CheckUniqueOnField(tp) end function c45082499.filter(c) return c:IsFaceup() and c:IsSetCard(0x7f) end function c45082499.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c45082499.filter(chkc) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingTarget(c45082499.filter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) Duel.SelectTarget(tp,c45082499.filter,tp,LOCATION_MZONE,0,1,1,nil) end function c45082499.eqop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end if c:IsLocation(LOCATION_MZONE) and c:IsFacedown() then return end local tc=Duel.GetFirstTarget() if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 or tc:GetControler()~=tp or tc:IsFacedown() or not tc:IsRelateToEffect(e) or not c:CheckUniqueOnField(tp) then Duel.SendtoGrave(c,REASON_EFFECT) return end Duel.Equip(tp,c,tc,true) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EQUIP_LIMIT) e1:SetReset(RESET_EVENT+0x1fe0000) e1:SetValue(c45082499.eqlimit) e1:SetLabelObject(tc) c:RegisterEffect(e1) --atkup local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_EQUIP) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetValue(1200) e2:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e2) end function c45082499.eqlimit(e,c) return c==e:GetLabelObject() end function c45082499.indval(e,re,tp) return e:GetHandler():GetControler()~=tp end function c45082499.repval(e,re,r,rp) return bit.band(r,REASON_EFFECT)~=0 end
gpl-2.0
johnparker007/mame
3rdparty/bimg/scripts/bimg_encode.lua
7
1425
-- -- Copyright 2010-2019 Branimir Karadzic. All rights reserved. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause -- project "bimg_encode" kind "StaticLib" includedirs { path.join(BX_DIR, "include"), path.join(BIMG_DIR, "include"), path.join(BIMG_DIR, "3rdparty"), path.join(BIMG_DIR, "3rdparty/nvtt"), path.join(BIMG_DIR, "3rdparty/iqa/include"), } files { path.join(BIMG_DIR, "include/**"), path.join(BIMG_DIR, "src/image_encode.*"), path.join(BIMG_DIR, "src/image_cubemap_filter.*"), path.join(BIMG_DIR, "3rdparty/libsquish/**.cpp"), path.join(BIMG_DIR, "3rdparty/libsquish/**.h"), path.join(BIMG_DIR, "3rdparty/edtaa3/**.cpp"), path.join(BIMG_DIR, "3rdparty/edtaa3/**.h"), path.join(BIMG_DIR, "3rdparty/etc1/**.cpp"), path.join(BIMG_DIR, "3rdparty/etc1/**.h"), path.join(BIMG_DIR, "3rdparty/etc2/**.cpp"), path.join(BIMG_DIR, "3rdparty/etc2/**.hpp"), path.join(BIMG_DIR, "3rdparty/nvtt/**.cpp"), path.join(BIMG_DIR, "3rdparty/nvtt/**.h"), path.join(BIMG_DIR, "3rdparty/pvrtc/**.cpp"), path.join(BIMG_DIR, "3rdparty/pvrtc/**.h"), path.join(BIMG_DIR, "3rdparty/astc/**.cpp"), path.join(BIMG_DIR, "3rdparty/astc/**.h"), path.join(BIMG_DIR, "3rdparty/tinyexr/**.h"), path.join(BIMG_DIR, "3rdparty/iqa/include/**.h"), path.join(BIMG_DIR, "3rdparty/iqa/source/**.c"), } configuration { "linux-*" } buildoptions { "-fPIC", } configuration {}
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c55948544.lua
3
3544
--ファラオの審判 function c55948544.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(55948544,0)) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_DRAW_PHASE) e1:SetCondition(c55948544.condition1) e1:SetCost(c55948544.cost) e1:SetOperation(c55948544.operation1) c:RegisterEffect(e1) -- local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(55948544,1)) e2:SetType(EFFECT_TYPE_ACTIVATE) e2:SetCode(EVENT_FREE_CHAIN) e2:SetHintTiming(0,TIMING_DRAW_PHASE) e2:SetCondition(c55948544.condition2) e2:SetCost(c55948544.cost) e2:SetOperation(c55948544.operation2) c:RegisterEffect(e2) end function c55948544.condition1(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(Card.IsCode,tp,LOCATION_GRAVE,0,1,nil,81332143) end function c55948544.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription()) Duel.PayLPCost(tp,math.floor(Duel.GetLP(tp)/2)) end function c55948544.operation1(e,tp,eg,ep,ev,re,r,rp) if not Duel.IsExistingMatchingCard(Card.IsCode,tp,LOCATION_GRAVE,0,1,nil,81332143) then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetTargetRange(0,1) Duel.RegisterEffect(e1,tp) local e2=e1:Clone() e2:SetCode(EFFECT_CANNOT_SUMMON) Duel.RegisterEffect(e2,tp) local e3=e1:Clone() e3:SetCode(EFFECT_CANNOT_FLIP_SUMMON) Duel.RegisterEffect(e3,tp) local e4=e1:Clone() e4:SetCode(EFFECT_CANNOT_MSET) Duel.RegisterEffect(e4,tp) local e5=e1:Clone() e5:SetCode(EFFECT_CANNOT_TURN_SET) Duel.RegisterEffect(e5,tp) local e6=Effect.CreateEffect(e:GetHandler()) e6:SetType(EFFECT_TYPE_FIELD) e6:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e6:SetCode(EFFECT_CANNOT_ACTIVATE) e6:SetTargetRange(0,1) e6:SetValue(c55948544.aclimit1) e6:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e6,tp) end function c55948544.aclimit1(e,re,tp) return re:IsActiveType(TYPE_MONSTER) end function c55948544.condition2(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(Card.IsCode,tp,LOCATION_GRAVE,0,1,nil,14731897) end function c55948544.operation2(e,tp,eg,ep,ev,re,r,rp) if not Duel.IsExistingMatchingCard(Card.IsCode,tp,LOCATION_GRAVE,0,1,nil,14731897) then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SSET) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(0,1) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_FIELD) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetCode(EFFECT_CANNOT_ACTIVATE) e2:SetTargetRange(0,1) e2:SetValue(c55948544.aclimit2) e2:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e2,tp) local e3=Effect.CreateEffect(e:GetHandler()) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_DISABLE) e3:SetTargetRange(0,LOCATION_SZONE) e3:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e3,tp) local e4=Effect.CreateEffect(e:GetHandler()) e4:SetType(EFFECT_TYPE_FIELD) e4:SetCode(EFFECT_DISABLE_TRAPMONSTER) e4:SetTargetRange(0,LOCATION_MZONE) e4:SetTarget(c55948544.distg) e4:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e4,tp) end function c55948544.aclimit2(e,re,tp) return re:IsHasType(EFFECT_TYPE_ACTIVATE) end function c55948544.distg(e,c) return c:IsType(TYPE_TRAP) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c70595331.lua
3
1969
--地獄の門番イル・ブラッド function c70595331.initial_effect(c) aux.EnableDualAttribute(c) --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetDescription(aux.Stringid(70595331,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetCondition(aux.IsDualState) e1:SetTarget(c70595331.target) e1:SetOperation(c70595331.operation) c:RegisterEffect(e1) --destroy local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetOperation(c70595331.desop) c:RegisterEffect(e2) end function c70595331.filter(c,e,tp) return c:IsRace(RACE_ZOMBIE) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsHasEffect(EFFECT_NECRO_VALLEY) end function c70595331.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c70595331.filter,tp,LOCATION_GRAVE+LOCATION_HAND,LOCATION_GRAVE,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE+LOCATION_HAND) end function c70595331.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c70595331.filter,tp,LOCATION_GRAVE+LOCATION_HAND,LOCATION_GRAVE,1,1,nil,e,tp) local c=e:GetHandler() local tc=g:GetFirst() if tc then if Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)==0 then return end if c:IsFaceup() and c:IsRelateToEffect(e) then c:SetCardTarget(tc) end end end function c70595331.desfilter(c,rc) return rc:GetCardTarget():IsContains(c) and c:IsRace(RACE_ZOMBIE) end function c70595331.desop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:GetCardTargetCount()>0 then local dg=Duel.GetMatchingGroup(c70595331.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,c) Duel.Destroy(dg,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c9342162.lua
3
2441
--彼岸の悪鬼 ハロウハウンド function c9342162.initial_effect(c) --self destroy local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_SELF_DESTROY) e1:SetCondition(c9342162.sdcon) c:RegisterEffect(e1) --Special Summon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(9342162,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_HAND) e2:SetCountLimit(1,9342162) e2:SetCondition(c9342162.sscon) e2:SetTarget(c9342162.sstg) e2:SetOperation(c9342162.ssop) c:RegisterEffect(e2) --to grave local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(9342162,1)) e3:SetCategory(CATEGORY_TOGRAVE) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_TO_GRAVE) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetCountLimit(1,9342162) e3:SetTarget(c9342162.tgtg) e3:SetOperation(c9342162.tgop) c:RegisterEffect(e3) end function c9342162.sdfilter(c) return not c:IsFaceup() or not c:IsSetCard(0xb1) end function c9342162.sdcon(e) return Duel.IsExistingMatchingCard(c9342162.sdfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,1,nil) end function c9342162.filter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) end function c9342162.sscon(e,tp,eg,ep,ev,re,r,rp) return not Duel.IsExistingMatchingCard(c9342162.filter,tp,LOCATION_ONFIELD,0,1,nil) end function c9342162.sstg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c9342162.ssop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SpecialSummon(e:GetHandler(),0,tp,tp,false,false,POS_FACEUP) end end function c9342162.tgfilter(c) return c:IsSetCard(0xb1) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToGrave() end function c9342162.tgtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c9342162.tgfilter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK) end function c9342162.tgop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c9342162.tgfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoGrave(g,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c4335645.lua
3
1132
--ニュードリュア function c4335645.initial_effect(c) --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(4335645,0)) e1:SetCategory(CATEGORY_DESTROY) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_BATTLE_DESTROYED) e1:SetCondition(c4335645.condition) e1:SetTarget(c4335645.target) e1:SetOperation(c4335645.operation) c:RegisterEffect(e1) end function c4335645.condition(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE) end function c4335645.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsDestructable() end if chk==0 then return true end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c4335645.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end
gpl-2.0
dinodeck/rpg_dialog_script
dialog_runner/code/Storyboard.lua
10
2268
Storyboard = {mId ="storybaord"} Storyboard.__index = Storyboard function Storyboard:Create(stack, events, handIn) local this = { mStack = stack, mEvents = events, mStates = {}, mSubStack = StateStack:Create(), mPlayingSounds = {} } setmetatable(this, self) if handIn then local state = this.mStack:Pop() this:PushState("handin", state) end return this end function Storyboard:Enter() end function Storyboard:Exit() for k, v in pairs(self.mPlayingSounds) do Sound.Stop(v) end end function Storyboard:AddSound(name, id) assert(self.mPlayingSounds[name] == nil) self.mPlayingSounds[name] = id end function Storyboard:StopSound(name) local id = self.mPlayingSounds[name] self.mPlayingSounds[name] = nil Sound.Stop(id) end function Storyboard:Update(dt) self.mSubStack:Update(dt) if #self.mEvents == 0 then self.mStack:Pop() end local deleteIndex = nil for k, v in ipairs(self.mEvents) do if type(v) == "function" then self.mEvents[k] = v(self) v = self.mEvents[k] end v:Update(dt, self) if v:IsFinished() then deleteIndex = k break end if v:IsBlocking() then break end end if deleteIndex then table.remove(self.mEvents, deleteIndex) end end function Storyboard:Render(renderer) self.mSubStack:Render(renderer) --local debugText = string.format("Events Stack: %d", #self.mEvents) --renderer:DrawText2d(0, 0, debugText) end function Storyboard:HandleInput() end function Storyboard:PushState(id, state) -- push a State on the stack but keep a reference here. assert(self.mStates[id] == nil) self.mStates[id] = state self.mSubStack:Push(state) end function Storyboard:RemoveState(id) local state = self.mStates[id] self.mStates[id] = nil for i = #self.mSubStack.mStates, 1, -1 do local v = self.mSubStack.mStates[i] if v == state then table.remove(self.mSubStack.mStates, i) end end end
mit
BooM-amour/neweagle
plugins/linkpv.lua
66
30275
do local function check_member(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, '') end end end local function check_member_modadd(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, '') end end end local function automodadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member,{receiver=receiver, data=data, msg = msg}) end end local function check_member_modrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = nil save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group has been removed') end end end local function show_group_settingsmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local bots_protection = "Yes" if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] end local settings = data[tostring(target)]['settings'] local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection return text end local function set_descriptionmod(msg, data, target, about) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set group description to:\n'..about end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about return 'About '..about end local function lock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'yes' then return 'Arabic is already locked' else data[tostring(target)]['settings']['lock_arabic'] = 'yes' save_data(_config.moderation.data, data) return 'Arabic has been locked' end end local function unlock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'no' then return 'Arabic is already unlocked' else data[tostring(target)]['settings']['lock_arabic'] = 'no' save_data(_config.moderation.data, data) return 'Arabic has been unlocked' end end local function lock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'yes' then return 'Bots protection is already enabled' else data[tostring(target)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Bots protection has been enabled' end end local function unlock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'no' then return 'Bots protection is already disabled' else data[tostring(target)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Bots protection has been disabled' end end local function lock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Group name has been locked' end end local function unlock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end local function lock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Group flood is locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Group flood has been locked' end end local function unlock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Group flood is not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Group flood has been unlocked' end end local function lock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end local function unlock_group_photomod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function set_rulesmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end local function modadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then return 'Group is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg}) end local function modrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not data[tostring(msg.to.id)] then return 'Group is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg}) end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Chat rules:\n'..rules return rules end local function promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, '@'..member_username..' has been promoted.') end local function demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if not data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not a moderator.') end data[group]['moderators'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, '@'..member_username..' has been demoted.') end local function username_id(cb_extra, success, result) local mod_cmd = cb_extra.mod_cmd local receiver = cb_extra.receiver local member = cb_extra.member local text = 'No user @'..member..' in this group.' for k,v in pairs(result.members) do vusername = v.username if vusername == member then member_username = member member_id = v.id if mod_cmd == 'promote' then return promote(receiver, member_username, member_id) elseif mod_cmd == 'demote' then return demote(receiver, member_username, member_id) end end end send_large_msg(receiver, text) end local function modlist(msg) local data = load_data(_config.moderation.data) if not data[tostring(msg.to.id)] then return 'Group is not added.' end -- determine if table is empty if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do message = message ..i..' - @'..v..' [' ..k.. '] \n' i = i + 1 end return message end local function callbackres(extra, success, result) local user = result.id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function help() local help_text = tostring(_config.help_text) return help_text end local function cleanmember(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name if success == -1 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end for k,v in pairs(result.members) do kick_user(v.id, result.id) end end local function run(msg, matches) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) local name_log = user_print_name(msg.from) local group = msg.to.id if msg.media then if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then load_photo(msg.id, set_group_photo, msg) end end if matches[1] == 'add' then print("group "..msg.to.print_name.."("..msg.to.id..") added") return modadd(msg) end if matches[1] == 'rem' then print("group "..msg.to.print_name.."("..msg.to.id..") removed") return modrem(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 then return automodadd(msg) end if msg.to.id and data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local group_member_lock = settings.lock_member local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then chat_del_user(chat, user, ok_cb, true) elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then return nil elseif group_member_lock == 'no' then return nil end end if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local receiver = 'user#id'..msg.action.user.id local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return false end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Welcome to "' .. string.gsub(msg.to.print_name, '_', ' ') ..'" this group has rules that you should follow:\n'..rules savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..msg.action.user.id) send_large_msg(receiver, rules) end if matches[1] == 'chat_del_user' then if not msg.service then return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user) end if matches[1] == 'chat_delete_photo' then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_rename' then if not msg.service then return "Are you trying to troll me?" end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:incr(namehash) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id local nameprotectionredis = redis:get(namehash) if nameprotectionredis then if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:set(namehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ") rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end if matches[1] == 'setname' and is_momod(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send me new group photo now' end if matches[1] == 'promote' and matches[2] then if not is_owner(msg) then return "Only owner can promote" end local member = string.gsub(matches[2], "@", "") local mod_cmd = 'promote' savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member) chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end if matches[1] == 'demote' and matches[2] then if not is_owner(msg) then return "Only owner can demote" end if string.gsub(matches[2], "@", "") == msg.from.username then return "You can't demote yourself" end local member = string.gsub(matches[2], "@", "") local mod_cmd = 'demote' savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member) chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end if matches[1] == 'modlist' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") return modlist(msg) end if matches[1] == 'about' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description") return get_description(msg, data) end if matches[1] == 'rules' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules") return get_rules(msg, data) end if matches[1] == 'set' then if matches[2] == 'rules' then rules = matches[3] local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]") return set_rulesmod(msg, data, target) end if matches[2] == 'about' then local data = load_data(_config.moderation.data) local target = msg.to.id local about = matches[3] savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]") return set_descriptionmod(msg, data, target, about) end end if matches[1] == 'lock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ") return lock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") return lock_group_membermod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") return lock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") return lock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ") return lock_group_bots(msg, data, target) end end if matches[1] == 'unlock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ") return unlock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") return unlock_group_membermod(msg, data, target) end if matches[2] == 'photo' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ") return unlock_group_photomod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ") return unlock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ") return unlock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ") return unlock_group_bots(msg, data, target) end end if matches[1] == 'settings' then local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ") return show_group_settingsmod(msg, data, target) end if matches[1] == 'newlink' then if not is_momod(msg) then return "For moderators only!" end local function callback (extra , success, result) local receiver = 'chat#'..msg.to.id if success == 0 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end send_large_msg(receiver, "Created a new link") data[tostring(msg.to.id)]['settings']['set_link'] = result save_data(_config.moderation.data, data) end local receiver = 'chat#'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ") return export_chat_link(receiver, callback, true) end if matches[1] == 'linkpv' then if not is_momod(msg) then return "For moderators only!" end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Create a link using /newlink first !" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") send_large_msg('user#id'..msg.from.id, 'Group link for ('..string.gsub(msg.to.print_name, "_", " ")..'):\n'..group_link) end if matches[1] == 'setowner' then if not is_owner(msg) then return "For owner only!" end data[tostring(msg.to.id)]['set_owner'] = matches[2] save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner") local text = matches[2].." added as owner" return text end if matches[1] == 'owner' then local group_owner = data[tostring(msg.to.id)]['set_owner'] if not group_owner then return "no owner,ask admins in support groups to set owner for your group" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") return "Group owner is ["..group_owner..']' end if matches[1] == 'setgpowner' then local receiver = "chat#id"..matches[2] if not is_admin(msg) then return "For admins only!" end data[tostring(matches[2])]['set_owner'] = matches[3] save_data(_config.moderation.data, data) local text = matches[3].." added as owner" send_large_msg(receiver, text) return end if matches[1] == 'setflood' then if not is_momod(msg) then return "For moderators only!" end if tonumber(matches[2]) < 2 or tonumber(matches[2]) > 50 then return "Wrong number,range is [2-50]" end local flood_max = matches[2] data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") return 'Group flood has been set to '..matches[2] end if matches[1] == 'clean' then if not is_owner(msg) then return "Only owner can clean" end if matches[2] == 'member' then if not is_owner(msg) then return "Only admins can clean members" end local receiver = get_receiver(msg) chat_info(receiver, cleanmember, {receiver=receiver}) end if matches[2] == 'modlist' then if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil save_data(_config.moderation.data, data) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") end if matches[2] == 'rules' then local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") end if matches[2] == 'about' then local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") end end if matches[1] == 'help' then if not is_momod(msg) then return end savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'res' and is_momod(msg) then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) return res_user(username, callbackres, cbres_extra) end end end return { usage = { "linkpv: Send Link In Private Chat.", }, patterns = { "^([Ll]inkpv)$", "%[(photo)%]", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
RockySeven3161/UB
plugins/qr.lua
637
1730
--[[ * qr plugin uses: * - http://goqr.me/api/doc/create-qr-code/ * psykomantis ]] local function get_hex(str) local colors = { red = "f00", blue = "00f", green = "0f0", yellow = "ff0", purple = "f0f", white = "fff", black = "000", gray = "ccc" } for color, value in pairs(colors) do if color == str then return value end end return str end local function qr(receiver, text, color, bgcolor) local url = "http://api.qrserver.com/v1/create-qr-code/?" .."size=600x600" --fixed size otherways it's low detailed .."&data="..URL.escape(text:trim()) if color then url = url.."&color="..get_hex(color) end if bgcolor then url = url.."&bgcolor="..get_hex(bgcolor) end local response, code, headers = http.request(url) if code ~= 200 then return "Oops! Error: " .. code end if #response > 0 then send_photo_from_url(receiver, url) return end return "Oops! Something strange happened :(" end local function run(msg, matches) local receiver = get_receiver(msg) local text = matches[1] local color local back if #matches > 1 then text = matches[3] color = matches[2] back = matches[1] end return qr(receiver, text, color, back) end return { description = {"qr code plugin for telegram, given a text it returns the qr code"}, usage = { "!qr [text]", '!qr "[background color]" "[data color]" [text]\n' .."Color through text: red|green|blue|purple|black|white|gray\n" .."Colors through hex notation: (\"a56729\" is brown)\n" .."Or colors through decimals: (\"255-192-203\" is pink)" }, patterns = { '^!qr "(%w+)" "(%w+)" (.+)$', "^!qr (.+)$" }, run = run }
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c75797046.lua
3
1625
--フォトン・アレキサンドラ・クイーン function c75797046.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsSetCard,0x6a),4,2) c:EnableReviveLimit() --return local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(75797046,0)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_DAMAGE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCost(c75797046.retcost) e1:SetTarget(c75797046.rettg) e1:SetOperation(c75797046.retop) c:RegisterEffect(e1) end function c75797046.retcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c75797046.rettg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToHand,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end local g=Duel.GetMatchingGroup(Card.IsAbleToHand,tp,LOCATION_MZONE,LOCATION_MZONE,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,PLAYER_ALL,0) end function c75797046.hfilter(c,tp) return c:IsLocation(LOCATION_HAND) and c:IsControler(tp) end function c75797046.retop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsAbleToHand,tp,LOCATION_MZONE,LOCATION_MZONE,nil) if g:GetCount()==0 then return end Duel.SendtoHand(g,nil,REASON_EFFECT) local ct1=g:FilterCount(c75797046.hfilter,nil,tp) local ct2=g:FilterCount(c75797046.hfilter,nil,1-tp) Duel.Damage(tp,ct1*300,REASON_EFFECT) Duel.Damage(1-tp,ct2*300,REASON_EFFECT) end
gpl-2.0
zhaoxin54430/zhaoxin_test
src_luci/applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua
78
1663
-- Copyright 2008 Steven Barth <steven@midlink.org> -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org> -- Copyright 2010 Manuel Munz <freifunk@somakoma.de> -- Licensed to the public under the Apache License 2.0. local fs = require "nixio.fs" local splashtextfile = "/usr/lib/luci-splash/splashtext.html" local splashtextinclude = "/usr/lib/luci-splash/splashtextinclude.html" f = SimpleForm("splashtext", translate("Edit the complete splash text"), translate("You can enter your own text that is displayed to clients here.<br />" .. "It is possible to use the following markers: " .. "###COMMUNITY###, ###COMMUNITY_URL###, ###CONTACTURL###, ###LEASETIME###, ###LIMIT### and ###ACCEPT###.")) t = f:field(TextValue, "text") t.rmempty = true t.rows = 30 function t.cfgvalue() return fs.readfile(splashtextfile) or "" end function f.handle(self, state, data) if state == FORM_VALID then if data.text then fs.writefile(splashtextfile, data.text:gsub("\r\n", "\n")) else fs.unlink(splashtextfile) end end return true end g = SimpleForm("splashtextinclude", translate("Include your own text in the default splash"), translate("As an alternative to editing the complete splash text you can also just include some custom text in the default splash page by entering it here.")) t = g:field(TextValue, "text") t.rmempty = true t.rows = 30 function t.cfgvalue() return fs.readfile(splashtextinclude) or "" end function g.handle(self, state, data) if state == FORM_VALID then if data.text then fs.writefile(splashtextinclude, data.text:gsub("\r\n", "\n")) else fs.unlink(splashtextinclude) end end return true end return f, g
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c46759931.lua
3
1246
--V・HERO トリニティー function c46759931.initial_effect(c) --fusion material c:EnableReviveLimit() aux.AddFusionProcFunRep(c,aux.FilterBoolFunction(Card.IsSetCard,0x8),3,true) --summon success local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(c46759931.regcon) e1:SetOperation(c46759931.regop) c:RegisterEffect(e1) --extra attack local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_EXTRA_ATTACK) e2:SetCondition(c46759931.atkcon) e2:SetValue(2) c:RegisterEffect(e2) --cannot diratk local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_CANNOT_DIRECT_ATTACK) c:RegisterEffect(e3) end function c46759931.regcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_FUSION end function c46759931.regop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SET_ATTACK) e1:SetReset(RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END) e1:SetValue(c:GetBaseAttack()*2) c:RegisterEffect(e1) end function c46759931.atkcon(e) return e:GetHandler():GetSummonType()==SUMMON_TYPE_FUSION end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c33823832.lua
3
2484
--EMファイア・マフライオ function c33823832.initial_effect(c) --pendulum summon aux.AddPendulumProcedure(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(33823832,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_BATTLE_DESTROYED) e2:SetRange(LOCATION_PZONE) e2:SetCondition(c33823832.spcon) e2:SetTarget(c33823832.sptg) e2:SetOperation(c33823832.spop) c:RegisterEffect(e2) --chain attack local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(33823832,1)) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_BATTLED) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1) e3:SetCondition(c33823832.cacon) e3:SetOperation(c33823832.caop) c:RegisterEffect(e3) end function c33823832.cfilter(c,tp) return c:IsType(TYPE_PENDULUM) and c:IsPreviousLocation(LOCATION_MZONE) and c:GetPreviousControler()==tp end function c33823832.spcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(c33823832.cfilter,1,nil,tp) end function c33823832.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c33823832.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end function c33823832.cacon(e,tp,eg,ep,ev,re,r,rp) local a=Duel.GetAttacker() local d=Duel.GetAttackTarget() if not d then return false end if a:IsStatus(STATUS_OPPO_BATTLE) and d:IsControler(tp) then a,d=d,a end if a:IsType(TYPE_PENDULUM) and not a:IsStatus(STATUS_BATTLE_DESTROYED) and d:IsStatus(STATUS_BATTLE_DESTROYED) then e:SetLabelObject(a) return true else return false end end function c33823832.caop(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetLabelObject() if tc:IsFaceup() and tc:IsControler(tp) and tc:IsRelateToBattle() then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetValue(200) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_BATTLE) tc:RegisterEffect(e1) if tc:IsChainAttackable() then Duel.ChainAttack() end end end
gpl-2.0
sjznxd/lc-20130302
applications/luci-diag-devinfo/luasrc/controller/luci_diag/devinfo_common.lua
76
5638
--[[ Luci diag - Diagnostics controller module (c) 2009 Daniel Dickinson Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]]-- module("luci.controller.luci_diag.devinfo_common", package.seeall) require("luci.i18n") require("luci.util") require("luci.sys") require("luci.cbi") require("luci.model.uci") local translate = luci.i18n.translate local DummyValue = luci.cbi.DummyValue local SimpleSection = luci.cbi.SimpleSection function index() return -- no-op end function run_processes(outnets, cmdfunc) i = next(outnets, nil) while (i) do outnets[i]["output"] = luci.sys.exec(cmdfunc(outnets, i)) i = next(outnets, i) end end function parse_output(devmap, outnets, haslink, type, mini, debug) local curnet = next(outnets, nil) while (curnet) do local output = outnets[curnet]["output"] local subnet = outnets[curnet]["subnet"] local ports = outnets[curnet]["ports"] local interface = outnets[curnet]["interface"] local netdevs = {} devlines = luci.util.split(output) if not devlines then devlines = {} table.insert(devlines, output) end local j = nil j = next(devlines, j) local found_a_device = false while (j) do if devlines[j] and ( devlines[j] ~= "" ) then found_a_device = true local devtable local row = {} devtable = luci.util.split(devlines[j], ' | ') row["ip"] = devtable[1] if (not mini) then row["mac"] = devtable[2] end if ( devtable[4] == 'unknown' ) then row["vendor"] = devtable[3] else row["vendor"] = devtable[4] end row["type"] = devtable[5] if (not mini) then row["model"] = devtable[6] end if (haslink) then row["config_page"] = devtable[7] end if (debug) then row["raw"] = devlines[j] end table.insert(netdevs, row) end j = next(devlines, j) end if not found_a_device then local row = {} row["ip"] = curnet if (not mini) then row["mac"] = "" end if (type == "smap") then row["vendor"] = luci.i18n.translate("No SIP devices") else row["vendor"] = luci.i18n.translate("No devices detected") end row["type"] = luci.i18n.translate("check other networks") if (not mini) then row["model"] = "" end if (haslink) then row["config_page"] = "" end if (debug) then row["raw"] = output end table.insert(netdevs, row) end local s if (type == "smap") then if (mini) then s = devmap:section(luci.cbi.Table, netdevs, luci.i18n.translate("SIP devices discovered for") .. " " .. curnet) else local interfacestring = "" if ( interface ~= "" ) then interfacestring = ", " .. interface end s = devmap:section(luci.cbi.Table, netdevs, luci.i18n.translate("SIP devices discovered for") .. " " .. curnet .. " (" .. subnet .. ":" .. ports .. interfacestring .. ")") end s.template = "diag/smapsection" else if (mini) then s = devmap:section(luci.cbi.Table, netdevs, luci.i18n.translate("Devices discovered for") .. " " .. curnet) else local interfacestring = "" if ( interface ~= "" ) then interfacestring = ", " .. interface end s = devmap:section(luci.cbi.Table, netdevs, luci.i18n.translate("Devices discovered for") .. " " .. curnet .. " (" .. subnet .. interfacestring .. ")") end end s:option(DummyValue, "ip", translate("IP Address")) if (not mini) then s:option(DummyValue, "mac", translate("MAC Address")) end s:option(DummyValue, "vendor", translate("Vendor")) s:option(DummyValue, "type", translate("Device Type")) if (not mini) then s:option(DummyValue, "model", translate("Model")) end if (haslink) then s:option(DummyValue, "config_page", translate("Link to Device")) end if (debug) then s:option(DummyValue, "raw", translate("Raw")) end curnet = next(outnets, curnet) end end function get_network_device(interface) local state = luci.model.uci.cursor_state() state:load("network") local dev return state:get("network", interface, "ifname") end function cbi_add_networks(field) uci.cursor():foreach("network", "interface", function (section) if section[".name"] ~= "loopback" then field:value(section[".name"]) end end ) field.titleref = luci.dispatcher.build_url("admin", "network", "network") end function config_devinfo_scan(map, scannet) local o o = scannet:option(luci.cbi.Flag, "enable", translate("Enable")) o.optional = false o.rmempty = false o = scannet:option(luci.cbi.Value, "interface", translate("Interface")) o.optional = false luci.controller.luci_diag.devinfo_common.cbi_add_networks(o) local scansubnet scansubnet = scannet:option(luci.cbi.Value, "subnet", translate("Subnet")) scansubnet.optional = false o = scannet:option(luci.cbi.Value, "timeout", translate("Timeout"), translate("Time to wait for responses in seconds (default 10)")) o.optional = true o = scannet:option(luci.cbi.Value, "repeat_count", translate("Repeat Count"), translate("Number of times to send requests (default 1)")) o.optional = true o = scannet:option(luci.cbi.Value, "sleepreq", translate("Sleep Between Requests"), translate("Milliseconds to sleep between requests (default 100)")) o.optional = true end
apache-2.0
anshkumar/yugioh-glaze
assets/script/c11508758.lua
3
1541
--ミュータント・ハイブレイン function c11508758.initial_effect(c) --control local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(11508758,0)) e1:SetCategory(CATEGORY_CONTROL) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_ATTACK_ANNOUNCE) e1:SetCondition(c11508758.ctlcon) e1:SetTarget(c11508758.ctltg) e1:SetOperation(c11508758.ctlop) c:RegisterEffect(e1) end function c11508758.ctlcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetAttackTarget()~=nil end function c11508758.filter(c) return c:IsPosition(POS_FACEUP_ATTACK) and c:IsControlerCanBeChanged() end function c11508758.ctltg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and chkc~=Duel.GetAttackTarget() and c11508758.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c11508758.filter,tp,0,LOCATION_MZONE,1,Duel.GetAttackTarget()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONTROL) local g=Duel.SelectTarget(tp,c11508758.filter,tp,0,LOCATION_MZONE,1,1,Duel.GetAttackTarget()) Duel.SetOperationInfo(0,CATEGORY_CONTROL,g,1,0,0) end function c11508758.ctlop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) and tc:IsFaceup() then if not Duel.GetControl(tc,tp,PHASE_BATTLE,1) then if not tc:IsImmuneToEffect(e) and tc:IsAbleToChangeControler() then Duel.Destroy(tc,REASON_EFFECT) end else if tc:IsAttackPos() then Duel.ChangeAttacker(tc) end end end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c3536537.lua
3
1379
--ヴェルズ・ザッハーク function c3536537.initial_effect(c) --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(3536537,0)) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_TO_GRAVE) e1:SetCondition(c3536537.descon) e1:SetTarget(c3536537.destg) e1:SetOperation(c3536537.desop) c:RegisterEffect(e1) end function c3536537.descon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return rp~=tp and c:GetPreviousControler()==tp and bit.band(r,REASON_DESTROY)~=0 and c:IsPreviousLocation(LOCATION_ONFIELD) and c:IsPreviousPosition(POS_FACEUP) end function c3536537.filter(c) return c:IsFaceup() and c:IsLevelAbove(5) and bit.band(c:GetSummonType(),SUMMON_TYPE_SPECIAL)~=0 and c:IsDestructable() end function c3536537.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c3536537.filter(chkc) end if chk==0 then return true end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,c3536537.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c3536537.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsFaceup() and tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end
gpl-2.0
qamrhom/wawi.alnajaf
plugin/stats.lua
15
4017
do -- Returns a table with `name` and `msgs` local function get_msgs_user_chat(user_id, chat_id) local user_info = {} local uhash = 'user:'..user_id local user = redis:hgetall(uhash) local um_hash = 'msgs:'..user_id..':'..chat_id user_info.msgs = tonumber(redis:get(um_hash) or 0) user_info.name = user_print_name(user)..' ['..user_id..']' return user_info end local function chat_stats(receiver, chat_id) -- Users on chat local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) local users_info = {} -- Get user info for i = 1, #users do local user_id = users[i] local user_info = get_msgs_user_chat(user_id, chat_id) table.insert(users_info, user_info) end -- Sort users by msgs number table.sort(users_info, function(a, b) if a.msgs and b.msgs then return a.msgs > b.msgs end end) local text = 'Users in this chat \n' for k,user in pairs(users_info) do text = text..user.name..' = '..user.msgs..'\n' end local file = io.open("./groups/lists/"..chat_id.."stats.txt", "w") file:write(text) file:flush() file:close() send_document(receiver,"./groups/lists/"..chat_id.."stats.txt", ok_cb, false) return --text end local function chat_stats2(chat_id) -- Users on chat local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) local users_info = {} -- Get user info for i = 1, #users do local user_id = users[i] local user_info = get_msgs_user_chat(user_id, chat_id) table.insert(users_info, user_info) end -- Sort users by msgs number table.sort(users_info, function(a, b) if a.msgs and b.msgs then return a.msgs > b.msgs end end) local text = 'Users in this chat \n' for k,user in pairs(users_info) do text = text..user.name..' = '..user.msgs..'\n' end return text end -- Save stats, ban user local function bot_stats() local redis_scan = [[ local cursor = '0' local count = 0 repeat local r = redis.call("SCAN", cursor, "MATCH", KEYS[1]) cursor = r[1] count = count + #r[2] until cursor == '0' return count]] -- Users local hash = 'msgs:*:'..our_id local r = redis:eval(redis_scan, 1, hash) local text = 'Users: '..r hash = 'chat:*:users' r = redis:eval(redis_scan, 1, hash) text = text..'\nGroups: '..r return text end local function run(msg, matches) if matches[1]:lower() == 'devpoint' then -- Put everything you like :) local about = _config.about_text local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] used /devpoint ") return about end if matches[1]:lower() == "statslist" then if not is_momod(msg) then return "For mods only !" end local chat_id = msg.to.id local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ") return chat_stats2(chat_id) end if matches[1]:lower() == "stats" then if not matches[2] then if not is_momod(msg) then return "For mods only !" end if msg.to.type == 'chat' or msg.to.type == 'channel' then local receiver = get_receiver(msg) local chat_id = msg.to.id local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested group stats ") return chat_stats(receiver, chat_id) else return end end if matches[2] == "devpoint" then -- Put everything you like :) if not is_admin1(msg) then return "For admins only !" else return bot_stats() end end if matches[2] == "group" then if not is_admin1(msg) then return "For admins only !" else return chat_stats(matches[3]) end end end end return { patterns = { "^[#!/]([Ss]tats)$", "^[#!/]([Ss]tatslist)$", "^[#!/]([Ss]tats) (group) (%d+)", "^[#!/]([Ss]tats) (devpoint)", "^[#!/]([Dd]evpoint)" }, run = run } end
gpl-3.0
svaarala/duktape
tests/perf/test-string-garbage.lua
7
1632
local function test() local s = 'x' local t for i=1,5e5 do t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y'; t = s .. 'y' end end test()
mit
zhaoxin54430/zhaoxin_test
src_luci/modules/luci-base/luasrc/sys/zoneinfo/tzdata.lua
14
17148
-- Licensed to the public under the Apache License 2.0. module "luci.sys.zoneinfo.tzdata" TZ = { { 'Africa/Abidjan', 'GMT0' }, { 'Africa/Accra', 'GMT0' }, { 'Africa/Addis Ababa', 'EAT-3' }, { 'Africa/Algiers', 'CET-1' }, { 'Africa/Asmara', 'EAT-3' }, { 'Africa/Bamako', 'GMT0' }, { 'Africa/Bangui', 'WAT-1' }, { 'Africa/Banjul', 'GMT0' }, { 'Africa/Bissau', 'GMT0' }, { 'Africa/Blantyre', 'CAT-2' }, { 'Africa/Brazzaville', 'WAT-1' }, { 'Africa/Bujumbura', 'CAT-2' }, { 'Africa/Cairo', 'EET-2' }, { 'Africa/Casablanca', 'WET0WEST,M3.5.0,M10.5.0/3' }, { 'Africa/Ceuta', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Africa/Conakry', 'GMT0' }, { 'Africa/Dakar', 'GMT0' }, { 'Africa/Dar es Salaam', 'EAT-3' }, { 'Africa/Djibouti', 'EAT-3' }, { 'Africa/Douala', 'WAT-1' }, { 'Africa/El Aaiun', 'WET0WEST,M3.5.0,M10.5.0/3' }, { 'Africa/Freetown', 'GMT0' }, { 'Africa/Gaborone', 'CAT-2' }, { 'Africa/Harare', 'CAT-2' }, { 'Africa/Johannesburg', 'SAST-2' }, { 'Africa/Juba', 'EAT-3' }, { 'Africa/Kampala', 'EAT-3' }, { 'Africa/Khartoum', 'EAT-3' }, { 'Africa/Kigali', 'CAT-2' }, { 'Africa/Kinshasa', 'WAT-1' }, { 'Africa/Lagos', 'WAT-1' }, { 'Africa/Libreville', 'WAT-1' }, { 'Africa/Lome', 'GMT0' }, { 'Africa/Luanda', 'WAT-1' }, { 'Africa/Lubumbashi', 'CAT-2' }, { 'Africa/Lusaka', 'CAT-2' }, { 'Africa/Malabo', 'WAT-1' }, { 'Africa/Maputo', 'CAT-2' }, { 'Africa/Maseru', 'SAST-2' }, { 'Africa/Mbabane', 'SAST-2' }, { 'Africa/Mogadishu', 'EAT-3' }, { 'Africa/Monrovia', 'GMT0' }, { 'Africa/Nairobi', 'EAT-3' }, { 'Africa/Ndjamena', 'WAT-1' }, { 'Africa/Niamey', 'WAT-1' }, { 'Africa/Nouakchott', 'GMT0' }, { 'Africa/Ouagadougou', 'GMT0' }, { 'Africa/Porto-Novo', 'WAT-1' }, { 'Africa/Sao Tome', 'GMT0' }, { 'Africa/Tripoli', 'EET-2' }, { 'Africa/Tunis', 'CET-1' }, { 'Africa/Windhoek', 'WAT-1WAST,M9.1.0,M4.1.0' }, { 'America/Adak', 'HST10HDT,M3.2.0,M11.1.0' }, { 'America/Anchorage', 'AKST9AKDT,M3.2.0,M11.1.0' }, { 'America/Anguilla', 'AST4' }, { 'America/Antigua', 'AST4' }, { 'America/Araguaina', 'BRT3' }, { 'America/Argentina/Buenos Aires', 'ART3' }, { 'America/Argentina/Catamarca', 'ART3' }, { 'America/Argentina/Cordoba', 'ART3' }, { 'America/Argentina/Jujuy', 'ART3' }, { 'America/Argentina/La Rioja', 'ART3' }, { 'America/Argentina/Mendoza', 'ART3' }, { 'America/Argentina/Rio Gallegos', 'ART3' }, { 'America/Argentina/Salta', 'ART3' }, { 'America/Argentina/San Juan', 'ART3' }, { 'America/Argentina/San Luis', 'ART3' }, { 'America/Argentina/Tucuman', 'ART3' }, { 'America/Argentina/Ushuaia', 'ART3' }, { 'America/Aruba', 'AST4' }, { 'America/Asuncion', 'PYT4PYST,M10.1.0/0,M3.4.0/0' }, { 'America/Atikokan', 'EST5' }, { 'America/Bahia', 'BRT3' }, { 'America/Bahia Banderas', 'CST6CDT,M4.1.0,M10.5.0' }, { 'America/Barbados', 'AST4' }, { 'America/Belem', 'BRT3' }, { 'America/Belize', 'CST6' }, { 'America/Blanc-Sablon', 'AST4' }, { 'America/Boa Vista', 'AMT4' }, { 'America/Bogota', 'COT5' }, { 'America/Boise', 'MST7MDT,M3.2.0,M11.1.0' }, { 'America/Cambridge Bay', 'MST7MDT,M3.2.0,M11.1.0' }, { 'America/Campo Grande', 'AMT4AMST,M10.3.0/0,M2.3.0/0' }, { 'America/Cancun', 'EST5' }, { 'America/Caracas', 'VET4:30' }, { 'America/Cayenne', 'GFT3' }, { 'America/Cayman', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Chicago', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Chihuahua', 'MST7MDT,M4.1.0,M10.5.0' }, { 'America/Costa Rica', 'CST6' }, { 'America/Creston', 'MST7' }, { 'America/Cuiaba', 'AMT4AMST,M10.3.0/0,M2.3.0/0' }, { 'America/Curacao', 'AST4' }, { 'America/Danmarkshavn', 'GMT0' }, { 'America/Dawson', 'PST8PDT,M3.2.0,M11.1.0' }, { 'America/Dawson Creek', 'MST7' }, { 'America/Denver', 'MST7MDT,M3.2.0,M11.1.0' }, { 'America/Detroit', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Dominica', 'AST4' }, { 'America/Edmonton', 'MST7MDT,M3.2.0,M11.1.0' }, { 'America/Eirunepe', 'ACT5' }, { 'America/El Salvador', 'CST6' }, { 'America/Fort Nelson', 'MST7' }, { 'America/Fortaleza', 'BRT3' }, { 'America/Glace Bay', 'AST4ADT,M3.2.0,M11.1.0' }, { 'America/Godthab', 'WGT3WGST,M3.5.0/-2,M10.5.0/-1' }, { 'America/Goose Bay', 'AST4ADT,M3.2.0,M11.1.0' }, { 'America/Grand Turk', 'AST4' }, { 'America/Grenada', 'AST4' }, { 'America/Guadeloupe', 'AST4' }, { 'America/Guatemala', 'CST6' }, { 'America/Guayaquil', 'ECT5' }, { 'America/Guyana', 'GYT4' }, { 'America/Halifax', 'AST4ADT,M3.2.0,M11.1.0' }, { 'America/Havana', 'CST5CDT,M3.2.0/0,M11.1.0/1' }, { 'America/Hermosillo', 'MST7' }, { 'America/Indiana/Indianapolis', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Indiana/Knox', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Indiana/Marengo', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Indiana/Petersburg', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Indiana/Tell City', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Indiana/Vevay', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Indiana/Vincennes', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Indiana/Winamac', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Inuvik', 'MST7MDT,M3.2.0,M11.1.0' }, { 'America/Iqaluit', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Jamaica', 'EST5' }, { 'America/Juneau', 'AKST9AKDT,M3.2.0,M11.1.0' }, { 'America/Kentucky/Louisville', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Kentucky/Monticello', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Kralendijk', 'AST4' }, { 'America/La Paz', 'BOT4' }, { 'America/Lima', 'PET5' }, { 'America/Los Angeles', 'PST8PDT,M3.2.0,M11.1.0' }, { 'America/Lower Princes', 'AST4' }, { 'America/Maceio', 'BRT3' }, { 'America/Managua', 'CST6' }, { 'America/Manaus', 'AMT4' }, { 'America/Marigot', 'AST4' }, { 'America/Martinique', 'AST4' }, { 'America/Matamoros', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Mazatlan', 'MST7MDT,M4.1.0,M10.5.0' }, { 'America/Menominee', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Merida', 'CST6CDT,M4.1.0,M10.5.0' }, { 'America/Metlakatla', 'PST8' }, { 'America/Mexico City', 'CST6CDT,M4.1.0,M10.5.0' }, { 'America/Miquelon', 'PMST3PMDT,M3.2.0,M11.1.0' }, { 'America/Moncton', 'AST4ADT,M3.2.0,M11.1.0' }, { 'America/Monterrey', 'CST6CDT,M4.1.0,M10.5.0' }, { 'America/Montevideo', 'UYT3' }, { 'America/Montserrat', 'AST4' }, { 'America/Nassau', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/New York', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Nipigon', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Nome', 'AKST9AKDT,M3.2.0,M11.1.0' }, { 'America/Noronha', 'FNT2' }, { 'America/North Dakota/Beulah', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/North Dakota/Center', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/North Dakota/New Salem', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Ojinaga', 'MST7MDT,M3.2.0,M11.1.0' }, { 'America/Panama', 'EST5' }, { 'America/Pangnirtung', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Paramaribo', 'SRT3' }, { 'America/Phoenix', 'MST7' }, { 'America/Port of Spain', 'AST4' }, { 'America/Port-au-Prince', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Porto Velho', 'AMT4' }, { 'America/Puerto Rico', 'AST4' }, { 'America/Rainy River', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Rankin Inlet', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Recife', 'BRT3' }, { 'America/Regina', 'CST6' }, { 'America/Resolute', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Rio Branco', 'ACT5' }, { 'America/Santa Isabel', 'PST8PDT,M4.1.0,M10.5.0' }, { 'America/Santarem', 'BRT3' }, { 'America/Santiago', 'CLT3' }, { 'America/Santo Domingo', 'AST4' }, { 'America/Sao Paulo', 'BRT3BRST,M10.3.0/0,M2.3.0/0' }, { 'America/Scoresbysund', 'EGT1EGST,M3.5.0/0,M10.5.0/1' }, { 'America/Sitka', 'AKST9AKDT,M3.2.0,M11.1.0' }, { 'America/St Barthelemy', 'AST4' }, { 'America/St Johns', 'NST3:30NDT,M3.2.0,M11.1.0' }, { 'America/St Kitts', 'AST4' }, { 'America/St Lucia', 'AST4' }, { 'America/St Thomas', 'AST4' }, { 'America/St Vincent', 'AST4' }, { 'America/Swift Current', 'CST6' }, { 'America/Tegucigalpa', 'CST6' }, { 'America/Thule', 'AST4ADT,M3.2.0,M11.1.0' }, { 'America/Thunder Bay', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Tijuana', 'PST8PDT,M3.2.0,M11.1.0' }, { 'America/Toronto', 'EST5EDT,M3.2.0,M11.1.0' }, { 'America/Tortola', 'AST4' }, { 'America/Vancouver', 'PST8PDT,M3.2.0,M11.1.0' }, { 'America/Whitehorse', 'PST8PDT,M3.2.0,M11.1.0' }, { 'America/Winnipeg', 'CST6CDT,M3.2.0,M11.1.0' }, { 'America/Yakutat', 'AKST9AKDT,M3.2.0,M11.1.0' }, { 'America/Yellowknife', 'MST7MDT,M3.2.0,M11.1.0' }, { 'Antarctica/Casey', 'AWST-8' }, { 'Antarctica/Davis', 'DAVT-7' }, { 'Antarctica/DumontDUrville', 'DDUT-10' }, { 'Antarctica/Macquarie', 'MIST-11' }, { 'Antarctica/Mawson', 'MAWT-5' }, { 'Antarctica/McMurdo', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, { 'Antarctica/Palmer', 'CLT3' }, { 'Antarctica/Rothera', 'ROTT3' }, { 'Antarctica/Syowa', 'SYOT-3' }, { 'Antarctica/Troll', 'UTC0CEST-2,M3.5.0/1,M10.5.0/3' }, { 'Antarctica/Vostok', 'VOST-6' }, { 'Arctic/Longyearbyen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Asia/Aden', 'AST-3' }, { 'Asia/Almaty', 'ALMT-6' }, { 'Asia/Amman', 'EET-2EEST,M3.5.4/24,M10.5.5/1' }, { 'Asia/Anadyr', 'ANAT-12' }, { 'Asia/Aqtau', 'AQTT-5' }, { 'Asia/Aqtobe', 'AQTT-5' }, { 'Asia/Ashgabat', 'TMT-5' }, { 'Asia/Baghdad', 'AST-3' }, { 'Asia/Bahrain', 'AST-3' }, { 'Asia/Baku', 'AZT-4AZST,M3.5.0/4,M10.5.0/5' }, { 'Asia/Bangkok', 'ICT-7' }, { 'Asia/Beirut', 'EET-2EEST,M3.5.0/0,M10.5.0/0' }, { 'Asia/Bishkek', 'KGT-6' }, { 'Asia/Brunei', 'BNT-8' }, { 'Asia/Chita', 'IRKT-8' }, { 'Asia/Choibalsan', 'CHOT-8CHOST,M3.5.6,M9.5.6/0' }, { 'Asia/Colombo', 'IST-5:30' }, { 'Asia/Damascus', 'EET-2EEST,M3.5.5/0,M10.5.5/0' }, { 'Asia/Dhaka', 'BDT-6' }, { 'Asia/Dili', 'TLT-9' }, { 'Asia/Dubai', 'GST-4' }, { 'Asia/Dushanbe', 'TJT-5' }, { 'Asia/Gaza', 'EET-2EEST,M3.5.5/24,M10.3.6/144' }, { 'Asia/Hebron', 'EET-2EEST,M3.5.5/24,M10.3.6/144' }, { 'Asia/Ho Chi Minh', 'ICT-7' }, { 'Asia/Hong Kong', 'HKT-8' }, { 'Asia/Hovd', 'HOVT-7HOVST,M3.5.6,M9.5.6/0' }, { 'Asia/Irkutsk', 'IRKT-8' }, { 'Asia/Jakarta', 'WIB-7' }, { 'Asia/Jayapura', 'WIT-9' }, { 'Asia/Jerusalem', 'IST-2IDT,M3.4.4/26,M10.5.0' }, { 'Asia/Kabul', 'AFT-4:30' }, { 'Asia/Kamchatka', 'PETT-12' }, { 'Asia/Karachi', 'PKT-5' }, { 'Asia/Kathmandu', 'NPT-5:45' }, { 'Asia/Khandyga', 'YAKT-9' }, { 'Asia/Kolkata', 'IST-5:30' }, { 'Asia/Krasnoyarsk', 'KRAT-7' }, { 'Asia/Kuala Lumpur', 'MYT-8' }, { 'Asia/Kuching', 'MYT-8' }, { 'Asia/Kuwait', 'AST-3' }, { 'Asia/Macau', 'CST-8' }, { 'Asia/Magadan', 'MAGT-10' }, { 'Asia/Makassar', 'WITA-8' }, { 'Asia/Manila', 'PHT-8' }, { 'Asia/Muscat', 'GST-4' }, { 'Asia/Nicosia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Asia/Novokuznetsk', 'KRAT-7' }, { 'Asia/Novosibirsk', 'NOVT-6' }, { 'Asia/Omsk', 'OMST-6' }, { 'Asia/Oral', 'ORAT-5' }, { 'Asia/Phnom Penh', 'ICT-7' }, { 'Asia/Pontianak', 'WIB-7' }, { 'Asia/Pyongyang', 'KST-8:30' }, { 'Asia/Qatar', 'AST-3' }, { 'Asia/Qyzylorda', 'QYZT-6' }, { 'Asia/Rangoon', 'MMT-6:30' }, { 'Asia/Riyadh', 'AST-3' }, { 'Asia/Sakhalin', 'SAKT-10' }, { 'Asia/Samarkand', 'UZT-5' }, { 'Asia/Seoul', 'KST-9' }, { 'Asia/Shanghai', 'CST-8' }, { 'Asia/Singapore', 'SGT-8' }, { 'Asia/Srednekolymsk', 'SRET-11' }, { 'Asia/Taipei', 'CST-8' }, { 'Asia/Tashkent', 'UZT-5' }, { 'Asia/Tbilisi', 'GET-4' }, { 'Asia/Thimphu', 'BTT-6' }, { 'Asia/Tokyo', 'JST-9' }, { 'Asia/Ulaanbaatar', 'ULAT-8ULAST,M3.5.6,M9.5.6/0' }, { 'Asia/Urumqi', 'XJT-6' }, { 'Asia/Ust-Nera', 'VLAT-10' }, { 'Asia/Vientiane', 'ICT-7' }, { 'Asia/Vladivostok', 'VLAT-10' }, { 'Asia/Yakutsk', 'YAKT-9' }, { 'Asia/Yekaterinburg', 'YEKT-5' }, { 'Asia/Yerevan', 'AMT-4' }, { 'Atlantic/Azores', 'AZOT1AZOST,M3.5.0/0,M10.5.0/1' }, { 'Atlantic/Bermuda', 'AST4ADT,M3.2.0,M11.1.0' }, { 'Atlantic/Canary', 'WET0WEST,M3.5.0/1,M10.5.0' }, { 'Atlantic/Cape Verde', 'CVT1' }, { 'Atlantic/Faroe', 'WET0WEST,M3.5.0/1,M10.5.0' }, { 'Atlantic/Madeira', 'WET0WEST,M3.5.0/1,M10.5.0' }, { 'Atlantic/Reykjavik', 'GMT0' }, { 'Atlantic/South Georgia', 'GST2' }, { 'Atlantic/St Helena', 'GMT0' }, { 'Atlantic/Stanley', 'FKST3' }, { 'Australia/Adelaide', 'ACST-9:30ACDT,M10.1.0,M4.1.0/3' }, { 'Australia/Brisbane', 'AEST-10' }, { 'Australia/Broken Hill', 'ACST-9:30ACDT,M10.1.0,M4.1.0/3' }, { 'Australia/Currie', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, { 'Australia/Darwin', 'ACST-9:30' }, { 'Australia/Eucla', 'ACWST-8:45' }, { 'Australia/Hobart', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, { 'Australia/Lindeman', 'AEST-10' }, { 'Australia/Lord Howe', 'LHST-10:30LHDT-11,M10.1.0,M4.1.0' }, { 'Australia/Melbourne', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, { 'Australia/Perth', 'AWST-8' }, { 'Australia/Sydney', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, { 'Europe/Amsterdam', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Andorra', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Athens', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Belgrade', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Berlin', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Bratislava', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Brussels', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Bucharest', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Budapest', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Busingen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Chisinau', 'EET-2EEST,M3.5.0,M10.5.0/3' }, { 'Europe/Copenhagen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Dublin', 'GMT0IST,M3.5.0/1,M10.5.0' }, { 'Europe/Gibraltar', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Guernsey', 'GMT0BST,M3.5.0/1,M10.5.0' }, { 'Europe/Helsinki', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Isle of Man', 'GMT0BST,M3.5.0/1,M10.5.0' }, { 'Europe/Istanbul', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Jersey', 'GMT0BST,M3.5.0/1,M10.5.0' }, { 'Europe/Kaliningrad', 'EET-2' }, { 'Europe/Kiev', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Lisbon', 'WET0WEST,M3.5.0/1,M10.5.0' }, { 'Europe/Ljubljana', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/London', 'GMT0BST,M3.5.0/1,M10.5.0' }, { 'Europe/Luxembourg', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Madrid', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Malta', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Mariehamn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Minsk', 'MSK-3' }, { 'Europe/Monaco', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Moscow', 'MSK-3' }, { 'Europe/Oslo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Paris', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Podgorica', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Prague', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Riga', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Rome', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Samara', 'SAMT-4' }, { 'Europe/San Marino', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Sarajevo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Simferopol', 'MSK-3' }, { 'Europe/Skopje', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Sofia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Stockholm', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Tallinn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Tirane', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Uzhgorod', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Vaduz', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Vatican', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Vienna', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Vilnius', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Volgograd', 'MSK-3' }, { 'Europe/Warsaw', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Zagreb', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Europe/Zaporozhye', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, { 'Europe/Zurich', 'CET-1CEST,M3.5.0,M10.5.0/3' }, { 'Indian/Antananarivo', 'EAT-3' }, { 'Indian/Chagos', 'IOT-6' }, { 'Indian/Christmas', 'CXT-7' }, { 'Indian/Cocos', 'CCT-6:30' }, { 'Indian/Comoro', 'EAT-3' }, { 'Indian/Kerguelen', 'TFT-5' }, { 'Indian/Mahe', 'SCT-4' }, { 'Indian/Maldives', 'MVT-5' }, { 'Indian/Mauritius', 'MUT-4' }, { 'Indian/Mayotte', 'EAT-3' }, { 'Indian/Reunion', 'RET-4' }, { 'Pacific/Apia', 'WSST-13WSDT,M9.5.0/3,M4.1.0/4' }, { 'Pacific/Auckland', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, { 'Pacific/Bougainville', 'BST-11' }, { 'Pacific/Chatham', 'CHAST-12:45CHADT,M9.5.0/2:45,M4.1.0/3:45' }, { 'Pacific/Chuuk', 'CHUT-10' }, { 'Pacific/Easter', 'EAST5' }, { 'Pacific/Efate', 'VUT-11' }, { 'Pacific/Enderbury', 'PHOT-13' }, { 'Pacific/Fakaofo', 'TKT-13' }, { 'Pacific/Fiji', 'FJT-12FJST,M11.1.0,M1.3.0/3' }, { 'Pacific/Funafuti', 'TVT-12' }, { 'Pacific/Galapagos', 'GALT6' }, { 'Pacific/Gambier', 'GAMT9' }, { 'Pacific/Guadalcanal', 'SBT-11' }, { 'Pacific/Guam', 'ChST-10' }, { 'Pacific/Honolulu', 'HST10' }, { 'Pacific/Johnston', 'HST10' }, { 'Pacific/Kiritimati', 'LINT-14' }, { 'Pacific/Kosrae', 'KOST-11' }, { 'Pacific/Kwajalein', 'MHT-12' }, { 'Pacific/Majuro', 'MHT-12' }, { 'Pacific/Marquesas', 'MART9:30' }, { 'Pacific/Midway', 'SST11' }, { 'Pacific/Nauru', 'NRT-12' }, { 'Pacific/Niue', 'NUT11' }, { 'Pacific/Norfolk', 'NFT-11' }, { 'Pacific/Noumea', 'NCT-11' }, { 'Pacific/Pago Pago', 'SST11' }, { 'Pacific/Palau', 'PWT-9' }, { 'Pacific/Pitcairn', 'PST8' }, { 'Pacific/Pohnpei', 'PONT-11' }, { 'Pacific/Port Moresby', 'PGT-10' }, { 'Pacific/Rarotonga', 'CKT10' }, { 'Pacific/Saipan', 'ChST-10' }, { 'Pacific/Tahiti', 'TAHT10' }, { 'Pacific/Tarawa', 'GILT-12' }, { 'Pacific/Tongatapu', 'TOT-13' }, { 'Pacific/Wake', 'WAKT-12' }, { 'Pacific/Wallis', 'WFT-12' }, }
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c66331855.lua
3
1831
--D・チャッカン function c66331855.initial_effect(c) --damagea local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(66331855,0)) e1:SetCategory(CATEGORY_DAMAGE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCountLimit(1) e1:SetRange(LOCATION_MZONE) e1:SetCondition(c66331855.cona) e1:SetCost(c66331855.costa) e1:SetTarget(c66331855.tga) e1:SetOperation(c66331855.op) c:RegisterEffect(e1) --damaged local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(66331855,1)) e2:SetCategory(CATEGORY_DAMAGE) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetCountLimit(1) e2:SetRange(LOCATION_MZONE) e2:SetCondition(c66331855.cond) e2:SetTarget(c66331855.tgd) e2:SetOperation(c66331855.op) c:RegisterEffect(e2) end function c66331855.cona(e,tp,eg,ep,ev,re,r,rp) return not e:GetHandler():IsDisabled() and e:GetHandler():IsAttackPos() end function c66331855.cond(e,tp,eg,ep,ev,re,r,rp) return not e:GetHandler():IsDisabled() and e:GetHandler():IsDefencePos() end function c66331855.costa(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,aux.TRUE,1,nil) end local g=Duel.SelectReleaseGroup(tp,aux.TRUE,1,1,nil) Duel.Release(g,REASON_COST) end function c66331855.tga(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(600) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,600) end function c66331855.tgd(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetTargetPlayer(1-tp) Duel.SetTargetParam(300) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,300) end function c66331855.op(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Damage(p,d,REASON_EFFECT) end
gpl-2.0
adan830/UpAndAway
code/prefabs/gummybear_den.lua
2
7791
BindGlobal() local assets = { Asset("ANIM", "anim/gummybear_den.zip"), } local prefabs = { "merm", "collapse_big", } local loot = { "log", "log", "goldnugget", "trinket_2", } local function onlightning(inst) inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") SpawnPrefab("lightning").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("lightning_rod_fx").Transform:SetPosition(inst:GetPosition():Get()) inst:DoTaskInTime(1, function() inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") SpawnPrefab("lightning_rod_fx").Transform:SetPosition(inst:GetPosition():Get()) SpawnPrefab("sparks").Transform:SetPosition(inst:GetPosition():Get()) end) end local zapchance = 0.04 local flickerchance = 0.2 local function onhammered(inst, worker) inst:RemoveComponent("childspawner") inst.components.lootdropper:DropLoot() SpawnPrefab("collapse_big").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst.SoundEmitter:PlaySound("dontstarve/common/destroy_wood") inst:Remove() end local function onhit(inst, worker) if inst.components.childspawner then inst.components.childspawner:ReleaseAllChildren(worker) end end local function IsSpawnTime() local c = GetPseudoClock() return c and (c:IsDay() or c:CurrentPhaseIsAlways()) end local function StartSpawning(inst) if inst.components.childspawner then inst.components.childspawner:StartSpawning() end end local function StopSpawning(inst) if inst.components.childspawner then inst.components.childspawner:StopSpawning() end end local function OnSpawned(inst, child) inst.SoundEmitter:PlaySound("dontstarve/common/pighouse_door") if not IsSpawnTime() and inst.components.childspawner and inst.components.childspawner:CountChildrenOutside() >= 1 and not child.components.combat.target then StopSpawning(inst) end if inst:HasTag("zapped") then inst:RemoveTag("zapped") SpawnPrefab("sparks").Transform:SetPosition(inst:GetPosition():Get()) inst.SoundEmitter:PlaySound("dontstarve/pig/pighut_lightoff") inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") inst.Light:Enable(false) inst.AnimState:PlayAnimation("full") inst.AnimState:SetBloomEffectHandle("") end end local function OnGoHome(inst, child) inst.SoundEmitter:PlaySound("dontstarve/common/pighouse_door") if inst.components.childspawner and inst.components.childspawner:CountChildrenOutside() < 1 then StartSpawning(inst) end inst:DoTaskInTime(1, function() if not inst:HasTag("zapped") then inst:AddTag("zapped") inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) inst.SoundEmitter:PlaySound("dontstarve/pig/pighut_lighton") inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") SpawnPrefab("sparks").Transform:SetPosition(inst:GetPosition():Get()) inst.Light:Enable(true) inst.AnimState:PlayAnimation("med") end end) end -- Called in a inst:DoPeriodicTask(). -- Disabled when the entity is asleep. local function AttemptLightFlicker(inst) if inst.components.childspawner and inst.components.childspawner.childreninside > 0 then if math.random() < flickerchance then inst.SoundEmitter:PlaySound("dontstarve/common/lightningrod") SpawnPrefab("lightning_rod_fx").Transform:SetPosition(inst:GetPosition():Get()) inst.AnimState:PlayAnimation("med") inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) inst:DoTaskInTime(0.1, function() inst.Light:Enable(false) inst.AnimState:PlayAnimation("full") inst.AnimState:SetBloomEffectHandle("") end) inst:DoTaskInTime(0.2, function() inst.Light:Enable(true) inst.AnimState:PlayAnimation("med") inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) end) inst:DoTaskInTime(0.3, function() inst.Light:Enable(false) inst.AnimState:PlayAnimation("full") inst.AnimState:SetBloomEffectHandle("") end) inst:DoTaskInTime(0.4, function() inst.Light:Enable(true) inst.AnimState:PlayAnimation("med") inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) end) end else inst.AnimState:PlayAnimation("full") inst.AnimState:SetBloomEffectHandle("") inst.Light:Enable(false) end end local function StartFlickerTask(inst) if not inst.flickertask then inst.flickertask = inst:DoPeriodicTask(100/100, AttemptLightFlicker) end end local function StopFlickerTask(inst) if inst.flickertask then inst.flickertask:Cancel() inst.flickertask = nil end end local function fn(Sim) local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() inst.entity:AddSoundEmitter() local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon("gummybear_den.tex") MakeObstaclePhysics(inst, 2) inst.Transform:SetScale(1.4, 1.4, 1.4) inst.AnimState:SetBank("rock_stalagmite") inst.AnimState:SetBuild("gummybear_den") inst.AnimState:PlayAnimation("full") local light = inst.entity:AddLight() inst.Light:Enable(false) inst.Light:SetRadius(1.5) inst.Light:SetFalloff(1) inst.Light:SetIntensity(.5) inst.Light:SetColour(235/255,121/255,12/255) ------------------------------------------------------------------------ SetupNetwork(inst) ------------------------------------------------------------------------ inst:AddTag("lightningrod") inst:ListenForEvent("lightningstrike", onlightning) inst:AddTag("structure") inst:AddComponent("lootdropper") inst.components.lootdropper:SetLoot(loot) inst:AddComponent("workable") inst.components.workable:SetWorkAction(ACTIONS.HAMMER) inst.components.workable:SetWorkLeft(5) inst.components.workable:SetOnFinishCallback(onhammered) inst.components.workable:SetOnWorkCallback(onhit) inst:AddComponent("childspawner") inst.components.childspawner.childname = "gummybear" inst.components.childspawner:SetSpawnedFn(OnSpawned) inst.components.childspawner:SetGoHomeFn(OnGoHome) inst.components.childspawner:SetRegenPeriod(TUNING.TOTAL_DAY_TIME*0.4) inst.components.childspawner:SetSpawnPeriod(10) inst.components.childspawner:SetMaxChildren(3) -- Ensures clock savedata has been loaded. inst:DoTaskInTime(0, function(inst) if not GetPseudoClock():CurrentPhaseIsAlways() then inst:ListenForEvent("daytime", function() inst.components.childspawner:ReleaseAllChildren() StartSpawning(inst) end, GetWorld()) inst:ListenForEvent("dusktime", function() StopSpawning(inst) end , GetWorld()) end if IsSpawnTime() then StartSpawning(inst) end end) StartFlickerTask(inst) inst:ListenForEvent("entitysleep", StopFlickerTask) inst:ListenForEvent("entitywake", StartFlickerTask) inst:AddComponent("inspectable") return inst end return Prefab( "common/objects/gummybear_den", fn, assets, prefabs)
gpl-2.0
sjznxd/lc-20130302
modules/admin-mini/luasrc/controller/mini/index.lua
79
1429
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- module("luci.controller.mini.index", package.seeall) function index() local root = node() if not root.lock then root.target = alias("mini") root.index = true end entry({"about"}, template("about")) local page = entry({"mini"}, alias("mini", "index"), _("Essentials"), 10) page.sysauth = "root" page.sysauth_authenticator = "htmlauth" page.index = true entry({"mini", "index"}, alias("mini", "index", "index"), _("Overview"), 10).index = true entry({"mini", "index", "index"}, form("mini/index"), _("General"), 1).ignoreindex = true entry({"mini", "index", "luci"}, cbi("mini/luci", {autoapply=true}), _("Settings"), 10) entry({"mini", "index", "logout"}, call("action_logout"), _("Logout")) end function action_logout() local dsp = require "luci.dispatcher" local sauth = require "luci.sauth" if dsp.context.authsession then sauth.kill(dsp.context.authsession) dsp.context.urltoken.stok = nil end luci.http.header("Set-Cookie", "sysauth=; path=" .. dsp.build_url()) luci.http.redirect(luci.dispatcher.build_url()) end
apache-2.0
adan830/UpAndAway
wickertools/pkgfilelist_gen.lua
2
8887
#!/usr/bin/lua --[[ -- -- Script for generating the list of files and directories to be packaged by -- pkg_archiver.pl. -- -- simplex -- --]] local ARGV = arg local opts = {} local function ParseOpts() local i = 1 while i <= #ARGV do local optname, optvalue repeat local opt opt = ARGV[i]:match("^%-([^-])$") if opt then optname = opt optvalue = true break end opt = ARGV[i]:match("^%-%-(.+)$") if opt then optname, optvalue = opt:match("^(.-)=(.+)$") if not optname then optname = opt optvalue = true end break end until true if optname then opts[optname] = optvalue table.remove(ARGV, i) else i = i + 1 end end end --[[ -- Returns the name of the pkginfo file. --]] local function ParseCmdline() local function print_usage(fh) fh = fh or io.stderr fh:write( ([[Usage: %s <pkginfo-file> pkginfo-file should be a file returning a table describing what to include in the distribution zip archive. It is assumed to be at the top level mod directory. ]]):format( ARGV[0] )) end ParseOpts() if opts.h or opts.help then print_usage(io.stdout) os.exit(0) end --[[ -- pkginfo should be the name of the pkginfo file, passed as the first -- (and only) parameter of the script. --]] local pkginfo = ARGV[1] if not pkginfo then print_usage() os.exit(1) end return pkginfo end --[[ -- Returns the name of the (real) mod directory, given the pkginfo file -- path. --]] local function GetModdir(pkginfo_name) local moddir = pkginfo_name:match("^(.-)[^/" .. package.config:sub(1,1) .. "]+$") if not moddir or #moddir == 0 then moddir = "./" end return moddir end --[[ -- General utitilies. --]] local loadfile_in_env = (function() if _VERSION >= "Lua 5.2" then return function(fname, env) return loadfile(fname, nil, env) end elseif _VERSION == "Lua 5.1" then return function(fname, env) local f = loadfile(fname) if f then setfenv(f, env) end return f end else return error("Unsupported version " .. _VERSION) end end)() local function MergeMaps(...) local ret = {} for _, t in ipairs{...} do for k, v in pairs(t) do ret[k] = v end end return ret end local function JoinArrays(...) local ret = {} for _, A in ipairs{...} do for _, v in ipairs(A) do table.insert(ret, v) end end return ret end local Asset, ExpandAsset = (function() local asset_key = {} local function asset_fn(kind, name) assert( type(name) == "string", "Asset file name is not a string!" ) return {[asset_key] = name} end local function expand_fn(asset) local name = asset[asset_key] assert( type(name) == "string", "Invalid asset!" ) return name end return asset_fn, expand_fn end)() local function NewBasicEnv() return { _PARSING_ENV = true, pairs = pairs, ipairs = ipairs, print = print, math = math, table = table, type = type, string = string, tostring = tostring, } end local pseudo_global_env = (function() local ret = MergeMaps( NewBasicEnv(), { assert = assert, error = error, pcall = pcall, debug = debug, tonumber = tonumber, } ) ret._G = ret ret.MergeMaps, ret.JoinArrays = MergeMaps, JoinArrays return ret end)() --[[ -- modname is the mod directory, as in DS's mod environment. --]] local function NewParsingEnv(modname) local MODROOT = modname .. "/" local env = MergeMaps( NewBasicEnv(), { modname = modname, GLOBAL = pseudo_global_env, MODROOT = MODROOT, Asset = Asset, } ) env.env = env env.modimport = function(fname) assert( loadfile_in_env(MODROOT..fname, env) )() end env.Asset = Asset return env end --[[ -- Tracks the order of variable declaration in the numerical entries. --]] local function NewModinfoEnv() local meta = {} local discovered_vars = {} function meta:__newindex(k, v) rawset(self, k, v) if type(k) == "string" and not discovered_vars[k] then discovered_vars[k] = true table.insert(self, k) end end meta.__index = { _PARSING_ENV = true, } return setmetatable({}, meta) end -- Turns a value x into a string. local DumpValue = (function() local dovalue local doarray local dokey local dotable local function isarray(t) local k = nil for i = 1, #t do k = next(t, k) assert( k ~= nil ) end return next(t, k) == nil end dovalue = function(x) if x == nil then return "nil" end local ty = type(x) if ty == "number" then if x == math.floor(x) then return ("%d"):format(x) else return ("%.4f"):format(x) end elseif ty == "string" then return ("%q"):format(x) elseif ty == "boolean" then return tostring(x) elseif ty == "table" then return dotable(x) else return error("Cannot dump value "..tostring(x).." of type "..ty..".") end end doarray = function(t) local els = {} for i, v in ipairs(t) do els[i] = dovalue(v) end return "{"..table.concat(els, ", ").."}" end dokey = function(k) if type(k) == "table" then return error("Cannot serialize a table as a key.") end if type(k) == "string" and k:find("^[_%a][_%w]*$") then return k end return "["..dovalue(k).."]" end dotable = function(t) if isarray(t) then return doarray(t) else local pieces = {} for k, v in pairs(t) do table.insert(pieces, dokey(k).." = "..dovalue(v)) end return "{"..table.concat(pieces, ", ").."}" end end return dovalue end)() --[[ -- Returns a modinfo parsed in the environment as a string corresponding to a file. --]] local function DumpModinfo(modinfo, annotations) local chunks = {} for _, varname in ipairs(modinfo) do if modinfo[varname] ~= nil then if type(varname) ~= "string" then return error("Modinfo key "..tostring(varname).." is not a string!") end local valstr = DumpValue(modinfo[varname]) local cmnt = annotations[varname] if cmnt then valstr = valstr.." -- "..tostring(cmnt) end table.insert(chunks, varname.." = "..valstr) end end table.insert(chunks, "") return table.concat(chunks, "\n") end --[[ -- Actual work. --]] --[[ -- Prints the packaging info to fh. --]] local function ProcessPkginfo(pkginfo_name, fh) local moddir = GetModdir(pkginfo_name) fh = fh or io.stdout local parsing_env = NewParsingEnv(moddir:sub(1, -2)) local function parse_modfile(name) return assert(loadfile_in_env( moddir..name, parsing_env ))() end local function parse_modinfo() local modinfo = NewModinfoEnv() assert(loadfile_in_env( moddir.."modinfo.lua", modinfo ))() return modinfo end local pkginfo_env = NewBasicEnv() pkginfo_env.opts = opts local pkginfo = assert(loadfile_in_env( pkginfo_name, pkginfo_env ))() assert( type(pkginfo) == "table", ("File %s didn't return a table."):format(pkginfo_name) ) local modinfo local modinfo_annotations = {} if pkginfo.modinfo_filter then modinfo = parse_modinfo() pkginfo_env.annotate = function(name, cmnt) modinfo_annotations[name] = cmnt end modinfo = pkginfo.modinfo_filter(modinfo) pkginfo_env.annotate = nil end fh:write("# Package mod dir\n") fh:write(pkginfo.moddir, "\n") fh:write("\n") fh:write("# Directives.", "\n") fh:write("%CD ", moddir, "\n") fh:write("\n") fh:write("# Excluded suffixes\n") for _, ext in ipairs(pkginfo.exclude_suffixes) do fh:write("!", ext, "\n") end fh:write("\n") fh:write("# Assets\n") do local file_cache = {} for _, asset_file in ipairs(pkginfo.asset_files) do for _, asset in ipairs( parse_modfile(asset_file) ) do local fname = ExpandAsset(asset) if not file_cache[fname] then file_cache[fname] = true fh:write( ExpandAsset(asset), "\n" ) end end end end fh:write("\n") fh:write("# Prefabs\n") do local PREFAB_ROOT = "scripts/prefabs/" local file_cache = {} for _, prefab_filelist in ipairs(pkginfo.prefab_files) do for _, prefab_file in ipairs( parse_modfile(prefab_filelist) ) do assert( type(prefab_file) == "string", "String expected as prefab file name." ) if not file_cache[prefab_file] then file_cache[prefab_file] = true fh:write( PREFAB_ROOT..prefab_file..".lua", "\n" ) end end end end fh:write("\n") fh:write("# Extra\n") for _, extra in ipairs(pkginfo.extra) do if not modinfo or extra ~= "modinfo.lua" then fh:write(extra, "\n") end end fh:write("\n") fh:write("# Empty dirs\n") for _, dir in ipairs(pkginfo.empty_directories) do fh:write("%EMPTY ", dir, "\n") end if modinfo then local modinfo_str = DumpModinfo(modinfo, modinfo_annotations) fh:write("\n") fh:write("# Custom modinfo\n") fh:write("%OCTET STREAM ", tostring(#modinfo_str), " ", "modinfo.lua\n") fh:write(modinfo_str) end end --------------------------------------------------------------------- --[[ -- Execution. --]] ProcessPkginfo(ParseCmdline(), io.stdout)
gpl-2.0
TETOO2020/THETETOO_A8
plugins/en_help.lua
3
7325
--[[ ▀▄ ▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀▄▀▄▄▀▀▄▄▀▀▄▄▀▀▄▄▀▀ ▀▄ ▄▀ ▀▄ ▄▀ ▀▄ ▄▀ BY tetoo ▀▄ ▄▀ ▀▄ ▄▀ BY nmore (@l_l_lo) ▀▄ ▄▀ ▀▄ ▄▀ JUST WRITED BY l_l_ll ▀▄ ▄▀ ▀▄ ▄▀ broadcast : help ar ▀▄ ▄▀ ▀▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀▄▄▀▀▄▄▀▄▄▀▀ --]] do function run(msg, matches) if matches[1] == "/help" and is_momod(msg) then return "🎀🎖اهـلا بـك عـزيـزي 😻 "..msg.from.first_name.."\n" .." ".."\n" ..[[ ⏺WeLcoOomE 🎀🎖سـورس تيـتو الانكليـزي 🎀🎖 /he1 :- اوامر الاداريه في الكروب 🎀🎖 /he2 :- اوامر الـطرد و الحظر في الكروب 🎀🎖 /he3 :-اومر الحمايـةة في الكروب 🎀🎖/he4 :- اوامر المـطور في الكروب ➖➖➖➖➖ 🎀🎖مـطور الســورس 🎀🎖 @l_l_lo 🎀🎖قنـاة السـورس 🎀🎖 @no_no 🎀🎖بـووت تواصل السورس 🎀🎖 @k4k33_bot ]] ------------------ elseif matches[1] == "/he1" and is_momod(msg) then return "🎀🎖اهـلا بـك عـزيـزي 😻 "..msg.from.first_name.."\n" .." ".."\n" ..[[ 🎀🎖اوامـر الادريه في سـورس تيـتو نكليـزي #تسـتخدم معها [/!#] ➖➖➖➖➖➖ 🎀🎖/who 🏅قائمه اعـضاء الكـروب 🎀🎖/info 🏅معلـوماتـي 🎀🎖/gpinfo 🏅معلومات الكروب 🎀🎖/me 🏅مـوقعـي 🎀🎖/id 🏅ايـدي الكروب او برد لضهور ايدي العضو 🎀🎖/link 🏅لضهور رابط الكروب 🎀🎖/ setlink 🏅وضع رابط 🎀🎖/newlink 🏅وضع رابط جديد 🎀🎖/setrules 🏅وضع قـوانـين 🎀🎖/rules 🏅لضهور القـوانين 🎀🎖/setabout 🏅لوضـع وصف 🎀🎖/setname 🏅 لـوضع اسـم 🎀🎖/setwlc 🏅لـوضع الترحـيب 🎀🎖/setbye 🏅 لـوضع تـوديع 🎀🎖/setphoto 🏅لـوضع صوره ➖➖➖➖➖➖ 🎀🎖مـطور الســورس 🎀🎖 @l_l_lo 🎀🎖قنـاة السـورس 🎀🎖 @no_no 🎀🎖بـووت تواصل السورس 🎀🎖 @k4k33_bot 🎀🎖معـرف مـطور البـوت @اكتب معرفك و لا تحذف حقوقنا ]] ------------------ elseif matches[1] == "/he2" and is_momod(msg) then return "🎀🎖اهـلا بـك عـزيـزي 😻 "..msg.from.first_name.."\n" .." ".."\n" ..[[ 🎀🎖اوامر الـترقيـةة و الحظر فـي ســورس تيــتو نكلـيزي #تســتخدم معهـا [/!#] 🎀🎖اوامــر الـترقيةة 🎀🎖/promote 🏅رفع ادمن 🎀🎖/demote 🏅تنزيل ادمن 🎀🎖/setadmin 🏅رفع اداري 🎀🎖 /demoteadmin 🏅 تنـزيل اداري 🎀🎖/admins 🏅عرض الادمنيةة 🎀🎖/who 🏅عـرض الاعضاء 🎀🎖اومـر الحـظر 🎀🎖 /kick + @ 🏅طرد 🎀🎖 /block + @ 🏅 بلوك 🎀🎖 /ban + @ 🏅 حظر 🎀🎖 / unban + @ 🏅 الغاء الحظر 🎀🎖/ banlist 🏅المحظوريــن 🎀🎖/silent 🏅كتـم 🎀🎖/id 🏅ايدي 🎀🎖 / kickme 🏅 مغادرة 🎀🎖/leave 🏅لـطرد البــوت 🎀🎖مـطور الســورس 🎀🎖 @l_l_lo 🎀🎖قنـاة السـورس 🎀🎖 @no_no 🎀🎖بـووت تواصل السورس 🎀🎖 @k4k33_bot ]] ------------------ elseif matches[1] == "/he3" and is_momod(msg) then return "🎀🎖اهـلا بـك عـزيـزي 😻 "..msg.from.first_name.."\n" .." ".."\n" ..[[ 🎀🎖اوامـر الـحمـايةة في ســورس تيـتو نكليـزي #تسـتخدم معهـا [/!#] 🎀🎖قائمــةة المنع 🎀🎖/mute و امر للمنع 🎀🎖/unmute وامـر للفك المنع 🎀🎖audio 🏅الصـوت 🎀🎖photo 🏅الصور 🎀🎖video 🏅الفيـديو 🎀🎖gifs 🏅الصور المتحركةة 🎀🎖text 🏅الكتابةة 🎀🎖قائمــةة القفل 🎀🎖/lock و امر للقفل 🎀🎖/unlock وامر للفتح 🎀🎖/links 🏅 الروابط 🎀🎖/ flood 🏅 التكرار 🎀🎖/ spam 🏅الكلايـش 🎀🎖/sticker 🏅 الملصقـاات 🎀🎖/tag 🏅تاك 🎀🎖/ emoji 🏅الـسمايلات 🎀🎖/bots 🏅البوتاات 🎀🎖/fwd 🏅اعادة توجيةة 🎀🎖/media 🏅الوسـائط او الميديا 🎀🎖/leave 🏅المغـادرةة 🎀🎖/all 🏅الكل 🎀🎖مـطور الســورس 🎀🎖 @l_l_lo 🎀🎖قـناه السـورس 🎀🎖 @no_no2 🎀🎖بـوت تواصل السـورس 🎀🎖 @k4k33_bot ]] ------------------ elseif matches[1] == "/he4" and is_momod(msg) then return "🎀🎖اهـلا بـك عـزيـزي 😻 "..msg.from.first_name.."\n" .." ".."\n" ..[[ 🎀🎖اوامـر الـمـطـور في ســورس تيـتو نكليـزي #تسـتخدم معهـا [/!#] 🎀🎖/addbot 🏅تـفعـيل البـوت 🎀🎖/rembot 🏅تعـطيل البـوت 🎀🎖/creategroup 🏅صـنع كـروب 🎀🎖/tosuper 🏅تحويل سـوبـر 🎀🎖/serverinfo 🏅معـلومات السيـرفر 🎀🎖/send 🏅جلب ملف 🎀🎖/p 🏅الملفات 🎀🎖 /p + اسم ملف 🏅 لتفعيل الملف 🎀🎖/p - اسم ملف 🏅لتعـطيل الملف 🎀🎖/run 🏅 للاعــادة تشـغيل البـوت 🎀🎖/leave 🏅 لـطرد البـوت 🎀🎖مـطور الســورس 🎀🎖 @l_l_lo 🎀🎖قـناه السـورس 🎀🎖 @no_no2 🎀🎖بـوت تواصل السـورس 🎀🎖 @k4k33_bot ]] ------------------------ elseif matches[1] == "الاوامر" and is_momod(msg) then return "🎀🎖اهـلا بـك عـزيـزي 😻 "..msg.from.first_name.."\n" .." ".."\n" ..[[ 🎀🎁ســـورس عـربي و نكـلـيزي 🎀🎖للاظـهار الاوامـر العربيه ارسل مسـاعدة 🎀🎖للاظـهار الاوامر الانكليزية ارسل /help 🎀🎁ملاحـظه اوامر نكليـزيه تعمل مع [/!#] و العـربيه لا تعـمل ➖➖➖➖➖ 🎀🎖مـطور الســورس 🎀🎖 @l_l_lo 🎀🎖قـناه السـورس 🎀🎖 @no_no2 🎀🎖بـوت تواصل السـورس 🎀🎖 @k4k33_bot ]] ----------------------- elseif matches[1] == "م6" and is_sudo(msg) then return "🎀🎖اهـلا بـك عـزيـزي 😻 "..msg.from.first_name.."\n" .." ".."\n" ..[[ انجـب ابـن نعال ويـن اكـو هيـج ]] end end return { patterns = { "^(/help)", "^(/he1)", "^(/he2)", "^(/he3)", "^(/he4)", "^(الاوامر)", "^()", }, run = run } end ---by tetoo -- @l_l_lo
gpl-2.0
freifunk-gluon/luci
applications/luci-vnstat/luasrc/model/cbi/vnstat.lua
90
2019
--[[ LuCI - Lua Configuration Interface Copyright 2010-2011 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]]-- local utl = require "luci.util" local sys = require "luci.sys" local fs = require "nixio.fs" local nw = require "luci.model.network" local dbdir, line for line in io.lines("/etc/vnstat.conf") do dbdir = line:match("^%s*DatabaseDir%s+[\"'](%S-)[\"']") if dbdir then break end end dbdir = dbdir or "/var/lib/vnstat" m = Map("vnstat", translate("VnStat"), translate("VnStat is a network traffic monitor for Linux that keeps a log of network traffic for the selected interface(s).")) m.submit = translate("Restart VnStat") m.reset = false nw.init(luci.model.uci.cursor_state()) local ifaces = { } local enabled = { } local iface if fs.access(dbdir) then for iface in fs.dir(dbdir) do if iface:sub(1,1) ~= '.' then ifaces[iface] = iface enabled[iface] = iface end end end for _, iface in ipairs(sys.net.devices()) do ifaces[iface] = iface end local s = m:section(TypedSection, "vnstat") s.anonymous = true s.addremove = false mon_ifaces = s:option(Value, "interface", translate("Monitor selected interfaces")) mon_ifaces.template = "cbi/network_ifacelist" mon_ifaces.widget = "checkbox" mon_ifaces.cast = "table" mon_ifaces.noinactive = true mon_ifaces.nocreate = true function mon_ifaces.write(self, section, val) local i local s = { } if val then for _, i in ipairs(type(val) == "table" and val or { val }) do s[i] = true end end for i, _ in pairs(ifaces) do if not s[i] then fs.unlink(dbdir .. "/" .. i) fs.unlink(dbdir .. "/." .. i) end end if next(s) then m.uci:set_list("vnstat", section, "interface", utl.keys(s)) else m.uci:delete("vnstat", section, "interface") end end mon_ifaces.remove = mon_ifaces.write return m
apache-2.0
walid55/all_wazer1
plugins/inrealm.lua
850
25085
-- data saved to moderation.json -- check moderation plugin do local function create_group(msg) -- superuser and admins only (because sudo are always has privilege) if is_sudo(msg) or is_realm(msg) and is_admin(msg) then local group_creator = msg.from.print_name create_group_chat (group_creator, group_name, ok_cb, false) return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.' end end local function create_realm(msg) -- superuser and admins only (because sudo are always has privilege) if is_sudo(msg) or is_realm(msg) and is_admin(msg) then local group_creator = msg.from.print_name create_group_chat (group_creator, group_name, ok_cb, false) return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.' end end local function killchat(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function killrealm(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function get_group_type(msg) local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if not data[tostring(msg.to.id)]['group_type'] then return 'No group type available.' end local group_type = data[tostring(msg.to.id)]['group_type'] return group_type else return 'Chat type not found.' end end local function callbackres(extra, success, result) --vardump(result) local user = result.id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function set_description(msg, data, target, about) if not is_admin(msg) then return "For admins only!" end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set group description to:\n'..about end local function set_rules(msg, data, target) if not is_admin(msg) then return "For admins only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end -- lock/unlock group name. bot automatically change group name when locked local function lock_group_name(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Group name has been locked' end end local function unlock_group_name(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end --lock/unlock group member. bot automatically kick new added user when locked local function lock_group_member(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_member(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end --lock/unlock group photo. bot automatically keep group photo when locked local function lock_group_photo(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'yes' then return 'Group photo is already locked' else data[tostring(target)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) end return 'Please send me the group photo now' end local function unlock_group_photo(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function lock_group_flood(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Group flood is locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Group flood has been locked' end end local function unlock_group_flood(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Group flood is not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Group flood has been unlocked' end end -- show group settings local function show_group_settings(msg, data, target) local data = load_data(_config.moderation.data, data) if not is_admin(msg) then return "For admins only!" end local settings = data[tostring(target)]['settings'] local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member return text end local function returnids(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..'' for k,v in pairs(result.members) do if v.print_name then local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end end send_large_msg(receiver, text) local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w") file:write(text) file:flush() file:close() end local function returnidsfile(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..'' for k,v in pairs(result.members) do if v.print_name then local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end end local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w") file:write(text) file:flush() file:close() send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false) end local function admin_promote(msg, admin_id) if not is_sudo(msg) then return "Access denied!" end local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end if data[tostring(admins)][tostring(admin_id)] then return admin_name..' is already an admin.' end data[tostring(admins)][tostring(admin_id)] = admin_id save_data(_config.moderation.data, data) return admin_id..' has been promoted as admin.' end local function admin_demote(msg, admin_id) if not is_sudo(msg) then return "Access denied!" end local data = load_data(_config.moderation.data) local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end if not data[tostring(admins)][tostring(admin_id)] then return admin_id..' is not an admin.' end data[tostring(admins)][tostring(admin_id)] = nil save_data(_config.moderation.data, data) return admin_id..' has been demoted from admin.' end local function admin_list(msg) local data = load_data(_config.moderation.data) local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end local message = 'List for Realm admins:\n' for k,v in pairs(data[tostring(admins)]) do message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n' end return message end local function groups_list(msg) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] then return 'No groups at the moment' end local message = 'List of groups:\n' for k,v in pairs(data[tostring(groups)]) do local settings = data[tostring(v)]['settings'] for m,n in pairs(settings) do if m == 'set_name' then name = n end end local group_owner = "No owner" if data[tostring(v)]['set_owner'] then group_owner = tostring(data[tostring(v)]['set_owner']) end local group_link = "No link" if data[tostring(v)]['settings']['set_link'] then group_link = data[tostring(v)]['settings']['set_link'] end message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n" end local file = io.open("./groups/lists/groups.txt", "w") file:write(message) file:flush() file:close() return message end local function realms_list(msg) local data = load_data(_config.moderation.data) local realms = 'realms' if not data[tostring(realms)] then return 'No Realms at the moment' end local message = 'List of Realms:\n' for k,v in pairs(data[tostring(realms)]) do local settings = data[tostring(v)]['settings'] for m,n in pairs(settings) do if m == 'set_name' then name = n end end local group_owner = "No owner" if data[tostring(v)]['admins_in'] then group_owner = tostring(data[tostring(v)]['admins_in']) end local group_link = "No link" if data[tostring(v)]['settings']['set_link'] then group_link = data[tostring(v)]['settings']['set_link'] end message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n" end local file = io.open("./groups/lists/realms.txt", "w") file:write(message) file:flush() file:close() return message end local function admin_user_promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) if not data['admins'] then data['admins'] = {} save_data(_config.moderation.data, data) end if data['admins'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already as admin.') end data['admins'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.') end local function admin_user_demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) if not data['admins'] then data['admins'] = {} save_data(_config.moderation.data, data) end if not data['admins'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not an admin.') end data['admins'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.') end local function username_id(cb_extra, success, result) local mod_cmd = cb_extra.mod_cmd local receiver = cb_extra.receiver local member = cb_extra.member local text = 'No user @'..member..' in this group.' for k,v in pairs(result.members) do vusername = v.username if vusername == member then member_username = member member_id = v.id if mod_cmd == 'addadmin' then return admin_user_promote(receiver, member_username, member_id) elseif mod_cmd == 'removeadmin' then return admin_user_demote(receiver, member_username, member_id) end end end send_large_msg(receiver, text) end local function set_log_group(msg) if not is_admin(msg) then return end local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group'] if log_group == 'yes' then return 'Log group is already set' else data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes' save_data(_config.moderation.data, data) return 'Log group has been set' end end local function unset_log_group(msg) if not is_admin(msg) then return end local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group'] if log_group == 'no' then return 'Log group is already disabled' else data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no' save_data(_config.moderation.data, data) return 'log group has been disabled' end end local function help() local help_text = tostring(_config.help_text_realm) return help_text end function run(msg, matches) --vardump(msg) local name_log = user_print_name(msg.from) if matches[1] == 'log' and is_owner(msg) then savelog(msg.to.id, "log file created by owner") send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false) end if matches[1] == 'who' and is_momod(msg) then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ") local receiver = get_receiver(msg) chat_info(receiver, returnidsfile, {receiver=receiver}) end if matches[1] == 'wholist' and is_momod(msg) then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file") local receiver = get_receiver(msg) chat_info(receiver, returnids, {receiver=receiver}) end if matches[1] == 'creategroup' and matches[2] then group_name = matches[2] group_type = 'group' return create_group(msg) end if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then return --Do nothing end if matches[1] == 'createrealm' and matches[2] then group_name = matches[2] group_type = 'realm' return create_realm(msg) end local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if matches[2] then if data[tostring(matches[2])] then local settings = data[tostring(matches[2])]['settings'] if matches[1] == 'setabout' and matches[2] then local target = matches[2] local about = matches[3] return set_description(msg, data, target, about) end if matches[1] == 'setrules' then rules = matches[3] local target = matches[2] return set_rules(msg, data, target) end if matches[1] == 'lock' then --group lock * local target = matches[2] if matches[3] == 'name' then return lock_group_name(msg, data, target) end if matches[3] == 'member' then return lock_group_member(msg, data, target) end if matches[3] == 'photo' then return lock_group_photo(msg, data, target) end if matches[3] == 'flood' then return lock_group_flood(msg, data, target) end end if matches[1] == 'unlock' then --group unlock * local target = matches[2] if matches[3] == 'name' then return unlock_group_name(msg, data, target) end if matches[3] == 'member' then return unlock_group_member(msg, data, target) end if matches[3] == 'photo' then return unlock_group_photo(msg, data, target) end if matches[3] == 'flood' then return unlock_group_flood(msg, data, target) end end if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then local target = matches[2] return show_group_settings(msg, data, target) end if matches[1] == 'setname' and is_realm(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setgpname' and is_admin(msg) then local new_name = string.gsub(matches[3], '_', ' ') data[tostring(matches[2])]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(matches[2])]['settings']['set_name'] local to_rename = 'chat#id'..matches[2] rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end end end if matches[1] == 'help' and is_realm(msg) then savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'set' then if matches[2] == 'loggroup' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group") return set_log_group(msg) end end if matches[1] == 'kill' and matches[2] == 'chat' then if not is_admin(msg) then return nil end if is_realm(msg) then local receiver = 'chat#id'..matches[3] return modrem(msg), print("Closing Group: "..receiver), chat_info(receiver, killchat, {receiver=receiver}) else return 'Error: Group '..matches[3]..' not found' end end if matches[1] == 'kill' and matches[2] == 'realm' then if not is_admin(msg) then return nil end if is_realm(msg) then local receiver = 'chat#id'..matches[3] return realmrem(msg), print("Closing realm: "..receiver), chat_info(receiver, killrealm, {receiver=receiver}) else return 'Error: Realm '..matches[3]..' not found' end end if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if not is_admin(msg) then chat_del_user(chat, user, ok_cb, true) end end if matches[1] == 'addadmin' then if string.match(matches[2], '^%d+$') then local admin_id = matches[2] print("user "..admin_id.." has been promoted as admin") return admin_promote(msg, admin_id) else local member = string.gsub(matches[2], "@", "") local mod_cmd = "addadmin" chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end end if matches[1] == 'removeadmin' then if string.match(matches[2], '^%d+$') then local admin_id = matches[2] print("user "..admin_id.." has been demoted") return admin_demote(msg, admin_id) else local member = string.gsub(matches[2], "@", "") local mod_cmd = "removeadmin" chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end end if matches[1] == 'type'then local group_type = get_group_type(msg) return group_type end if matches[1] == 'list' and matches[2] == 'admins' then return admin_list(msg) end if matches[1] == 'list' and matches[2] == 'groups' then if msg.to.type == 'chat' then groups_list(msg) send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false) return "Group list created" --group_list(msg) elseif msg.to.type == 'user' then groups_list(msg) send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false) return "Group list created" --group_list(msg) end end if matches[1] == 'list' and matches[2] == 'realms' then if msg.to.type == 'chat' then realms_list(msg) send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false) return "Realms list created" --realms_list(msg) elseif msg.to.type == 'user' then realms_list(msg) send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false) return "Realms list created" --realms_list(msg) end end if matches[1] == 'res' and is_momod(msg) then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) return res_user(username, callbackres, cbres_extra) end end return { patterns = { "^[!/](creategroup) (.*)$", "^[!/](createrealm) (.*)$", "^[!/](setabout) (%d+) (.*)$", "^[!/](setrules) (%d+) (.*)$", "^[!/](setname) (.*)$", "^[!/](setgpname) (%d+) (.*)$", "^[!/](setname) (%d+) (.*)$", "^[!/](lock) (%d+) (.*)$", "^[!/](unlock) (%d+) (.*)$", "^[!/](setting) (%d+)$", "^[!/](wholist)$", "^[!/](who)$", "^[!/](type)$", "^[!/](kill) (chat) (%d+)$", "^[!/](kill) (realm) (%d+)$", "^[!/](addadmin) (.*)$", -- sudoers only "^[!/](removeadmin) (.*)$", -- sudoers only "^[!/](list) (.*)$", "^[!/](log)$", "^[!/](help)$", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
cpluscpu/episs
plugins/inrealm.lua
850
25085
-- data saved to moderation.json -- check moderation plugin do local function create_group(msg) -- superuser and admins only (because sudo are always has privilege) if is_sudo(msg) or is_realm(msg) and is_admin(msg) then local group_creator = msg.from.print_name create_group_chat (group_creator, group_name, ok_cb, false) return 'Group [ '..string.gsub(group_name, '_', ' ')..' ] has been created.' end end local function create_realm(msg) -- superuser and admins only (because sudo are always has privilege) if is_sudo(msg) or is_realm(msg) and is_admin(msg) then local group_creator = msg.from.print_name create_group_chat (group_creator, group_name, ok_cb, false) return 'Realm [ '..string.gsub(group_name, '_', ' ')..' ] has been created.' end end local function killchat(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function killrealm(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function get_group_type(msg) local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if not data[tostring(msg.to.id)]['group_type'] then return 'No group type available.' end local group_type = data[tostring(msg.to.id)]['group_type'] return group_type else return 'Chat type not found.' end end local function callbackres(extra, success, result) --vardump(result) local user = result.id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function set_description(msg, data, target, about) if not is_admin(msg) then return "For admins only!" end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set group description to:\n'..about end local function set_rules(msg, data, target) if not is_admin(msg) then return "For admins only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end -- lock/unlock group name. bot automatically change group name when locked local function lock_group_name(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Group name has been locked' end end local function unlock_group_name(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end --lock/unlock group member. bot automatically kick new added user when locked local function lock_group_member(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_member(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end --lock/unlock group photo. bot automatically keep group photo when locked local function lock_group_photo(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'yes' then return 'Group photo is already locked' else data[tostring(target)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) end return 'Please send me the group photo now' end local function unlock_group_photo(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function lock_group_flood(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Group flood is locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Group flood has been locked' end end local function unlock_group_flood(msg, data, target) if not is_admin(msg) then return "For admins only!" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Group flood is not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Group flood has been unlocked' end end -- show group settings local function show_group_settings(msg, data, target) local data = load_data(_config.moderation.data, data) if not is_admin(msg) then return "For admins only!" end local settings = data[tostring(target)]['settings'] local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member return text end local function returnids(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..'' for k,v in pairs(result.members) do if v.print_name then local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end end send_large_msg(receiver, text) local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w") file:write(text) file:flush() file:close() end local function returnidsfile(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name local text = 'Users in '..string.gsub(chatname,"_"," ")..' ('..result.id..'):'..'\n'..'' for k,v in pairs(result.members) do if v.print_name then local username = "" text = text .. "- " .. string.gsub(v.print_name,"_"," ") .. " (" .. v.id .. ") \n" end end local file = io.open("./groups/lists/"..result.id.."memberlist.txt", "w") file:write(text) file:flush() file:close() send_document("chat#id"..result.id,"./groups/lists/"..result.id.."memberlist.txt", ok_cb, false) end local function admin_promote(msg, admin_id) if not is_sudo(msg) then return "Access denied!" end local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end if data[tostring(admins)][tostring(admin_id)] then return admin_name..' is already an admin.' end data[tostring(admins)][tostring(admin_id)] = admin_id save_data(_config.moderation.data, data) return admin_id..' has been promoted as admin.' end local function admin_demote(msg, admin_id) if not is_sudo(msg) then return "Access denied!" end local data = load_data(_config.moderation.data) local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end if not data[tostring(admins)][tostring(admin_id)] then return admin_id..' is not an admin.' end data[tostring(admins)][tostring(admin_id)] = nil save_data(_config.moderation.data, data) return admin_id..' has been demoted from admin.' end local function admin_list(msg) local data = load_data(_config.moderation.data) local admins = 'admins' if not data[tostring(admins)] then data[tostring(admins)] = {} save_data(_config.moderation.data, data) end local message = 'List for Realm admins:\n' for k,v in pairs(data[tostring(admins)]) do message = message .. '- (at)' .. v .. ' [' .. k .. '] ' ..'\n' end return message end local function groups_list(msg) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] then return 'No groups at the moment' end local message = 'List of groups:\n' for k,v in pairs(data[tostring(groups)]) do local settings = data[tostring(v)]['settings'] for m,n in pairs(settings) do if m == 'set_name' then name = n end end local group_owner = "No owner" if data[tostring(v)]['set_owner'] then group_owner = tostring(data[tostring(v)]['set_owner']) end local group_link = "No link" if data[tostring(v)]['settings']['set_link'] then group_link = data[tostring(v)]['settings']['set_link'] end message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n" end local file = io.open("./groups/lists/groups.txt", "w") file:write(message) file:flush() file:close() return message end local function realms_list(msg) local data = load_data(_config.moderation.data) local realms = 'realms' if not data[tostring(realms)] then return 'No Realms at the moment' end local message = 'List of Realms:\n' for k,v in pairs(data[tostring(realms)]) do local settings = data[tostring(v)]['settings'] for m,n in pairs(settings) do if m == 'set_name' then name = n end end local group_owner = "No owner" if data[tostring(v)]['admins_in'] then group_owner = tostring(data[tostring(v)]['admins_in']) end local group_link = "No link" if data[tostring(v)]['settings']['set_link'] then group_link = data[tostring(v)]['settings']['set_link'] end message = message .. '- '.. name .. ' (' .. v .. ') ['..group_owner..'] \n {'..group_link.."}\n" end local file = io.open("./groups/lists/realms.txt", "w") file:write(message) file:flush() file:close() return message end local function admin_user_promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) if not data['admins'] then data['admins'] = {} save_data(_config.moderation.data, data) end if data['admins'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already as admin.') end data['admins'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, '@'..member_username..' has been promoted as admin.') end local function admin_user_demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) if not data['admins'] then data['admins'] = {} save_data(_config.moderation.data, data) end if not data['admins'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not an admin.') end data['admins'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Admin '..member_username..' has been demoted.') end local function username_id(cb_extra, success, result) local mod_cmd = cb_extra.mod_cmd local receiver = cb_extra.receiver local member = cb_extra.member local text = 'No user @'..member..' in this group.' for k,v in pairs(result.members) do vusername = v.username if vusername == member then member_username = member member_id = v.id if mod_cmd == 'addadmin' then return admin_user_promote(receiver, member_username, member_id) elseif mod_cmd == 'removeadmin' then return admin_user_demote(receiver, member_username, member_id) end end end send_large_msg(receiver, text) end local function set_log_group(msg) if not is_admin(msg) then return end local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group'] if log_group == 'yes' then return 'Log group is already set' else data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'yes' save_data(_config.moderation.data, data) return 'Log group has been set' end end local function unset_log_group(msg) if not is_admin(msg) then return end local log_group = data[tostring(groups)][tostring(msg.to.id)]['log_group'] if log_group == 'no' then return 'Log group is already disabled' else data[tostring(groups)][tostring(msg.to.id)]['log_group'] = 'no' save_data(_config.moderation.data, data) return 'log group has been disabled' end end local function help() local help_text = tostring(_config.help_text_realm) return help_text end function run(msg, matches) --vardump(msg) local name_log = user_print_name(msg.from) if matches[1] == 'log' and is_owner(msg) then savelog(msg.to.id, "log file created by owner") send_document("chat#id"..msg.to.id,"./groups/"..msg.to.id.."log.txt", ok_cb, false) end if matches[1] == 'who' and is_momod(msg) then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list ") local receiver = get_receiver(msg) chat_info(receiver, returnidsfile, {receiver=receiver}) end if matches[1] == 'wholist' and is_momod(msg) then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] requested member list in a file") local receiver = get_receiver(msg) chat_info(receiver, returnids, {receiver=receiver}) end if matches[1] == 'creategroup' and matches[2] then group_name = matches[2] group_type = 'group' return create_group(msg) end if not is_sudo(msg) or not is_admin(msg) and not is_realm(msg) then return --Do nothing end if matches[1] == 'createrealm' and matches[2] then group_name = matches[2] group_type = 'realm' return create_realm(msg) end local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if matches[2] then if data[tostring(matches[2])] then local settings = data[tostring(matches[2])]['settings'] if matches[1] == 'setabout' and matches[2] then local target = matches[2] local about = matches[3] return set_description(msg, data, target, about) end if matches[1] == 'setrules' then rules = matches[3] local target = matches[2] return set_rules(msg, data, target) end if matches[1] == 'lock' then --group lock * local target = matches[2] if matches[3] == 'name' then return lock_group_name(msg, data, target) end if matches[3] == 'member' then return lock_group_member(msg, data, target) end if matches[3] == 'photo' then return lock_group_photo(msg, data, target) end if matches[3] == 'flood' then return lock_group_flood(msg, data, target) end end if matches[1] == 'unlock' then --group unlock * local target = matches[2] if matches[3] == 'name' then return unlock_group_name(msg, data, target) end if matches[3] == 'member' then return unlock_group_member(msg, data, target) end if matches[3] == 'photo' then return unlock_group_photo(msg, data, target) end if matches[3] == 'flood' then return unlock_group_flood(msg, data, target) end end if matches[1] == 'settings' and data[tostring(matches[2])]['settings'] then local target = matches[2] return show_group_settings(msg, data, target) end if matches[1] == 'setname' and is_realm(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Realm { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setgpname' and is_admin(msg) then local new_name = string.gsub(matches[3], '_', ' ') data[tostring(matches[2])]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(matches[2])]['settings']['set_name'] local to_rename = 'chat#id'..matches[2] rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end end end if matches[1] == 'help' and is_realm(msg) then savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'set' then if matches[2] == 'loggroup' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set as log group") return set_log_group(msg) end end if matches[1] == 'kill' and matches[2] == 'chat' then if not is_admin(msg) then return nil end if is_realm(msg) then local receiver = 'chat#id'..matches[3] return modrem(msg), print("Closing Group: "..receiver), chat_info(receiver, killchat, {receiver=receiver}) else return 'Error: Group '..matches[3]..' not found' end end if matches[1] == 'kill' and matches[2] == 'realm' then if not is_admin(msg) then return nil end if is_realm(msg) then local receiver = 'chat#id'..matches[3] return realmrem(msg), print("Closing realm: "..receiver), chat_info(receiver, killrealm, {receiver=receiver}) else return 'Error: Realm '..matches[3]..' not found' end end if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if not is_admin(msg) then chat_del_user(chat, user, ok_cb, true) end end if matches[1] == 'addadmin' then if string.match(matches[2], '^%d+$') then local admin_id = matches[2] print("user "..admin_id.." has been promoted as admin") return admin_promote(msg, admin_id) else local member = string.gsub(matches[2], "@", "") local mod_cmd = "addadmin" chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end end if matches[1] == 'removeadmin' then if string.match(matches[2], '^%d+$') then local admin_id = matches[2] print("user "..admin_id.." has been demoted") return admin_demote(msg, admin_id) else local member = string.gsub(matches[2], "@", "") local mod_cmd = "removeadmin" chat_info(receiver, username_id, {mod_cmd= mod_cmd, receiver=receiver, member=member}) end end if matches[1] == 'type'then local group_type = get_group_type(msg) return group_type end if matches[1] == 'list' and matches[2] == 'admins' then return admin_list(msg) end if matches[1] == 'list' and matches[2] == 'groups' then if msg.to.type == 'chat' then groups_list(msg) send_document("chat#id"..msg.to.id, "./groups/lists/groups.txt", ok_cb, false) return "Group list created" --group_list(msg) elseif msg.to.type == 'user' then groups_list(msg) send_document("user#id"..msg.from.id, "./groups/lists/groups.txt", ok_cb, false) return "Group list created" --group_list(msg) end end if matches[1] == 'list' and matches[2] == 'realms' then if msg.to.type == 'chat' then realms_list(msg) send_document("chat#id"..msg.to.id, "./groups/lists/realms.txt", ok_cb, false) return "Realms list created" --realms_list(msg) elseif msg.to.type == 'user' then realms_list(msg) send_document("user#id"..msg.from.id, "./groups/lists/realms.txt", ok_cb, false) return "Realms list created" --realms_list(msg) end end if matches[1] == 'res' and is_momod(msg) then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) return res_user(username, callbackres, cbres_extra) end end return { patterns = { "^[!/](creategroup) (.*)$", "^[!/](createrealm) (.*)$", "^[!/](setabout) (%d+) (.*)$", "^[!/](setrules) (%d+) (.*)$", "^[!/](setname) (.*)$", "^[!/](setgpname) (%d+) (.*)$", "^[!/](setname) (%d+) (.*)$", "^[!/](lock) (%d+) (.*)$", "^[!/](unlock) (%d+) (.*)$", "^[!/](setting) (%d+)$", "^[!/](wholist)$", "^[!/](who)$", "^[!/](type)$", "^[!/](kill) (chat) (%d+)$", "^[!/](kill) (realm) (%d+)$", "^[!/](addadmin) (.*)$", -- sudoers only "^[!/](removeadmin) (.*)$", -- sudoers only "^[!/](list) (.*)$", "^[!/](log)$", "^[!/](help)$", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
alireza1998/power
plugins/sudo.lua
1
1875
function run_sh(msg) name = get_name(msg) text = '' -- if config.sh_enabled == false then -- text = '!sh command is disabled' -- else -- if is_sudo(msg) then -- bash = msg.text:sub(4,-1) -- text = run_bash(bash) -- else -- text = name .. ' you have no power here!' -- end -- end if is_sudo(msg) then bash = msg.text:sub(4,-1) text = run_bash(bash) else text = name .. ' you have no power here!' end return text end function run_bash(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end function on_getting_dialogs(cb_extra,success,result) if success then local dialogs={} for key,value in pairs(result) do for chatkey, chat in pairs(value.peer) do print(chatkey,chat) if chatkey=="id" then table.insert(dialogs,chat.."\n") end if chatkey=="print_name" then table.insert(dialogs,chat..": ") end end end send_msg(cb_extra[1],table.concat(dialogs),ok_cb,false) end end function run(msg, matches) if not is_sudo(msg) then return "You aren't allowed!" end local receiver = get_receiver(msg) if string.match(msg.text, '!sh') then text = run_sh(msg) send_msg(receiver, text, ok_cb, false) return end if string.match(msg.text, '!cpu') then text = run_bash('uname -snr') .. ' ' .. run_bash('whoami') text = text .. '\n' .. run_bash('top -b |head -2') send_msg(receiver, text, ok_cb, false) return end if matches[1]=="Get dialogs" then get_dialog_list(on_getting_dialogs,{get_receiver(msg)}) return end end return { description = "shows cpuinfo", usage = "cpu", patterns = {"^cpu", "^!sh","^Get dialogs$"}, run = run }
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c36021814.lua
3
2064
--ワイトキング function c36021814.initial_effect(c) --base attack local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SET_BASE_ATTACK) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetValue(c36021814.atkval) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(36021814,0)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_BATTLE_DESTROYED) e2:SetCondition(c36021814.condition) e2:SetCost(c36021814.cost) e2:SetTarget(c36021814.target) e2:SetOperation(c36021814.operation) c:RegisterEffect(e2) end function c36021814.filter(c) local code=c:GetCode() return code==32274490 or code==36021814 end function c36021814.atkval(e,c) return Duel.GetMatchingGroupCount(c36021814.filter,c:GetControler(),LOCATION_GRAVE,0,nil)*1000 end function c36021814.condition(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsLocation(LOCATION_GRAVE) and bit.band(e:GetHandler():GetReason(),REASON_BATTLE)~=0 end function c36021814.costfilter(c) local code=c:GetCode() return (code==32274490 or code==36021814) and c:IsAbleToRemoveAsCost() end function c36021814.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c36021814.costfilter,tp,LOCATION_GRAVE,0,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c36021814.costfilter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler()) Duel.Remove(g,POS_FACEUP,REASON_COST) end function c36021814.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c36021814.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end if e:GetHandler():IsRelateToEffect(e) then Duel.SpecialSummon(e:GetHandler(),0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
freifunk-gluon/luci
libs/web/luasrc/http/protocol.lua
55
18445
--[[ HTTP protocol implementation for LuCI (c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- --- LuCI http protocol class. -- This class contains several functions useful for http message- and content -- decoding and to retrive form data from raw http messages. module("luci.http.protocol", package.seeall) local ltn12 = require("luci.ltn12") HTTP_MAX_CONTENT = 1024*8 -- 8 kB maximum content size --- Decode an urlencoded string - optionally without decoding -- the "+" sign to " " - and return the decoded string. -- @param str Input string in x-www-urlencoded format -- @param no_plus Don't decode "+" signs to spaces -- @return The decoded string -- @see urlencode function urldecode( str, no_plus ) local function __chrdec( hex ) return string.char( tonumber( hex, 16 ) ) end if type(str) == "string" then if not no_plus then str = str:gsub( "+", " " ) end str = str:gsub( "%%([a-fA-F0-9][a-fA-F0-9])", __chrdec ) end return str end --- Extract and split urlencoded data pairs, separated bei either "&" or ";" -- from given url or string. Returns a table with urldecoded values. -- Simple parameters are stored as string values associated with the parameter -- name within the table. Parameters with multiple values are stored as array -- containing the corresponding values. -- @param url The url or string which contains x-www-urlencoded form data -- @param tbl Use the given table for storing values (optional) -- @return Table containing the urldecoded parameters -- @see urlencode_params function urldecode_params( url, tbl ) local params = tbl or { } if url:find("?") then url = url:gsub( "^.+%?([^?]+)", "%1" ) end for pair in url:gmatch( "[^&;]+" ) do -- find key and value local key = urldecode( pair:match("^([^=]+)") ) local val = urldecode( pair:match("^[^=]+=(.+)$") ) -- store if type(key) == "string" and key:len() > 0 then if type(val) ~= "string" then val = "" end if not params[key] then params[key] = val elseif type(params[key]) ~= "table" then params[key] = { params[key], val } else table.insert( params[key], val ) end end end return params end --- Encode given string to x-www-urlencoded format. -- @param str String to encode -- @return String containing the encoded data -- @see urldecode function urlencode( str ) local function __chrenc( chr ) return string.format( "%%%02x", string.byte( chr ) ) end if type(str) == "string" then str = str:gsub( "([^a-zA-Z0-9$_%-%.%+!*'(),])", __chrenc ) end return str end --- Encode each key-value-pair in given table to x-www-urlencoded format, -- separated by "&". Tables are encoded as parameters with multiple values by -- repeating the parameter name with each value. -- @param tbl Table with the values -- @return String containing encoded values -- @see urldecode_params function urlencode_params( tbl ) local enc = "" for k, v in pairs(tbl) do if type(v) == "table" then for i, v2 in ipairs(v) do enc = enc .. ( #enc > 0 and "&" or "" ) .. urlencode(k) .. "=" .. urlencode(v2) end else enc = enc .. ( #enc > 0 and "&" or "" ) .. urlencode(k) .. "=" .. urlencode(v) end end return enc end -- (Internal function) -- Initialize given parameter and coerce string into table when the parameter -- already exists. -- @param tbl Table where parameter should be created -- @param key Parameter name -- @return Always nil local function __initval( tbl, key ) if tbl[key] == nil then tbl[key] = "" elseif type(tbl[key]) == "string" then tbl[key] = { tbl[key], "" } else table.insert( tbl[key], "" ) end end -- (Internal function) -- Append given data to given parameter, either by extending the string value -- or by appending it to the last string in the parameter's value table. -- @param tbl Table containing the previously initialized parameter value -- @param key Parameter name -- @param chunk String containing the data to append -- @return Always nil -- @see __initval local function __appendval( tbl, key, chunk ) if type(tbl[key]) == "table" then tbl[key][#tbl[key]] = tbl[key][#tbl[key]] .. chunk else tbl[key] = tbl[key] .. chunk end end -- (Internal function) -- Finish the value of given parameter, either by transforming the string value -- or - in the case of multi value parameters - the last element in the -- associated values table. -- @param tbl Table containing the previously initialized parameter value -- @param key Parameter name -- @param handler Function which transforms the parameter value -- @return Always nil -- @see __initval -- @see __appendval local function __finishval( tbl, key, handler ) if handler then if type(tbl[key]) == "table" then tbl[key][#tbl[key]] = handler( tbl[key][#tbl[key]] ) else tbl[key] = handler( tbl[key] ) end end end -- Table of our process states local process_states = { } -- Extract "magic", the first line of a http message. -- Extracts the message type ("get", "post" or "response"), the requested uri -- or the status code if the line descripes a http response. process_states['magic'] = function( msg, chunk, err ) if chunk ~= nil then -- ignore empty lines before request if #chunk == 0 then return true, nil end -- Is it a request? local method, uri, http_ver = chunk:match("^([A-Z]+) ([^ ]+) HTTP/([01]%.[019])$") -- Yup, it is if method then msg.type = "request" msg.request_method = method:lower() msg.request_uri = uri msg.http_version = tonumber( http_ver ) msg.headers = { } -- We're done, next state is header parsing return true, function( chunk ) return process_states['headers']( msg, chunk ) end -- Is it a response? else local http_ver, code, message = chunk:match("^HTTP/([01]%.[019]) ([0-9]+) ([^\r\n]+)$") -- Is a response if code then msg.type = "response" msg.status_code = code msg.status_message = message msg.http_version = tonumber( http_ver ) msg.headers = { } -- We're done, next state is header parsing return true, function( chunk ) return process_states['headers']( msg, chunk ) end end end end -- Can't handle it return nil, "Invalid HTTP message magic" end -- Extract headers from given string. process_states['headers'] = function( msg, chunk ) if chunk ~= nil then -- Look for a valid header format local hdr, val = chunk:match( "^([A-Za-z][A-Za-z0-9%-_]+): +(.+)$" ) if type(hdr) == "string" and hdr:len() > 0 and type(val) == "string" and val:len() > 0 then msg.headers[hdr] = val -- Valid header line, proceed return true, nil elseif #chunk == 0 then -- Empty line, we won't accept data anymore return false, nil else -- Junk data return nil, "Invalid HTTP header received" end else return nil, "Unexpected EOF" end end --- Creates a ltn12 source from the given socket. The source will return it's -- data line by line with the trailing \r\n stripped of. -- @param sock Readable network socket -- @return Ltn12 source function function header_source( sock ) return ltn12.source.simplify( function() local chunk, err, part = sock:receive("*l") -- Line too long if chunk == nil then if err ~= "timeout" then return nil, part and "Line exceeds maximum allowed length" or "Unexpected EOF" else return nil, err end -- Line ok elseif chunk ~= nil then -- Strip trailing CR chunk = chunk:gsub("\r$","") return chunk, nil end end ) end --- Decode a mime encoded http message body with multipart/form-data -- Content-Type. Stores all extracted data associated with its parameter name -- in the params table withing the given message object. Multiple parameter -- values are stored as tables, ordinary ones as strings. -- If an optional file callback function is given then it is feeded with the -- file contents chunk by chunk and only the extracted file name is stored -- within the params table. The callback function will be called subsequently -- with three arguments: -- o Table containing decoded (name, file) and raw (headers) mime header data -- o String value containing a chunk of the file data -- o Boolean which indicates wheather the current chunk is the last one (eof) -- @param src Ltn12 source function -- @param msg HTTP message object -- @param filecb File callback function (optional) -- @return Value indicating successful operation (not nil means "ok") -- @return String containing the error if unsuccessful -- @see parse_message_header function mimedecode_message_body( src, msg, filecb ) if msg and msg.env.CONTENT_TYPE then msg.mime_boundary = msg.env.CONTENT_TYPE:match("^multipart/form%-data; boundary=(.+)$") end if not msg.mime_boundary then return nil, "Invalid Content-Type found" end local tlen = 0 local inhdr = false local field = nil local store = nil local lchunk = nil local function parse_headers( chunk, field ) local stat repeat chunk, stat = chunk:gsub( "^([A-Z][A-Za-z0-9%-_]+): +([^\r\n]+)\r\n", function(k,v) field.headers[k] = v return "" end ) until stat == 0 chunk, stat = chunk:gsub("^\r\n","") -- End of headers if stat > 0 then if field.headers["Content-Disposition"] then if field.headers["Content-Disposition"]:match("^form%-data; ") then field.name = field.headers["Content-Disposition"]:match('name="(.-)"') field.file = field.headers["Content-Disposition"]:match('filename="(.+)"$') end end if not field.headers["Content-Type"] then field.headers["Content-Type"] = "text/plain" end if field.name and field.file and filecb then __initval( msg.params, field.name ) __appendval( msg.params, field.name, field.file ) store = filecb elseif field.name then __initval( msg.params, field.name ) store = function( hdr, buf, eof ) __appendval( msg.params, field.name, buf ) end else store = nil end return chunk, true end return chunk, false end local function snk( chunk ) tlen = tlen + ( chunk and #chunk or 0 ) if msg.env.CONTENT_LENGTH and tlen > tonumber(msg.env.CONTENT_LENGTH) + 2 then return nil, "Message body size exceeds Content-Length" end if chunk and not lchunk then lchunk = "\r\n" .. chunk elseif lchunk then local data = lchunk .. ( chunk or "" ) local spos, epos, found repeat spos, epos = data:find( "\r\n--" .. msg.mime_boundary .. "\r\n", 1, true ) if not spos then spos, epos = data:find( "\r\n--" .. msg.mime_boundary .. "--\r\n", 1, true ) end if spos then local predata = data:sub( 1, spos - 1 ) if inhdr then predata, eof = parse_headers( predata, field ) if not eof then return nil, "Invalid MIME section header" elseif not field.name then return nil, "Invalid Content-Disposition header" end end if store then store( field, predata, true ) end field = { headers = { } } found = found or true data, eof = parse_headers( data:sub( epos + 1, #data ), field ) inhdr = not eof end until not spos if found then -- We found at least some boundary. Save -- the unparsed remaining data for the -- next chunk. lchunk, data = data, nil else -- There was a complete chunk without a boundary. Parse it as headers or -- append it as data, depending on our current state. if inhdr then lchunk, eof = parse_headers( data, field ) inhdr = not eof else -- We're inside data, so append the data. Note that we only append -- lchunk, not all of data, since there is a chance that chunk -- contains half a boundary. Assuming that each chunk is at least the -- boundary in size, this should prevent problems store( field, lchunk, false ) lchunk, chunk = chunk, nil end end end return true end return ltn12.pump.all( src, snk ) end --- Decode an urlencoded http message body with application/x-www-urlencoded -- Content-Type. Stores all extracted data associated with its parameter name -- in the params table withing the given message object. Multiple parameter -- values are stored as tables, ordinary ones as strings. -- @param src Ltn12 source function -- @param msg HTTP message object -- @return Value indicating successful operation (not nil means "ok") -- @return String containing the error if unsuccessful -- @see parse_message_header function urldecode_message_body( src, msg ) local tlen = 0 local lchunk = nil local function snk( chunk ) tlen = tlen + ( chunk and #chunk or 0 ) if msg.env.CONTENT_LENGTH and tlen > tonumber(msg.env.CONTENT_LENGTH) + 2 then return nil, "Message body size exceeds Content-Length" elseif tlen > HTTP_MAX_CONTENT then return nil, "Message body size exceeds maximum allowed length" end if not lchunk and chunk then lchunk = chunk elseif lchunk then local data = lchunk .. ( chunk or "&" ) local spos, epos repeat spos, epos = data:find("^.-[;&]") if spos then local pair = data:sub( spos, epos - 1 ) local key = pair:match("^(.-)=") local val = pair:match("=([^%s]*)%s*$") if key and #key > 0 then __initval( msg.params, key ) __appendval( msg.params, key, val ) __finishval( msg.params, key, urldecode ) end data = data:sub( epos + 1, #data ) end until not spos lchunk = data end return true end return ltn12.pump.all( src, snk ) end --- Try to extract an http message header including information like protocol -- version, message headers and resulting CGI environment variables from the -- given ltn12 source. -- @param src Ltn12 source function -- @return HTTP message object -- @see parse_message_body function parse_message_header( src ) local ok = true local msg = { } local sink = ltn12.sink.simplify( function( chunk ) return process_states['magic']( msg, chunk ) end ) -- Pump input data... while ok do -- get data ok, err = ltn12.pump.step( src, sink ) -- error if not ok and err then return nil, err -- eof elseif not ok then -- Process get parameters if ( msg.request_method == "get" or msg.request_method == "post" ) and msg.request_uri:match("?") then msg.params = urldecode_params( msg.request_uri ) else msg.params = { } end -- Populate common environment variables msg.env = { CONTENT_LENGTH = msg.headers['Content-Length']; CONTENT_TYPE = msg.headers['Content-Type'] or msg.headers['Content-type']; REQUEST_METHOD = msg.request_method:upper(); REQUEST_URI = msg.request_uri; SCRIPT_NAME = msg.request_uri:gsub("?.+$",""); SCRIPT_FILENAME = ""; -- XXX implement me SERVER_PROTOCOL = "HTTP/" .. string.format("%.1f", msg.http_version); QUERY_STRING = msg.request_uri:match("?") and msg.request_uri:gsub("^.+?","") or "" } -- Populate HTTP_* environment variables for i, hdr in ipairs( { 'Accept', 'Accept-Charset', 'Accept-Encoding', 'Accept-Language', 'Connection', 'Cookie', 'Host', 'Referer', 'User-Agent', } ) do local var = 'HTTP_' .. hdr:upper():gsub("%-","_") local val = msg.headers[hdr] msg.env[var] = val end end end return msg end --- Try to extract and decode a http message body from the given ltn12 source. -- This function will examine the Content-Type within the given message object -- to select the appropriate content decoder. -- Currently the application/x-www-urlencoded and application/form-data -- mime types are supported. If the encountered content encoding can't be -- handled then the whole message body will be stored unaltered as "content" -- property within the given message object. -- @param src Ltn12 source function -- @param msg HTTP message object -- @param filecb File data callback (optional, see mimedecode_message_body()) -- @return Value indicating successful operation (not nil means "ok") -- @return String containing the error if unsuccessful -- @see parse_message_header function parse_message_body( src, msg, filecb ) -- Is it multipart/mime ? if msg.env.REQUEST_METHOD == "POST" and msg.env.CONTENT_TYPE and msg.env.CONTENT_TYPE:match("^multipart/form%-data") then return mimedecode_message_body( src, msg, filecb ) -- Is it application/x-www-form-urlencoded ? elseif msg.env.REQUEST_METHOD == "POST" and msg.env.CONTENT_TYPE and msg.env.CONTENT_TYPE:match("^application/x%-www%-form%-urlencoded") then return urldecode_message_body( src, msg, filecb ) -- Unhandled encoding -- If a file callback is given then feed it chunk by chunk, else -- store whole buffer in message.content else local sink -- If we have a file callback then feed it if type(filecb) == "function" then sink = filecb -- ... else append to .content else msg.content = "" msg.content_length = 0 sink = function( chunk, err ) if chunk then if ( msg.content_length + #chunk ) <= HTTP_MAX_CONTENT then msg.content = msg.content .. chunk msg.content_length = msg.content_length + #chunk return true else return nil, "POST data exceeds maximum allowed length" end end return true end end -- Pump data... while true do local ok, err = ltn12.pump.step( src, sink ) if not ok and err then return nil, err elseif not err then return true end end return true end end --- Table containing human readable messages for several http status codes. -- @class table statusmsg = { [200] = "OK", [206] = "Partial Content", [301] = "Moved Permanently", [302] = "Found", [304] = "Not Modified", [400] = "Bad Request", [403] = "Forbidden", [404] = "Not Found", [405] = "Method Not Allowed", [408] = "Request Time-out", [411] = "Length Required", [412] = "Precondition Failed", [416] = "Requested range not satisfiable", [500] = "Internal Server Error", [503] = "Server Unavailable", }
apache-2.0
LuaDist2/dromozoa-ubench
sample.lua
2
1110
-- Copyright (C) 2015 Tomoyuki Fujimori <moyu@dromozoa.com> -- -- This file is part of dromozoa-ubench. -- -- dromozoa-ubench is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- dromozoa-ubench is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with dromozoa-ubench. If not, see <http://www.gnu.org/licenses/>. local loadstring = loadstring or load local B = {} for i = 0, 32 do local code = {} code[#code + 1] = [[ return function () local out local n1, n2 = 1, 2 ]] for j = 1, i do code[#code + 1] = " out = n1 + n2\n" end code[#code + 1] = "end\n" B[#B + 1] = { "ADD/" .. i, assert(loadstring(table.concat(code)))() } end return B
gpl-3.0
dinodeck/rpg_dialog_script
dialog_runner/code/MoveState.lua
10
3261
MoveState = { mName = "move" } MoveState.__index = MoveState function MoveState:Create(character, map) local this = { mCharacter = character, mMap = map, mTileWidth = map.mTileWidth, mEntity = character.mEntity, mController = character.mController, mMoveX = 0, mMoveY = 0, mTween = Tween:Create(0, 0, 1), mMoveSpeed = 0.3, } this.mAnim = Animation:Create({ this.mEntity.mStartFrame }) setmetatable(this, self) return this end function MoveState:Enter(data) local frames = nil if data.x == 1 then frames = self.mCharacter.mAnims.right self.mCharacter.mFacing = "right" elseif data.x == -1 then frames = self.mCharacter.mAnims.left self.mCharacter.mFacing = "left" elseif data.y == -1 then frames = self.mCharacter.mAnims.up self.mCharacter.mFacing = "up" elseif data.y == 1 then frames = self.mCharacter.mAnims.down self.mCharacter.mFacing = "down" end self.mAnim:SetFrames(frames) self.mMoveX = data.x self.mMoveY = data.y local pixelPos = self.mEntity.mSprite:GetPosition() self.mPixelX = pixelPos:X() self.mPixelY = pixelPos:Y() self.mTween = Tween:Create(0, self.mTileWidth, self.mMoveSpeed) local targetX = self.mEntity.mTileX + data.x local targetY = self.mEntity.mTileY + data.y if self.mMap:IsBlocked(1, targetX, targetY) then self.mMoveX = 0 self.mMoveY = 0 self.mEntity:SetFrame(self.mAnim:Frame()) self.mController:Change(self.mCharacter.mDefaultState) return end if self.mMoveX ~= 0 or self.mMoveY ~= 0 then local x = self.mEntity.mTileX local y = self.mEntity.mTileY local layer = self.mEntity.mLayer local trigger = self.mMap:GetTrigger(x,y, layer) if trigger then trigger:OnExit(self.mEntity, x, y, layer) else self.mMap:TryEncounter(x, y, layer) end end self.mEntity:SetTilePos(self.mEntity.mTileX + self.mMoveX, self.mEntity.mTileY + self.mMoveY, self.mEntity.mLayer, self.mMap) self.mEntity.mSprite:SetPosition(pixelPos) end function MoveState:Exit() local x = self.mEntity.mTileX local y = self.mEntity.mTileY local layer = self.mEntity.mLayer local trigger = self.mMap:GetTrigger(x, y, layer) if trigger then trigger:OnEnter(self.mEntity, x, y, layer) end end function MoveState:Render(renderer) end function MoveState:Update(dt) self.mAnim:Update(dt) self.mEntity:SetFrame(self.mAnim:Frame()) self.mTween:Update(dt) local value = self.mTween:Value() local x = self.mPixelX + (value * self.mMoveX) local y = self.mPixelY - (value * self.mMoveY) self.mEntity.mX = math.floor(x) self.mEntity.mY = math.floor(y) self.mEntity.mSprite:SetPosition(self.mEntity.mX , self.mEntity.mY) if self.mTween:IsFinished() then self.mController:Change(self.mCharacter.mDefaultState) end end
mit
zhaoxin54430/zhaoxin_test
src_luci/applications/luci-app-radicale/luasrc/controller/radicale.lua
32
6668
-- Copyright 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com> -- Licensed under the Apache License, Version 2.0 module("luci.controller.radicale", package.seeall) local NX = require("nixio") local NXFS = require("nixio.fs") local DISP = require "luci.dispatcher" local HTTP = require("luci.http") local I18N = require("luci.i18n") -- not globally avalible here local UTIL = require("luci.util") local SYS = require("luci.sys") function index() entry( {"admin", "services", "radicale"}, alias("admin", "services", "radicale", "edit"), _("CalDAV/CardDAV"), 58) entry( {"admin", "services", "radicale", "edit"}, cbi("radicale") ).leaf = true entry( {"admin", "services", "radicale", "logview"}, call("_logread") ).leaf = true entry( {"admin", "services", "radicale", "startstop"}, call("_startstop") ).leaf = true entry( {"admin", "services", "radicale", "status"}, call("_status") ).leaf = true end -- called by XHR.get from detail_logview.htm function _logread() -- read application settings local uci = UCI.cursor() local logfile = uci:get("radicale", "radicale", "logfile") or "/var/log/radicale" uci:unload("radicale") local ldata=NXFS.readfile(logfile) if not ldata or #ldata == 0 then ldata="_nodata_" end HTTP.write(ldata) end -- called by XHR.get from detail_startstop.htm function _startstop() local pid = get_pid() if pid > 0 then SYS.call("/etc/init.d/radicale stop") NX.nanosleep(1) -- sleep a second if NX.kill(pid, 0) then -- still running NX.kill(pid, 9) -- send SIGKILL end pid = 0 else SYS.call("/etc/init.d/radicale start") NX.nanosleep(1) -- sleep a second pid = get_pid() if pid > 0 and not NX.kill(pid, 0) then pid = 0 -- process did not start end end HTTP.write(tostring(pid)) -- HTTP needs string not number end -- called by XHR.poll from detail_startstop.htm function _status() local pid = get_pid() HTTP.write(tostring(pid)) -- HTTP needs string not number end -- Application / Service specific information functions ######################## function luci_app_name() return "luci-app-radicale" end function service_name() return "radicale" end function service_required() return "0.10-1" end function service_installed() local v = ipkg_ver_installed("radicale-py2") if not v or #v == 0 then v = ipkg_ver_installed("radicale-py3") end if not v or #v == 0 then v = "0" end return v end function service_ok() return ipkg_ver_compare(service_installed(),">=",service_required()) end function app_title_main() return [[</a><a href="javascript:alert(']] .. I18N.translate("Version Information") .. [[\n\n]] .. luci_app_name() .. [[\n\t]] .. I18N.translate("Version") .. [[:\t]] .. (ipkg_ver_installed(luci_app_name()) == "" and I18N.translate("NOT installed") or ipkg_ver_installed(luci_app_name()) ) .. [[\n\n]] .. service_name() .. [[ ]] .. I18N.translate("required") .. [[:]] .. [[\n\t]] .. I18N.translate("Version") .. [[:\t]] .. service_required() .. [[ ]] .. I18N.translate("or higher") .. [[\n\n]] .. service_name() .. [[ ]] .. I18N.translate("installed") .. [[:]] .. [[\n\t]] .. I18N.translate("Version") .. [[:\t]] .. (service_installed() == "0" and I18N.translate("NOT installed") or service_installed()) .. [[\n\n]] .. [[')">]] .. I18N.translate("Radicale CalDAV/CardDAV Server") end function app_title_back() return [[</a><a href="]] .. DISP.build_url("admin", "services", "radicale") .. [[">]] .. I18N.translate("Radicale CalDAV/CardDAV Server") end function app_description() return I18N.translate("The Radicale Project is a complete CalDAV (calendar) and CardDAV (contact) server solution.") .. [[<br />]] .. I18N.translate("Calendars and address books are available for both local and remote access, possibly limited through authentication policies.") .. [[<br />]] .. I18N.translate("They can be viewed and edited by calendar and contact clients on mobile phones or computers.") end -- other multiused functions ################################################### --return pid of running process function get_pid() return tonumber(SYS.exec([[ps | grep "[p]ython.*[r]adicale" 2>/dev/null | awk '{print $1}']])) or 0 end -- compare versions using "<=" "<" ">" ">=" "=" "<<" ">>" function ipkg_ver_compare(ver1, comp, ver2) if not ver1 or not ver2 or not comp or not (#comp > 0) then return nil end -- correct compare string if comp == "<>" or comp == "><" or comp == "!=" or comp == "~=" then comp = "~=" elseif comp == "<=" or comp == "<" or comp == "=<" then comp = "<=" elseif comp == ">=" or comp == ">" or comp == "=>" then comp = ">=" elseif comp == "=" or comp == "==" then comp = "==" elseif comp == "<<" then comp = "<" elseif comp == ">>" then comp = ">" else return nil end local av1 = UTIL.split(ver1, "[%.%-]", nil, true) local av2 = UTIL.split(ver2, "[%.%-]", nil, true) for i = 1, math.max(table.getn(av1),table.getn(av2)), 1 do local s1 = av1[i] or "" local s2 = av2[i] or "" -- first "not equal" found return true if comp == "~=" and (s1 ~= s2) then return true end -- first "lower" found return true if (comp == "<" or comp == "<=") and (s1 < s2) then return true end -- first "greater" found return true if (comp == ">" or comp == ">=") and (s1 > s2) then return true end -- not equal then return false if (s1 ~= s2) then return false end end -- all equal and not compare greater or lower then true return not (comp == "<" or comp == ">") end -- read version information for given package if installed function ipkg_ver_installed(pkg) local version = "" local control = io.open("/usr/lib/opkg/info/%s.control" % pkg, "r") if control then local ln repeat ln = control:read("*l") if ln and ln:match("^Version: ") then version = ln:gsub("^Version: ", "") break end until not ln control:close() end return version end -- replacement of build-in Flag.parse of cbi.lua -- modified to mark section as changed if value changes -- current parse did not do this, but it is done AbstaractValue.parse() function flag_parse(self, section) local fexists = self.map:formvalue( luci.cbi.FEXIST_PREFIX .. self.config .. "." .. section .. "." .. self.option) if fexists then local fvalue = self:formvalue(section) and self.enabled or self.disabled local cvalue = self:cfgvalue(section) if fvalue ~= self.default or (not self.optional and not self.rmempty) then self:write(section, fvalue) else self:remove(section) end if (fvalue ~= cvalue) then self.section.changed = true end else self:remove(section) self.section.changed = true end end
gpl-2.0
TETOO2020/THETETOO_A8
plugins/links.lua
4
1302
local function run(msg, matches) if is_momod(msg) then return end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings'] then if data[tostring(msg.to.id)]['settings']['lock_ads'] then lock_ads = data[tostring(msg.to.id)]['settings']['lock_ads'] end end end local chat = get_receiver(msg) local user = "user#id"..msg.from.id if lock_ads == "yes" then delete_msg(msg.id, ok_cb, true) end end return {patterns = { "[Hh][Tt][Tt][Pp][Ss]://[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/[Jj][Oo][Ii][Nn][Cc][Hh][Aa][Tt]/", "[Hh][Tt][Tt][Pp][Ss]://[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/[Jj][Oo][Ii][Nn][Cc][Hh][Aa][Tt]", "[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/[Jj][Oo][Ii][Nn][Cc][Hh][Aa][Tt]/", "[Tt][Ee][Ll][Ee][Gg][Rr][Aa][Mm].[Mm][Ee]/[Jj][Oo][Ii][Nn][Cc][Hh][Aa][Tt]/", "[Hh][Tt][Tt][Pp]://", "[Ww][Ww][Ww]:", "telegram.me/(.*)", "TELEGRAM.ME/(.*)", "Telegram.me/(.*)", "(.*) telegram.me/(.*)", "(.*) https://(.*)", "(.*) www.(.*)", "(.*) telegram.me/(.*)", "(.*) https://(.*)", "(.*) www.(.*)"; "https://(.*)", "http://(.*)", "www.(.*)", "WWW.(.*)", "^(https://t.me/)$", "[Tt].[Mm][Ee]/", }, run = run } ----by @llX8Xll
gpl-2.0
zwhfly/openwrt-luci
modules/freifunk/luasrc/model/cbi/freifunk/basics.lua
74
3518
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2011 Manuel Munz <freifunk at somakoma de> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]] local fs = require "luci.fs" local util = require "luci.util" local uci = require "luci.model.uci".cursor() local profiles = "/etc/config/profile_" m = Map("freifunk", translate ("Community")) c = m:section(NamedSection, "community", "public", nil, translate("These are the basic settings for your local wireless community. These settings define the default values for the wizard and DO NOT affect the actual configuration of the router.")) community = c:option(ListValue, "name", translate ("Community")) community.rmempty = false local list = { } local list = fs.glob(profiles .. "*") for k,v in ipairs(list) do local name = uci:get_first(v, "community", "name") or "?" local n = string.gsub(v, profiles, "") community:value(n, name) end n = Map("system", translate("Basic system settings")) function n.on_after_commit(self) luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "basics")) end b = n:section(TypedSection, "system") b.anonymous = true hn = b:option(Value, "hostname", translate("Hostname")) hn.rmempty = false hn.datatype = "hostname" loc = b:option(Value, "location", translate("Location")) loc.rmempty = false loc.datatype = "minlength(1)" lat = b:option(Value, "latitude", translate("Latitude"), translate("e.g.") .. " 48.12345") lat.datatype = "float" lat.rmempty = false lon = b:option(Value, "longitude", translate("Longitude"), translate("e.g.") .. " 10.12345") lon.datatype = "float" lon.rmempty = false --[[ Opens an OpenStreetMap iframe or popup Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js ]]-- local class = util.class local ff = uci:get("freifunk", "community", "name") or "" local co = "profile_" .. ff local deflat = uci:get_first("system", "system", "latitude") or uci:get_first(co, "community", "latitude") or 52 local deflon = uci:get_first("system", "system", "longitude") or uci:get_first(co, "community", "longitude") or 10 local zoom = 12 if ( deflat == 52 and deflon == 10 ) then zoom = 4 end OpenStreetMapLonLat = luci.util.class(AbstractValue) function OpenStreetMapLonLat.__init__(self, ...) AbstractValue.__init__(self, ...) self.template = "cbi/osmll_value" self.latfield = nil self.lonfield = nil self.centerlat = "" self.centerlon = "" self.zoom = "0" self.width = "100%" --popups will ignore the %-symbol, "100%" is interpreted as "100" self.height = "600" self.popup = false self.displaytext="OpenStreetMap" --text on button, that loads and displays the OSMap self.hidetext="X" -- text on button, that hides OSMap end osm = b:option(OpenStreetMapLonLat, "latlon", translate("Find your coordinates with OpenStreetMap"), translate("Select your location with a mouse click on the map. The map will only show up if you are connected to the Internet.")) osm.latfield = "latitude" osm.lonfield = "longitude" osm.centerlat = uci:get_first("system", "system", "latitude") or deflat osm.centerlon = uci:get_first("system", "system", "longitude") or deflon osm.zoom = zoom osm.width = "100%" osm.height = "600" osm.popup = false osm.displaytext=translate("Show OpenStreetMap") osm.hidetext=translate("Hide OpenStreetMap") return m, n
apache-2.0
sjznxd/lc-20130302
modules/freifunk/luasrc/model/cbi/freifunk/basics.lua
74
3518
--[[ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> Copyright 2011 Manuel Munz <freifunk at somakoma de> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]] local fs = require "luci.fs" local util = require "luci.util" local uci = require "luci.model.uci".cursor() local profiles = "/etc/config/profile_" m = Map("freifunk", translate ("Community")) c = m:section(NamedSection, "community", "public", nil, translate("These are the basic settings for your local wireless community. These settings define the default values for the wizard and DO NOT affect the actual configuration of the router.")) community = c:option(ListValue, "name", translate ("Community")) community.rmempty = false local list = { } local list = fs.glob(profiles .. "*") for k,v in ipairs(list) do local name = uci:get_first(v, "community", "name") or "?" local n = string.gsub(v, profiles, "") community:value(n, name) end n = Map("system", translate("Basic system settings")) function n.on_after_commit(self) luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "basics")) end b = n:section(TypedSection, "system") b.anonymous = true hn = b:option(Value, "hostname", translate("Hostname")) hn.rmempty = false hn.datatype = "hostname" loc = b:option(Value, "location", translate("Location")) loc.rmempty = false loc.datatype = "minlength(1)" lat = b:option(Value, "latitude", translate("Latitude"), translate("e.g.") .. " 48.12345") lat.datatype = "float" lat.rmempty = false lon = b:option(Value, "longitude", translate("Longitude"), translate("e.g.") .. " 10.12345") lon.datatype = "float" lon.rmempty = false --[[ Opens an OpenStreetMap iframe or popup Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js ]]-- local class = util.class local ff = uci:get("freifunk", "community", "name") or "" local co = "profile_" .. ff local deflat = uci:get_first("system", "system", "latitude") or uci:get_first(co, "community", "latitude") or 52 local deflon = uci:get_first("system", "system", "longitude") or uci:get_first(co, "community", "longitude") or 10 local zoom = 12 if ( deflat == 52 and deflon == 10 ) then zoom = 4 end OpenStreetMapLonLat = luci.util.class(AbstractValue) function OpenStreetMapLonLat.__init__(self, ...) AbstractValue.__init__(self, ...) self.template = "cbi/osmll_value" self.latfield = nil self.lonfield = nil self.centerlat = "" self.centerlon = "" self.zoom = "0" self.width = "100%" --popups will ignore the %-symbol, "100%" is interpreted as "100" self.height = "600" self.popup = false self.displaytext="OpenStreetMap" --text on button, that loads and displays the OSMap self.hidetext="X" -- text on button, that hides OSMap end osm = b:option(OpenStreetMapLonLat, "latlon", translate("Find your coordinates with OpenStreetMap"), translate("Select your location with a mouse click on the map. The map will only show up if you are connected to the Internet.")) osm.latfield = "latitude" osm.lonfield = "longitude" osm.centerlat = uci:get_first("system", "system", "latitude") or deflat osm.centerlon = uci:get_first("system", "system", "longitude") or deflon osm.zoom = zoom osm.width = "100%" osm.height = "600" osm.popup = false osm.displaytext=translate("Show OpenStreetMap") osm.hidetext=translate("Hide OpenStreetMap") return m, n
apache-2.0
Arashbrsh/kings-BOT
plugins/media.lua
376
1679
do local function run(msg, matches) local receiver = get_receiver(msg) local url = matches[1] local ext = matches[2] local file = download_to_file(url) local cb_extra = {file_path=file} local mime_type = mimetype.get_content_type_no_sub(ext) if ext == 'gif' then print('send_file') send_document(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'text' then print('send_document') send_document(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'image' then print('send_photo') send_photo(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'audio' then print('send_audio') send_audio(receiver, file, rmtmp_cb, cb_extra) elseif mime_type == 'video' then print('send_video') send_video(receiver, file, rmtmp_cb, cb_extra) else print('send_file') send_file(receiver, file, rmtmp_cb, cb_extra) end end return { description = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.", usage = "When user sends media URL (ends with gif, mp4, pdf, etc.) download and send it to origin.", patterns = { "(https?://[%w-_%.%?%.:/%+=&]+%.(gif))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(mp4))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(pdf))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(ogg))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(zip))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(mp3))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(rar))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(wmv))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(doc))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(avi))$", "(https?://[%w-_%.%?%.:/%+=&]+%.(webp))$" }, run = run } end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c48783998.lua
6
1896
--コーリング・ノヴァ function c48783998.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(48783998,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_BATTLE_DESTROYED) e1:SetCondition(c48783998.condition) e1:SetTarget(c48783998.target) e1:SetOperation(c48783998.operation) c:RegisterEffect(e1) end function c48783998.condition(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE) end function c48783998.filter1(c,e,tp) return c:IsAttackBelow(1500) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_FAIRY) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c48783998.filter2(c,e,tp) return (c:IsCode(18036057) or (c:IsAttackBelow(1500) and c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_FAIRY))) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c48783998.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return false end if not Duel.IsEnvironment(56433456) then return Duel.IsExistingMatchingCard(c48783998.filter1,tp,LOCATION_DECK,0,1,nil,e,tp) else return Duel.IsExistingMatchingCard(c48783998.filter2,tp,LOCATION_DECK,0,1,nil,e,tp) end end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function c48783998.operation(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local g=nil Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) if not Duel.IsEnvironment(56433456) then g=Duel.SelectMatchingCard(tp,c48783998.filter1,tp,LOCATION_DECK,0,1,1,nil,e,tp) else g=Duel.SelectMatchingCard(tp,c48783998.filter2,tp,LOCATION_DECK,0,1,1,nil,e,tp) end if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
zxcwe/uhf
plugins/banhammer.lua
1
11663
local function pre_process(msg) if msg.action and msg.action.type then local action = msg.action.type -- Check if banned user joins chat by link if action == 'chat_add_user_link' then local user_id = msg.from.id local banned = is_banned(user_id, msg.to.id) if banned or is_gbanned(user_id) then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] is banned and kicked ! ")-- Save to logs kick_user(user_id, msg.to.id) end end -- Check if banned user joins chat if action == 'chat_add_user' then local user_id = msg.action.user.id local banned = is_banned(user_id, msg.to.id) if banned or is_gbanned(user_id) then -- Check it with redis local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] added a banned user >"..msg.action.user.id) kick_user(user_id, msg.to.id) local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id redis:incr(banhash) local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id local banaddredis = redis:get(banhash) if banaddredis then if tonumber(banaddredis) == 2 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id)-- Kick user who adds ban ppl more than 3 times end if tonumber(banaddredis) == 3 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) kick_user(user_id, msg.to.id) -- Kick user who adds ban ppl more than 7 times local banhash = 'addedbanuser:'..msg.to.id..':'..msg.from.id redis:set(banhash, 0)-- Reset the Counter end end end local bots_protection = "Yes" local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] end if msg.action.user.username ~= nil then if string.sub(msg.action.user.username:lower(), -3) == 'bot' and not is_admin(msg) and bots_protection == "yes" then --- Will kick bots added by normal users local name = user_print_name(msg.from) kick_user(msg.action.user.id, msg.to.id) ban_user(msg.action.user.id, msg.to.id) end end end -- No further checks return msg end -- banned user is talking ! if msg.to.type == 'chat' then local data = load_data(_config.moderation.data) local group = msg.to.id local texttext = 'groups' if not data[tostring(texttext)][tostring(msg.to.id)] and not is_realm(msg) then -- Check if this group is one of my groups or not chat_del_user('chat#id'..msg.to.id,'user#id'..our_id,ok_cb,false) return end local user_id = msg.from.id local chat_id = msg.to.id local banned = is_banned(user_id, chat_id) if banned or is_gbanned(user_id) then -- Check it with redis print('Banned user talking!') local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] banned user is talking !")-- Save to logs kick_user(user_id, chat_id) msg.text = '' end end return msg end local function kick_ban_res(extra, success, result) --vardump(result) --vardump(extra) local member_id = result.id local user_id = member_id local member = result.username local chat_id = extra.chat_id local from_id = extra.from_id local get_cmd = extra.get_cmd local receiver = "chat#id"..chat_id if get_cmd == "kick" then if member_id == from_id then return send_large_msg(receiver, "You can't kick yourself") end if is_momod2(member_id, chat_id) and not is_admin2(sender) then return send_large_msg(receiver, "You can't kick mods/owner/admins") end return kick_user(member_id, chat_id) elseif get_cmd == 'ban' then if is_momod2(member_id, chat_id) and not is_admin2(sender) then return send_large_msg(receiver, "You can't ban mods/owner/admins") end send_large_msg(receiver, 'User @'..member..' ['..member_id..'] banned') return ban_user(member_id, chat_id) elseif get_cmd == 'unban' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] unbanned') local hash = 'banned:'..chat_id redis:srem(hash, member_id) return 'User '..user_id..' unbanned' elseif get_cmd == 'banall' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] globally banned') return banall_user(member_id, chat_id), kick_user(member_id, chat_id) elseif get_cmd == 'unbanall' then send_large_msg(receiver, 'User @'..member..' ['..member_id..'] un-globally banned') return unbanall_user(member_id, chat_id) end end local function run(msg, matches) if matches[1]:lower() == 'id' then if msg.to.type == "user" then return "Bot ID: "..msg.to.id.. "\n\nYour ID: "..msg.from.id end if type(msg.reply_id) ~= "nil" then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ") id = get_message(msg.reply_id,get_message_callback_id, false) elseif matches[1]:lower() == 'id' then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] used /id ") return "Group ID for " ..string.gsub(msg.to.print_name, "_", " ").. ":\n\n"..msg.to.id end end if matches[1]:lower() == 'kickme' then-- /kickme local receiver = get_receiver(msg) if msg.to.type == 'chat' then local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] left using kickme ")-- Save to logs chat_del_user("chat#id"..msg.to.id, "user#id"..msg.from.id, ok_cb, false) end end if not is_momod(msg) then -- Ignore normal users return end if matches[1]:lower() == "banlist" then -- Ban list ! local chat_id = msg.to.id if matches[2] and is_admin(msg) then chat_id = matches[2] end return ban_list(chat_id) end if matches[1]:lower() == 'ban' then-- /ban if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin(msg) then local msgr = get_message(msg.reply_id,ban_by_reply_admins, false) else msgr = get_message(msg.reply_id,ban_by_reply, false) end end local user_id = matches[2] local chat_id = msg.to.id if string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin(msg) and is_momod2(matches[2], msg.to.id) then return "you can't ban mods/owner/admins" end if tonumber(matches[2]) == tonumber(msg.from.id) then return "You can't ban your self !" end local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] baned user ".. matches[2]) ban_user(user_id, chat_id) else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'ban', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') res_user(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == 'unban' then -- /unban if type(msg.reply_id)~="nil" and is_momod(msg) then local msgr = get_message(msg.reply_id,unban_by_reply, false) end local user_id = matches[2] local chat_id = msg.to.id local targetuser = matches[2] if string.match(targetuser, '^%d+$') then local user_id = targetuser local hash = 'banned:'..chat_id redis:srem(hash, user_id) local name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] unbaned user ".. matches[2]) return 'User '..user_id..' unbanned' else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'unban', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') res_user(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == 'kick' then if type(msg.reply_id)~="nil" and is_momod(msg) then if is_admin(msg) then local msgr = get_message(msg.reply_id,Kick_by_reply_admins, false) else msgr = get_message(msg.reply_id,Kick_by_reply, false) end end if string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return end if not is_admin(msg) and is_momod2(matches[2], msg.to.id) then return "you can't kick mods/owner/admins" end if tonumber(matches[2]) == tonumber(msg.from.id) then return "You can't kick your self !" end local user_id = matches[2] local chat_id = msg.to.id name = user_print_name(msg.from) savelog(msg.to.id, name.." ["..msg.from.id.."] kicked user ".. matches[2]) kick_user(user_id, chat_id) else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'kick', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') res_user(username, kick_ban_res, cbres_extra) end end if not is_admin(msg) then return end if matches[1]:lower() == 'banall' then -- Global ban if type(msg.reply_id) ~="nil" and is_admin(msg) then return get_message(msg.reply_id,banall_by_reply, false) end local user_id = matches[2] local chat_id = msg.to.id local targetuser = matches[2] if string.match(targetuser, '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return false end banall_user(targetuser) return 'User ['..user_id..' ] globally banned' else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'banall', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') res_user(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == 'unbanall' then -- Global unban local user_id = matches[2] local chat_id = msg.to.id if string.match(matches[2], '^%d+$') then if tonumber(matches[2]) == tonumber(our_id) then return false end unbanall_user(user_id) return 'User ['..user_id..' ] removed from global ban list' else local cbres_extra = { chat_id = msg.to.id, get_cmd = 'unbanall', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') res_user(username, kick_ban_res, cbres_extra) end end if matches[1]:lower() == "gbanlist" then -- Global ban list return banall_list() end end return { patterns = { "^[!/]([Bb]anall) (.*)$", "^[!/]([Bb]anall)$", "^[!/]([Bb]anlist) (.*)$", "^[!/]([Bb]anlist)$", "^[!/]([Gg]banlist)$", "^[!/]([Bb]an) (.*)$", "^[!/]([Kk]ick)$", "^[!/]([Uu]nban) (.*)$", "^[!/]([Uu]nbanall) (.*)$", "^[!/]([Uu]nbanall)$", "^[!/]([Kk]ick) (.*)$", "^[!/]([Kk]ickme)$", "^[!/]([Bb]an)$", "^[!/]([Uu]nban)$", "^[!/]([Ii]d)$", "^([Bb]anall) (.*)$", "^([Bb]anall)$", "^([Bb]anlist) (.*)$", "^([Bb]anlist)$", "^([Gg]banlist)$", "^([Bb]an) (.*)$", "^([Kk]ick)$", "^([Uu]nban) (.*)$", "^([Uu]nbanall) (.*)$", "^([Uu]nbanall)$", "^([Kk]ick) (.*)$", "^([Kk]ickme)$", "^([Bb]an)$", "^([Uu]nban)$", "^([Ii]d)$", "^!!tgservice (.+)$" }, run = run, pre_process = pre_process }
gpl-2.0
zwhfly/openwrt-luci
libs/nixio/docsrc/nixio.File.lua
173
4457
--- Large File Object. -- Large file operations are supported up to 52 bits if the Lua number type is -- double (default). -- @cstyle instance module "nixio.File" --- Write to the file descriptor. -- @class function -- @name File.write -- @usage <strong>Warning:</strong> It is not guaranteed that all data -- in the buffer is written at once especially when dealing with pipes. -- You have to check the return value - the number of bytes actually written - -- or use the safe IO functions in the high-level IO utility module. -- @usage Unlike standard Lua indexing the lowest offset and default is 0. -- @param buffer Buffer holding the data to be written. -- @param offset Offset to start reading the buffer from. (optional) -- @param length Length of chunk to read from the buffer. (optional) -- @return number of bytes written --- Read from a file descriptor. -- @class function -- @name File.read -- @usage <strong>Warning:</strong> It is not guaranteed that all requested data -- is read at once especially when dealing with pipes. -- You have to check the return value - the length of the buffer actually read - -- or use the safe IO functions in the high-level IO utility module. -- @usage The length of the return buffer is limited by the (compile time) -- nixio buffersize which is <em>nixio.const.buffersize</em> (8192 by default). -- Any read request greater than that will be safely truncated to this value. -- @param length Amount of data to read (in Bytes). -- @return buffer containing data successfully read --- Reposition read / write offset of the file descriptor. -- The seek will be done either from the beginning of the file or relative -- to the current position or relative to the end. -- @class function -- @name File.seek -- @usage This function calls lseek(). -- @param offset File Offset -- @param whence Starting point [<strong>"set"</strong>, "cur", "end"] -- @return new (absolute) offset position --- Return the current read / write offset of the file descriptor. -- @class function -- @name File.tell -- @usage This function calls lseek() with offset 0 from the current position. -- @return offset position --- Synchronizes the file with the storage device. -- Returns when the file is successfully written to the disk. -- @class function -- @name File.sync -- @usage This function calls fsync() when data_only equals false -- otherwise fdatasync(), on Windows _commit() is used instead. -- @usage fdatasync() is only supported by Linux and Solaris. For other systems -- the <em>data_only</em> parameter is ignored and fsync() is always called. -- @param data_only Do not synchronize the metadata. (optional, boolean) -- @return true --- Apply or test a lock on the file. -- @class function -- @name File.lock -- @usage This function calls lockf() on POSIX and _locking() on Windows. -- @usage The "lock" command is blocking, "tlock" is non-blocking, -- "ulock" unlocks and "test" only tests for the lock. -- @usage The "test" command is not available on Windows. -- @usage Locks are by default advisory on POSIX, but mandatory on Windows. -- @param command Locking Command ["lock", "tlock", "ulock", "test"] -- @param length Amount of Bytes to lock from current offset (optional) -- @return true --- Get file status and attributes. -- @class function -- @name File.stat -- @param field Only return a specific field, not the whole table (optional) -- @usage This function calls fstat(). -- @return Table containing: <ul> -- <li>atime = Last access timestamp</li> -- <li>blksize = Blocksize (POSIX only)</li> -- <li>blocks = Blocks used (POSIX only)</li> -- <li>ctime = Creation timestamp</li> -- <li>dev = Device ID</li> -- <li>gid = Group ID</li> -- <li>ino = Inode</li> -- <li>modedec = Mode converted into a decimal number</li> -- <li>modestr = Mode as string as returned by `ls -l`</li> -- <li>mtime = Last modification timestamp</li> -- <li>nlink = Number of links</li> -- <li>rdev = Device ID (if special file)</li> -- <li>size = Size in bytes</li> -- <li>type = ["reg", "dir", "chr", "blk", "fifo", "lnk", "sock"]</li> -- <li>uid = User ID</li> -- </ul> --- Close the file descriptor. -- @class function -- @name File.close -- @return true --- Get the number of the filedescriptor. -- @class function -- @name File.fileno -- @return file descriptor number --- (POSIX) Set the blocking mode of the file descriptor. -- @class function -- @name File.setblocking -- @param blocking (boolean) -- @return true
apache-2.0
assassinboy208/eagleTG
plugins/ingroup.lua
371
44212
do -- Check Member local function check_member_autorealm(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Welcome to your new realm !') end end end local function check_member_realm_add(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Realm', settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes' } } save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = {} save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been added!') end end end function check_member_group(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'You have been promoted as the owner.') end end end local function check_member_modadd(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration data[tostring(msg.to.id)] = { group_type = 'Group', moderators = {}, set_owner = member_id , settings = { set_name = string.gsub(msg.to.print_name, '_', ' '), lock_name = 'yes', lock_photo = 'no', lock_member = 'no', flood = 'yes', } } save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = {} save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = msg.to.id save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group is added and you have been promoted as the owner ') end end end local function automodadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_group,{receiver=receiver, data=data, msg = msg}) end end local function autorealmadd(msg) local data = load_data(_config.moderation.data) if msg.action.type == 'chat_created' then receiver = get_receiver(msg) chat_info(receiver, check_member_autorealm,{receiver=receiver, data=data, msg = msg}) end end local function check_member_realmrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Realm configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local realms = 'realms' if not data[tostring(realms)] then data[tostring(realms)] = nil save_data(_config.moderation.data, data) end data[tostring(realms)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Realm has been removed!') end end end local function check_member_modrem(cb_extra, success, result) local receiver = cb_extra.receiver local data = cb_extra.data local msg = cb_extra.msg for k,v in pairs(result.members) do local member_id = v.id if member_id ~= our_id then -- Group configuration removal data[tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) local groups = 'groups' if not data[tostring(groups)] then data[tostring(groups)] = nil save_data(_config.moderation.data, data) end data[tostring(groups)][tostring(msg.to.id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, 'Group has been removed') end end end --End Check Member local function show_group_settingsmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data = load_data(_config.moderation.data) if data[tostring(msg.to.id)] then if data[tostring(msg.to.id)]['settings']['flood_msg_max'] then NUM_MSG_MAX = tonumber(data[tostring(msg.to.id)]['settings']['flood_msg_max']) print('custom'..NUM_MSG_MAX) else NUM_MSG_MAX = 5 end end local bots_protection = "Yes" if data[tostring(msg.to.id)]['settings']['lock_bots'] then bots_protection = data[tostring(msg.to.id)]['settings']['lock_bots'] end local leave_ban = "no" if data[tostring(msg.to.id)]['settings']['leave_ban'] then leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] end local settings = data[tostring(target)]['settings'] local text = "Group settings:\nLock group name : "..settings.lock_name.."\nLock group photo : "..settings.lock_photo.."\nLock group member : "..settings.lock_member.."\nLock group leave : "..leave_ban.."\nflood sensitivity : "..NUM_MSG_MAX.."\nBot protection : "..bots_protection--"\nPublic: "..public return text end local function set_descriptionmod(msg, data, target, about) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'description' data[tostring(target)][data_cat] = about save_data(_config.moderation.data, data) return 'Set group description to:\n'..about end local function get_description(msg, data) local data_cat = 'description' if not data[tostring(msg.to.id)][data_cat] then return 'No description available.' end local about = data[tostring(msg.to.id)][data_cat] local about = string.gsub(msg.to.print_name, "_", " ")..':\n\n'..about return 'About '..about end local function lock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'yes' then return 'Arabic is already locked' else data[tostring(target)]['settings']['lock_arabic'] = 'yes' save_data(_config.moderation.data, data) return 'Arabic has been locked' end end local function unlock_group_arabic(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_arabic_lock = data[tostring(target)]['settings']['lock_arabic'] if group_arabic_lock == 'no' then return 'Arabic is already unlocked' else data[tostring(target)]['settings']['lock_arabic'] = 'no' save_data(_config.moderation.data, data) return 'Arabic has been unlocked' end end local function lock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'yes' then return 'Bots protection is already enabled' else data[tostring(target)]['settings']['lock_bots'] = 'yes' save_data(_config.moderation.data, data) return 'Bots protection has been enabled' end end local function unlock_group_bots(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_bots_lock = data[tostring(target)]['settings']['lock_bots'] if group_bots_lock == 'no' then return 'Bots protection is already disabled' else data[tostring(target)]['settings']['lock_bots'] = 'no' save_data(_config.moderation.data, data) return 'Bots protection has been disabled' end end local function lock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'yes' then return 'Group name is already locked' else data[tostring(target)]['settings']['lock_name'] = 'yes' save_data(_config.moderation.data, data) rename_chat('chat#id'..target, group_name_set, ok_cb, false) return 'Group name has been locked' end end local function unlock_group_namemod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_name_set = data[tostring(target)]['settings']['set_name'] local group_name_lock = data[tostring(target)]['settings']['lock_name'] if group_name_lock == 'no' then return 'Group name is already unlocked' else data[tostring(target)]['settings']['lock_name'] = 'no' save_data(_config.moderation.data, data) return 'Group name has been unlocked' end end local function lock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'yes' then return 'Group flood is locked' else data[tostring(target)]['settings']['flood'] = 'yes' save_data(_config.moderation.data, data) return 'Group flood has been locked' end end local function unlock_group_floodmod(msg, data, target) if not is_owner(msg) then return "Only admins can do it for now" end local group_flood_lock = data[tostring(target)]['settings']['flood'] if group_flood_lock == 'no' then return 'Group flood is not locked' else data[tostring(target)]['settings']['flood'] = 'no' save_data(_config.moderation.data, data) return 'Group flood has been unlocked' end end local function lock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'yes' then return 'Group members are already locked' else data[tostring(target)]['settings']['lock_member'] = 'yes' save_data(_config.moderation.data, data) end return 'Group members has been locked' end local function unlock_group_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['lock_member'] if group_member_lock == 'no' then return 'Group members are not locked' else data[tostring(target)]['settings']['lock_member'] = 'no' save_data(_config.moderation.data, data) return 'Group members has been unlocked' end end local function set_public_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['public'] if group_member_lock == 'yes' then return 'Group is already public' else data[tostring(target)]['settings']['public'] = 'yes' save_data(_config.moderation.data, data) end return 'Group is now: public' end local function unset_public_membermod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_member_lock = data[tostring(target)]['settings']['public'] if group_member_lock == 'no' then return 'Group is not public' else data[tostring(target)]['settings']['public'] = 'no' save_data(_config.moderation.data, data) return 'Group is now: not public' end end local function lock_group_leave(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] if leave_ban == 'yes' then return 'Leaving users will be banned' else data[tostring(msg.to.id)]['settings']['leave_ban'] = 'yes' save_data(_config.moderation.data, data) end return 'Leaving users will be banned' end local function unlock_group_leave(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local leave_ban = data[tostring(msg.to.id)]['settings']['leave_ban'] if leave_ban == 'no' then return 'Leaving users will not be banned' else data[tostring(msg.to.id)]['settings']['leave_ban'] = 'no' save_data(_config.moderation.data, data) return 'Leaving users will not be banned' end end local function unlock_group_photomod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local group_photo_lock = data[tostring(target)]['settings']['lock_photo'] if group_photo_lock == 'no' then return 'Group photo is not locked' else data[tostring(target)]['settings']['lock_photo'] = 'no' save_data(_config.moderation.data, data) return 'Group photo has been unlocked' end end local function set_rulesmod(msg, data, target) if not is_momod(msg) then return "For moderators only!" end local data_cat = 'rules' data[tostring(target)][data_cat] = rules save_data(_config.moderation.data, data) return 'Set group rules to:\n'..rules end local function modadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_group(msg) then return 'Group is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modadd,{receiver=receiver, data=data, msg = msg}) end local function realmadd(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if is_realm(msg) then return 'Realm is already added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realm_add,{receiver=receiver, data=data, msg = msg}) end -- Global functions function modrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_group(msg) then return 'Group is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_modrem,{receiver=receiver, data=data, msg = msg}) end function realmrem(msg) -- superuser and admins only (because sudo are always has privilege) if not is_admin(msg) then return "You're not admin" end local data = load_data(_config.moderation.data) if not is_realm(msg) then return 'Realm is not added.' end receiver = get_receiver(msg) chat_info(receiver, check_member_realmrem,{receiver=receiver, data=data, msg = msg}) end local function get_rules(msg, data) local data_cat = 'rules' if not data[tostring(msg.to.id)][data_cat] then return 'No rules available.' end local rules = data[tostring(msg.to.id)][data_cat] local rules = 'Chat rules:\n'..rules return rules end local function set_group_photo(msg, success, result) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) if success then local file = 'data/photos/chat_photo_'..msg.to.id..'.jpg' print('File downloaded to:', result) os.rename(result, file) print('File moved to:', file) chat_set_photo (receiver, file, ok_cb, false) data[tostring(msg.to.id)]['settings']['set_photo'] = file save_data(_config.moderation.data, data) data[tostring(msg.to.id)]['settings']['lock_photo'] = 'yes' save_data(_config.moderation.data, data) send_large_msg(receiver, 'Photo saved!', ok_cb, false) else print('Error downloading: '..msg.id) send_large_msg(receiver, 'Failed, please try again!', ok_cb, false) end end local function promote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is already a moderator.') end data[group]['moderators'][tostring(member_id)] = member_username save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been promoted.') end local function promote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'.. msg.from.username else member_username = full_name end local member_id = msg.from.id if msg.to.type == 'chat' then return promote(get_receiver(msg), member_username, member_id) end end local function demote(receiver, member_username, member_id) local data = load_data(_config.moderation.data) local group = string.gsub(receiver, 'chat#id', '') if not data[group] then return send_large_msg(receiver, 'Group is not added.') end if not data[group]['moderators'][tostring(member_id)] then return send_large_msg(receiver, member_username..' is not a moderator.') end data[group]['moderators'][tostring(member_id)] = nil save_data(_config.moderation.data, data) return send_large_msg(receiver, member_username..' has been demoted.') end local function demote_by_reply(extra, success, result) local msg = result local full_name = (msg.from.first_name or '')..' '..(msg.from.last_name or '') if msg.from.username then member_username = '@'..msg.from.username else member_username = full_name end local member_id = msg.from.id if msg.to.type == 'chat' then return demote(get_receiver(msg), member_username, member_id) end end local function setowner_by_reply(extra, success, result) local msg = result local receiver = get_receiver(msg) local data = load_data(_config.moderation.data) local name_log = msg.from.print_name:gsub("_", " ") data[tostring(msg.to.id)]['set_owner'] = tostring(msg.from.id) save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] setted ["..msg.from.id.."] as owner") local text = msg.from.print_name:gsub("_", " ").." is the owner now" return send_large_msg(receiver, text) end local function promote_demote_res(extra, success, result) --vardump(result) --vardump(extra) local member_id = result.id local member_username = "@"..result.username local chat_id = extra.chat_id local mod_cmd = extra.mod_cmd local receiver = "chat#id"..chat_id if mod_cmd == 'promote' then return promote(receiver, member_username, member_id) elseif mod_cmd == 'demote' then return demote(receiver, member_username, member_id) end end local function modlist(msg) local data = load_data(_config.moderation.data) local groups = "groups" if not data[tostring(groups)][tostring(msg.to.id)] then return 'Group is not added.' end -- determine if table is empty if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local i = 1 local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do message = message ..i..' - '..v..' [' ..k.. '] \n' i = i + 1 end return message end local function callbackres(extra, success, result) --vardump(result) local user = result.id local name = string.gsub(result.print_name, "_", " ") local chat = 'chat#id'..extra.chatid send_large_msg(chat, user..'\n'..name) return user end local function help() local help_text = tostring(_config.help_text) return help_text end local function cleanmember(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user(v.id, result.id) end end local function killchat(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function killrealm(cb_extra, success, result) local receiver = cb_extra.receiver local chat_id = "chat#id"..result.id local chatname = result.print_name for k,v in pairs(result.members) do kick_user_any(v.id, result.id) end end local function user_msgs(user_id, chat_id) local user_info local uhash = 'user:'..user_id local user = redis:hgetall(uhash) local um_hash = 'msgs:'..user_id..':'..chat_id user_info = tonumber(redis:get(um_hash) or 0) return user_info end local function kick_zero(cb_extra, success, result) local chat_id = cb_extra.chat_id local chat = "chat#id"..chat_id local ci_user local re_user for k,v in pairs(result.members) do local si = false ci_user = v.id local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) for i = 1, #users do re_user = users[i] if tonumber(ci_user) == tonumber(re_user) then si = true end end if not si then if ci_user ~= our_id then if not is_momod2(ci_user, chat_id) then chat_del_user(chat, 'user#id'..ci_user, ok_cb, true) end end end end end local function kick_inactive(chat_id, num, receiver) local hash = 'chat:'..chat_id..':users' local users = redis:smembers(hash) -- Get user info for i = 1, #users do local user_id = users[i] local user_info = user_msgs(user_id, chat_id) local nmsg = user_info if tonumber(nmsg) < tonumber(num) then if not is_momod2(user_id, chat_id) then chat_del_user('chat#id'..chat_id, 'user#id'..user_id, ok_cb, true) end end end return chat_info(receiver, kick_zero, {chat_id = chat_id}) end local function run(msg, matches) local data = load_data(_config.moderation.data) local receiver = get_receiver(msg) local name_log = user_print_name(msg.from) local group = msg.to.id if msg.media then if msg.media.type == 'photo' and data[tostring(msg.to.id)]['settings']['set_photo'] == 'waiting' and is_chat_msg(msg) and is_momod(msg) then load_photo(msg.id, set_group_photo, msg) end end if matches[1] == 'add' and not matches[2] then if is_realm(msg) then return 'Error: Already a realm.' end print("group "..msg.to.print_name.."("..msg.to.id..") added") return modadd(msg) end if matches[1] == 'add' and matches[2] == 'realm' then if is_group(msg) then return 'Error: Already a group.' end print("group "..msg.to.print_name.."("..msg.to.id..") added as a realm") return realmadd(msg) end if matches[1] == 'rem' and not matches[2] then print("group "..msg.to.print_name.."("..msg.to.id..") removed") return modrem(msg) end if matches[1] == 'rem' and matches[2] == 'realm' then print("group "..msg.to.print_name.."("..msg.to.id..") removed as a realm") return realmrem(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "group" then return automodadd(msg) end if matches[1] == 'chat_created' and msg.from.id == 0 and group_type == "realm" then return autorealmadd(msg) end if msg.to.id and data[tostring(msg.to.id)] then local settings = data[tostring(msg.to.id)]['settings'] if matches[1] == 'chat_add_user' then if not msg.service then return "Are you trying to troll me?" end local group_member_lock = settings.lock_member local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id if group_member_lock == 'yes' and not is_owner2(msg.action.user.id, msg.to.id) then chat_del_user(chat, user, ok_cb, true) elseif group_member_lock == 'yes' and tonumber(msg.from.id) == tonumber(our_id) then return nil elseif group_member_lock == 'no' then return nil end end if matches[1] == 'chat_del_user' then if not msg.service then -- return "Are you trying to troll me?" end local user = 'user#id'..msg.action.user.id local chat = 'chat#id'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] deleted user "..user) end if matches[1] == 'chat_delete_photo' then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to deleted picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_change_photo' and msg.from.id ~= 0 then if not msg.service then return "Are you trying to troll me?" end local group_photo_lock = settings.lock_photo if group_photo_lock == 'yes' then local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:incr(picturehash) --- local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id local picprotectionredis = redis:get(picturehash) if picprotectionredis then if tonumber(picprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(picprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local picturehash = 'picture:changed:'..msg.to.id..':'..msg.from.id redis:set(picturehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change picture but failed ") chat_set_photo(receiver, settings.set_photo, ok_cb, false) elseif group_photo_lock == 'no' then return nil end end if matches[1] == 'chat_rename' then if not msg.service then return "Are you trying to troll me?" end local group_name_set = settings.set_name local group_name_lock = settings.lock_name local to_rename = 'chat#id'..msg.to.id if group_name_lock == 'yes' then if group_name_set ~= tostring(msg.to.print_name) then local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:incr(namehash) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id local nameprotectionredis = redis:get(namehash) if nameprotectionredis then if tonumber(nameprotectionredis) == 4 and not is_owner(msg) then kick_user(msg.from.id, msg.to.id) end if tonumber(nameprotectionredis) == 8 and not is_owner(msg) then ban_user(msg.from.id, msg.to.id) local namehash = 'name:changed:'..msg.to.id..':'..msg.from.id redis:set(namehash, 0) end end savelog(msg.to.id, name_log.." ["..msg.from.id.."] tried to change name but failed ") rename_chat(to_rename, group_name_set, ok_cb, false) end elseif group_name_lock == 'no' then return nil end end if matches[1] == 'setname' and is_momod(msg) then local new_name = string.gsub(matches[2], '_', ' ') data[tostring(msg.to.id)]['settings']['set_name'] = new_name save_data(_config.moderation.data, data) local group_name_set = data[tostring(msg.to.id)]['settings']['set_name'] local to_rename = 'chat#id'..msg.to.id rename_chat(to_rename, group_name_set, ok_cb, false) savelog(msg.to.id, "Group { "..msg.to.print_name.." } name changed to [ "..new_name.." ] by "..name_log.." ["..msg.from.id.."]") end if matches[1] == 'setphoto' and is_momod(msg) then data[tostring(msg.to.id)]['settings']['set_photo'] = 'waiting' save_data(_config.moderation.data, data) return 'Please send me new group photo now' end if matches[1] == 'promote' and not matches[2] then if not is_owner(msg) then return "Only the owner can prmote new moderators" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, promote_by_reply, false) end end if matches[1] == 'promote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner can promote" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] promoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'promote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return res_user(username, promote_demote_res, cbres_extra) end if matches[1] == 'demote' and not matches[2] then if not is_owner(msg) then return "Only the owner can demote moderators" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, demote_by_reply, false) end end if matches[1] == 'demote' and matches[2] then if not is_momod(msg) then return end if not is_owner(msg) then return "Only owner can demote" end if string.gsub(matches[2], "@", "") == msg.from.username and not is_owner(msg) then return "You can't demote yourself" end local member = matches[2] savelog(msg.to.id, name_log.." ["..msg.from.id.."] demoted @".. member) local cbres_extra = { chat_id = msg.to.id, mod_cmd = 'demote', from_id = msg.from.id } local username = matches[2] local username = string.gsub(matches[2], '@', '') return res_user(username, promote_demote_res, cbres_extra) end if matches[1] == 'modlist' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group modlist") return modlist(msg) end if matches[1] == 'about' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group description") return get_description(msg, data) end if matches[1] == 'rules' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group rules") return get_rules(msg, data) end if matches[1] == 'set' then if matches[2] == 'rules' then rules = matches[3] local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group rules to ["..matches[3].."]") return set_rulesmod(msg, data, target) end if matches[2] == 'about' then local data = load_data(_config.moderation.data) local target = msg.to.id local about = matches[3] savelog(msg.to.id, name_log.." ["..msg.from.id.."] has changed group description to ["..matches[3].."]") return set_descriptionmod(msg, data, target, about) end end if matches[1] == 'lock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked name ") return lock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked member ") return lock_group_membermod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked flood ") return lock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked arabic ") return lock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked bots ") return lock_group_bots(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] locked leaving ") return lock_group_leave(msg, data, target) end end if matches[1] == 'unlock' then local target = msg.to.id if matches[2] == 'name' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked name ") return unlock_group_namemod(msg, data, target) end if matches[2] == 'member' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked member ") return unlock_group_membermod(msg, data, target) end if matches[2] == 'photo' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked photo ") return unlock_group_photomod(msg, data, target) end if matches[2] == 'flood' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked flood ") return unlock_group_floodmod(msg, data, target) end if matches[2] == 'arabic' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked arabic ") return unlock_group_arabic(msg, data, target) end if matches[2] == 'bots' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked bots ") return unlock_group_bots(msg, data, target) end if matches[2] == 'leave' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] unlocked leaving ") return unlock_group_leave(msg, data, target) end end if matches[1] == 'settings' then local target = msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group settings ") return show_group_settingsmod(msg, data, target) end --[[if matches[1] == 'public' then local target = msg.to.id if matches[2] == 'yes' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: public") return set_public_membermod(msg, data, target) end if matches[2] == 'no' then savelog(msg.to.id, name_log.." ["..msg.from.id.."] set group to: not public") return unset_public_membermod(msg, data, target) end end]] if matches[1] == 'newlink' and not is_realm(msg) then if not is_momod(msg) then return "For moderators only!" end local function callback (extra , success, result) local receiver = 'chat#'..msg.to.id if success == 0 then return send_large_msg(receiver, '*Error: Invite link failed* \nReason: Not creator.') end send_large_msg(receiver, "Created a new link") data[tostring(msg.to.id)]['settings']['set_link'] = result save_data(_config.moderation.data, data) end local receiver = 'chat#'..msg.to.id savelog(msg.to.id, name_log.." ["..msg.from.id.."] revoked group link ") return export_chat_link(receiver, callback, true) end if matches[1] == 'link' then if not is_momod(msg) then return "For moderators only!" end local group_link = data[tostring(msg.to.id)]['settings']['set_link'] if not group_link then return "Create a link using /newlink first !" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] requested group link ["..group_link.."]") return "Group link:\n"..group_link end if matches[1] == 'setowner' and matches[2] then if not is_owner(msg) then return "For owner only!" end data[tostring(msg.to.id)]['set_owner'] = matches[2] save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set ["..matches[2].."] as owner") local text = matches[2].." added as owner" return text end if matches[1] == 'setowner' and not matches[2] then if not is_owner(msg) then return "only for the owner!" end if type(msg.reply_id)~="nil" then msgr = get_message(msg.reply_id, setowner_by_reply, false) end end if matches[1] == 'owner' then local group_owner = data[tostring(msg.to.id)]['set_owner'] local user_info = redis:hgetall('user:'..group_owner) if not group_owner then return "no owner,ask admins in support groups to set owner for your group" end savelog(msg.to.id, name_log.." ["..msg.from.id.."] used /owner") if user_info.username then return "Group onwer is @"..user_info.username.." ["..group_owner.."]" else return "Group owner is ["..group_owner..']' end end if matches[1] == 'setgpowner' then local receiver = "chat#id"..matches[2] if not is_admin(msg) then return "For admins only!" end data[tostring(matches[2])]['set_owner'] = matches[3] save_data(_config.moderation.data, data) local text = matches[3].." added as owner" send_large_msg(receiver, text) return end if matches[1] == 'setflood' then if not is_momod(msg) then return "For moderators only!" end if tonumber(matches[2]) < 5 or tonumber(matches[2]) > 20 then return "Wrong number,range is [5-20]" end local flood_max = matches[2] data[tostring(msg.to.id)]['settings']['flood_msg_max'] = flood_max save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] set flood to ["..matches[2].."]") return 'Group flood has been set to '..matches[2] end if matches[1] == 'clean' then if not is_owner(msg) then return "Only owner can clean" end if matches[2] == 'member' then if not is_owner(msg) then return "Only admins can clean members" end local receiver = get_receiver(msg) chat_info(receiver, cleanmember, {receiver=receiver}) end if matches[2] == 'modlist' then if next(data[tostring(msg.to.id)]['moderators']) == nil then --fix way return 'No moderator in this group.' end local message = '\nList of moderators for ' .. string.gsub(msg.to.print_name, '_', ' ') .. ':\n' for k,v in pairs(data[tostring(msg.to.id)]['moderators']) do data[tostring(msg.to.id)]['moderators'][tostring(k)] = nil save_data(_config.moderation.data, data) end savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned modlist") end if matches[2] == 'rules' then local data_cat = 'rules' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned rules") end if matches[2] == 'about' then local data_cat = 'description' data[tostring(msg.to.id)][data_cat] = nil save_data(_config.moderation.data, data) savelog(msg.to.id, name_log.." ["..msg.from.id.."] cleaned about") end end if matches[1] == 'kill' and matches[2] == 'chat' then if not is_admin(msg) then return nil end if not is_realm(msg) then local receiver = get_receiver(msg) return modrem(msg), print("Closing Group..."), chat_info(receiver, killchat, {receiver=receiver}) else return 'This is a realm' end end if matches[1] == 'kill' and matches[2] == 'realm' then if not is_admin(msg) then return nil end if not is_group(msg) then local receiver = get_receiver(msg) return realmrem(msg), print("Closing Realm..."), chat_info(receiver, killrealm, {receiver=receiver}) else return 'This is a group' end end if matches[1] == 'help' then if not is_momod(msg) or is_realm(msg) then return end savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /help") return help() end if matches[1] == 'res' and is_momod(msg) then local cbres_extra = { chatid = msg.to.id } local username = matches[2] local username = username:gsub("@","") savelog(msg.to.id, name_log.." ["..msg.from.id.."] Used /res "..username) return res_user(username, callbackres, cbres_extra) end if matches[1] == 'kickinactive' then --send_large_msg('chat#id'..msg.to.id, 'I\'m in matches[1]') if not is_momod(msg) then return 'Only a moderator can kick inactive users' end local num = 1 if matches[2] then num = matches[2] end local chat_id = msg.to.id local receiver = get_receiver(msg) return kick_inactive(chat_id, num, receiver) end end end return { patterns = { "^[!/](add)$", "^[!/](add) (realm)$", "^[!/](rem)$", "^[!/](rem) (realm)$", "^[!/](rules)$", "^[!/](about)$", "^[!/](setname) (.*)$", "^[!/](setphoto)$", "^[!/](promote) (.*)$", "^[!/](promote)", "^[!/](help)$", "^[!/](clean) (.*)$", "^[!/](kill) (chat)$", "^[!/](kill) (realm)$", "^[!/](demote) (.*)$", "^[!/](demote)", "^[!/](set) ([^%s]+) (.*)$", "^[!/](lock) (.*)$", "^[!/](setowner) (%d+)$", "^[!/](setowner)", "^[!/](owner)$", "^[!/](res) (.*)$", "^[!/](setgpowner) (%d+) (%d+)$",-- (group id) (owner id) "^[!/](unlock) (.*)$", "^[!/](setflood) (%d+)$", "^[!/](settings)$", -- "^[!/](public) (.*)$", "^[!/](modlist)$", "^[!/](newlink)$", "^[!/](link)$", "^[!/](kickinactive)$", "^[!/](kickinactive) (%d+)$", "%[(photo)%]", "^!!tgservice (.+)$", }, run = run } end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c20563387.lua
5
3415
--CNo.80 葬装覇王レクイエム・イン・バーサーク function c20563387.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,nil,5,3) c:EnableReviveLimit() --equip local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(20563387,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCategory(CATEGORY_EQUIP) e1:SetRange(LOCATION_MZONE) e1:SetTarget(c20563387.eqtg) e1:SetOperation(c20563387.eqop) c:RegisterEffect(e1) --remove local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(20563387,1)) e2:SetCategory(CATEGORY_REMOVE) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCondition(c20563387.rmcon) e2:SetCost(c20563387.rmcost) e2:SetTarget(c20563387.rmtg) e2:SetOperation(c20563387.rmop) c:RegisterEffect(e2) end c20563387.xyz_number=80 function c20563387.filter(c) return c:IsFaceup() and c:IsType(TYPE_XYZ) end function c20563387.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c20563387.filter(chkc) and chkc~=e:GetHandler() end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingTarget(c20563387.filter,tp,LOCATION_MZONE,0,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP) Duel.SelectTarget(tp,c20563387.filter,tp,LOCATION_MZONE,0,1,1,e:GetHandler()) end function c20563387.eqop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) or c:IsFacedown() then return end local tc=Duel.GetFirstTarget() if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 or tc:GetControler()~=tp or tc:IsFacedown() or not tc:IsRelateToEffect(e) then Duel.SendtoGrave(c,REASON_EFFECT) return end Duel.Equip(tp,c,tc,true) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EQUIP_LIMIT) e1:SetReset(RESET_EVENT+0x1fe0000) e1:SetValue(c20563387.eqlimit) e1:SetLabelObject(tc) c:RegisterEffect(e1) --atkup local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_EQUIP) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetValue(2000) e2:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e2) --destroy sub local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_EQUIP) e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e3:SetCode(EFFECT_DESTROY_SUBSTITUTE) e3:SetValue(1) e3:SetReset(RESET_EVENT+0x1fe0000) c:RegisterEffect(e3) end function c20563387.eqlimit(e,c) return c==e:GetLabelObject() end function c20563387.rmcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetOverlayGroup():IsExists(Card.IsCode,1,nil,93568288) end function c20563387.rmcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c20563387.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and chkc:IsAbleToRemove() end if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) end function c20563387.rmop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Remove(tc,POS_FACEUP,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c44481227.lua
3
2702
--EMラクダウン function c44481227.initial_effect(c) --pendulum summon aux.AddPendulumProcedure(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) -- local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_PZONE) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCountLimit(1) e2:SetCondition(c44481227.condition) e2:SetTarget(c44481227.target) e2:SetOperation(c44481227.operation) c:RegisterEffect(e2) --atk down local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_ATKCHANGE) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_BATTLE_DESTROYED) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetCondition(c44481227.atkcon) e3:SetOperation(c44481227.atkop) c:RegisterEffect(e3) end function c44481227.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.IsAbleToEnterBP() end function c44481227.filter(c) return c:IsFaceup() and not c:IsHasEffect(EFFECT_PIERCE) end function c44481227.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c44481227.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c44481227.filter,tp,LOCATION_MZONE,0,1,nil) and Duel.IsExistingMatchingCard(Card.IsFaceup,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,c44481227.filter,tp,LOCATION_MZONE,0,1,1,nil) end function c44481227.operation(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local tc=Duel.GetFirstTarget() local g=Duel.GetMatchingGroup(Card.IsFaceup,tp,0,LOCATION_MZONE,nil) if g:GetCount()==0 then return end local gc=g:GetFirst() while gc do local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_DEFENCE) e1:SetValue(-800) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END) gc:RegisterEffect(e1) gc=g:GetNext() end if tc:IsRelateToEffect(e) then local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_PIERCE) e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END) tc:RegisterEffect(e2) end end function c44481227.atkcon(e,tp,eg,ep,ev,re,r,rp) local rc=e:GetHandler():GetReasonCard() return rc:IsRelateToBattle() end function c44481227.atkop(e,tp,eg,ep,ev,re,r,rp) local rc=e:GetHandler():GetReasonCard() if rc:IsRelateToBattle() then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(-800) e1:SetReset(RESET_EVENT+0x1fe0000) rc:RegisterEffect(e1) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c35329581.lua
5
1878
--シャドー・インパルス function c35329581.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_TO_GRAVE) e1:SetCountLimit(1,35329581+EFFECT_COUNT_CODE_OATH) e1:SetTarget(c35329581.target) e1:SetOperation(c35329581.activate) c:RegisterEffect(e1) end function c35329581.filter(c,e,tp) return c:IsLocation(LOCATION_GRAVE) and c:IsCanBeEffectTarget(e) and c:GetPreviousControler()==tp and c:IsReason(REASON_DESTROY) and c:IsReason(REASON_BATTLE+REASON_EFFECT) and c:IsType(TYPE_SYNCHRO) and Duel.IsExistingMatchingCard(c35329581.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,c) end function c35329581.spfilter(c,e,tp,tc) return c:IsType(TYPE_SYNCHRO) and c:GetLevel()==tc:GetLevel() and c:GetRace()==tc:GetRace() and c:GetCode()~=tc:GetCode() and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c35329581.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return eg:IsContains(chkc) and c35329581.filter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and eg:IsExists(c35329581.filter,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=eg:FilterSelect(tp,c35329581.filter,1,1,nil,e,tp) Duel.SetTargetCard(g) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c35329581.activate(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local tc=Duel.GetFirstTarget() if not tc:IsRelateToEffect(e) or tc:IsFacedown() then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=Duel.SelectMatchingCard(tp,c35329581.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc) if sg:GetCount()>0 then Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
madmanteam/vlc
share/lua/modules/common.lua
54
4986
--[[ This code is public domain (since it really isn't very interesting) ]]-- module("common",package.seeall) -- Iterate over a table in the keys' alphabetical order function pairs_sorted(t) local s = {} for k,_ in pairs(t) do table.insert(s,k) end table.sort(s) local i = 0 return function () i = i + 1; return s[i], t[s[i]] end end -- Return a function such as skip(foo)(a,b,c) = foo(b,c) function skip(foo) return function(discard,...) return foo(...) end end -- Return a function such as setarg(foo,a)(b,c) = foo(a,b,c) function setarg(foo,a) return function(...) return foo(a,...) end end -- Trigger a hotkey function hotkey(arg) local id = vlc.misc.action_id( arg ) if id ~= nil then vlc.var.set( vlc.object.libvlc(), "key-action", id ) return true else return false end end -- Take a video snapshot function snapshot() local vout = vlc.object.vout() if not vout then return end vlc.var.set(vout,"video-snapshot",nil) end -- Naive (non recursive) table copy function table_copy(t) c = {} for i,v in pairs(t) do c[i]=v end return c end -- tonumber() for decimals number, using a dot as decimal separator -- regardless of the system locale function us_tonumber(str) local s, i, d = string.match(str, "^([+-]?)(%d*)%.?(%d*)$") if not s or not i or not d then return nil end if s == "-" then s = -1 else s = 1 end if i == "" then i = "0" end if d == nil or d == "" then d = "0" end return s * (tonumber(i) + tonumber(d)/(10^string.len(d))) end -- tostring() for decimals number, using a dot as decimal separator -- regardless of the system locale function us_tostring(n) s = tostring(n):gsub(",", ".", 1) return s end -- strip leading and trailing spaces function strip(str) return string.gsub(str, "^%s*(.-)%s*$", "%1") end -- print a table (recursively) function table_print(t,prefix) local prefix = prefix or "" if not t then print(prefix.."/!\\ nil") return end for a,b in pairs_sorted(t) do print(prefix..tostring(a),b) if type(b)==type({}) then table_print(b,prefix.."\t") end end end -- print the list of callbacks registered in lua -- useful for debug purposes function print_callbacks() print "callbacks:" table_print(vlc.callbacks) end -- convert a duration (in seconds) to a string function durationtostring(duration) return string.format("%02d:%02d:%02d", math.floor(duration/3600), math.floor(duration/60)%60, math.floor(duration%60)) end -- realpath function realpath(path) return string.gsub(string.gsub(string.gsub(string.gsub(path,"/%.%./[^/]+","/"),"/[^/]+/%.%./","/"),"/%./","/"),"//","/") end -- parse the time from a string and return the seconds -- time format: [+ or -][<int><H or h>:][<int><M or m or '>:][<int><nothing or S or s or ">] function parsetime(timestring) local seconds = 0 local hourspattern = "(%d+)[hH]" local minutespattern = "(%d+)[mM']" local secondspattern = "(%d+)[sS\"]?$" local _, _, hoursmatch = string.find(timestring, hourspattern) if hoursmatch ~= nil then seconds = seconds + tonumber(hoursmatch) * 3600 end local _, _, minutesmatch = string.find(timestring, minutespattern) if minutesmatch ~= nil then seconds = seconds + tonumber(minutesmatch) * 60 end local _, _, secondsmatch = string.find(timestring, secondspattern) if secondsmatch ~= nil then seconds = seconds + tonumber(secondsmatch) end if string.sub(timestring,1,1) == "-" then seconds = seconds * -1 end return seconds end -- seek function seek(value) local input = vlc.object.input() if input ~= nil and value ~= nil then if string.sub(value,-1) == "%" then local number = us_tonumber(string.sub(value,1,-2)) if number ~= nil then local posPercent = number/100 if string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then vlc.var.set(input,"position",vlc.var.get(input,"position") + posPercent) else vlc.var.set(input,"position",posPercent) end end else local posTime = parsetime(value) if string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then vlc.var.set(input,"time",vlc.var.get(input,"time") + (posTime * 1000000)) else vlc.var.set(input,"time",posTime * 1000000) end end end end function volume(value) if type(value)=="string" and string.sub(value,1,1) == "+" or string.sub(value,1,1) == "-" then vlc.volume.set(vlc.volume.get()+tonumber(value)) else vlc.volume.set(tostring(value)) end end
gpl-2.0
zhaoxin54430/zhaoxin_test
src_luci/applications/luci-app-pbx/luasrc/model/cbi/pbx.lua
146
4360
--[[ Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com> This file is part of luci-pbx. luci-pbx is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. luci-pbx is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with luci-pbx. If not, see <http://www.gnu.org/licenses/>. ]]-- modulename = "pbx" if nixio.fs.access("/etc/init.d/asterisk") then server = "asterisk" elseif nixio.fs.access("/etc/init.d/freeswitch") then server = "freeswitch" else server = "" end -- Returns formatted output of string containing only the words at the indices -- specified in the table "indices". function format_indices(string, indices) if indices == nil then return "Error: No indices to format specified.\n" end -- Split input into separate lines. lines = luci.util.split(luci.util.trim(string), "\n") -- Split lines into separate words. splitlines = {} for lpos,line in ipairs(lines) do splitlines[lpos] = luci.util.split(luci.util.trim(line), "%s+", nil, true) end -- For each split line, if the word at all indices specified -- to be formatted are not null, add the formatted line to the -- gathered output. output = "" for lpos,splitline in ipairs(splitlines) do loutput = "" for ipos,index in ipairs(indices) do if splitline[index] ~= nil then loutput = loutput .. string.format("%-40s", splitline[index]) else loutput = nil break end end if loutput ~= nil then output = output .. loutput .. "\n" end end return output end m = Map (modulename, translate("PBX Main Page"), translate("This configuration page allows you to configure a phone system (PBX) service which \ permits making phone calls through multiple Google and SIP (like Sipgate, \ SipSorcery, and Betamax) accounts and sharing them among many SIP devices. \ Note that Google accounts, SIP accounts, and local user accounts are configured in the \ \"Google Accounts\", \"SIP Accounts\", and \"User Accounts\" sub-sections. \ You must add at least one User Account to this PBX, and then configure a SIP device or \ softphone to use the account, in order to make and receive calls with your Google/SIP \ accounts. Configuring multiple users will allow you to make free calls between all users, \ and share the configured Google and SIP accounts. If you have more than one Google and SIP \ accounts set up, you should probably configure how calls to and from them are routed in \ the \"Call Routing\" page. If you're interested in using your own PBX from anywhere in the \ world, then visit the \"Remote Usage\" section in the \"Advanced Settings\" page.")) ----------------------------------------------------------------------------------------- s = m:section(NamedSection, "connection_status", "main", translate("PBX Service Status")) s.anonymous = true s:option (DummyValue, "status", translate("Service Status")) sts = s:option(DummyValue, "_sts") sts.template = "cbi/tvalue" sts.rows = 20 function sts.cfgvalue(self, section) if server == "asterisk" then regs = luci.sys.exec("asterisk -rx 'sip show registry' | sed 's/peer-//'") jabs = luci.sys.exec("asterisk -rx 'jabber show connections' | grep onnected") usrs = luci.sys.exec("asterisk -rx 'sip show users'") chan = luci.sys.exec("asterisk -rx 'core show channels'") return format_indices(regs, {1, 5}) .. format_indices(jabs, {2, 4}) .. "\n" .. format_indices(usrs, {1} ) .. "\n" .. chan elseif server == "freeswitch" then return "Freeswitch is not supported yet.\n" else return "Neither Asterisk nor FreeSwitch discovered, please install Asterisk, as Freeswitch is not supported yet.\n" end end return m
gpl-2.0
zwhfly/openwrt-luci
protocols/ppp/luasrc/model/cbi/admin_network/proto_pptp.lua
59
3379
--[[ LuCI - Lua Configuration Interface Copyright 2011-2012 Jo-Philipp Wich <xm@subsignal.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]]-- local map, section, net = ... local server, username, password local defaultroute, metric, peerdns, dns, keepalive_failure, keepalive_interval, demand, mtu server = section:taboption("general", Value, "server", translate("VPN Server")) server.datatype = "host" username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) password.password = true defaultroute = section:taboption("advanced", Flag, "defaultroute", translate("Use default gateway"), translate("If unchecked, no default route is configured")) defaultroute.default = defaultroute.enabled metric = section:taboption("advanced", Value, "metric", translate("Use gateway metric")) metric.placeholder = "0" metric.datatype = "uinteger" metric:depends("defaultroute", defaultroute.enabled) peerdns = section:taboption("advanced", Flag, "peerdns", translate("Use DNS servers advertised by peer"), translate("If unchecked, the advertised DNS server addresses are ignored")) peerdns.default = peerdns.enabled dns = section:taboption("advanced", DynamicList, "dns", translate("Use custom DNS servers")) dns:depends("peerdns", "") dns.datatype = "ipaddr" dns.cast = "string" keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", translate("LCP echo failure threshold"), translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) function keepalive_failure.cfgvalue(self, section) local v = m:get(section, "keepalive") if v and #v > 0 then return tonumber(v:match("^(%d+)[ ,]+%d+") or v) end end function keepalive_failure.write() end function keepalive_failure.remove() end keepalive_failure.placeholder = "0" keepalive_failure.datatype = "uinteger" keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", translate("LCP echo interval"), translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) function keepalive_interval.cfgvalue(self, section) local v = m:get(section, "keepalive") if v and #v > 0 then return tonumber(v:match("^%d+[ ,]+(%d+)")) end end function keepalive_interval.write(self, section, value) local f = tonumber(keepalive_failure:formvalue(section)) or 0 local i = tonumber(value) or 5 if i < 1 then i = 1 end if f > 0 then m:set(section, "keepalive", "%d %d" %{ f, i }) else m:del(section, "keepalive") end end keepalive_interval.remove = keepalive_interval.write keepalive_interval.placeholder = "5" keepalive_interval.datatype = "min(1)" demand = section:taboption("advanced", Value, "demand", translate("Inactivity timeout"), translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) demand.placeholder = "0" demand.datatype = "uinteger" mtu = section:taboption("advanced", Value, "mtu", translate("Override MTU")) mtu.placeholder = "1500" mtu.datatype = "max(9200)"
apache-2.0
anshkumar/yugioh-glaze
assets/script/c36523152.lua
7
1636
--超重武者ビッグワラ-G function c36523152.initial_effect(c) --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetValue(1) e1:SetCondition(c36523152.spcon) c:RegisterEffect(e1) --spsummon limit local e2=Effect.CreateEffect(c) e2:SetProperty(EFFECT_FLAG_UNCOPYABLE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetCondition(c36523152.limcon) e2:SetOperation(c36523152.limop) c:RegisterEffect(e2) --double tribute local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_DOUBLE_TRIBUTE) e3:SetValue(c36523152.condition) c:RegisterEffect(e3) end function c36523152.spcon(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and not Duel.IsExistingMatchingCard(Card.IsType,tp,LOCATION_GRAVE,0,1,nil,TYPE_SPELL+TYPE_TRAP) end function c36523152.limcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetSummonType()==SUMMON_TYPE_SPECIAL+1 end function c36523152.limop(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetTarget(c36523152.splimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c36523152.splimit(e,c,sump,sumtype,sumpos,targetp,se) return not c:IsSetCard(0x9a) end function c36523152.condition(e,c) return c:IsRace(RACE_MACHINE) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c22201234.lua
5
2139
--ライトロード・バリア function c22201234.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c22201234.atg) e1:SetOperation(c22201234.aop) c:RegisterEffect(e1) --quick local e2=Effect.CreateEffect(c) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetDescription(aux.Stringid(22201234,1)) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetRange(LOCATION_SZONE) e2:SetCode(EVENT_BE_BATTLE_TARGET) e2:SetCondition(c22201234.qcon) e2:SetCost(c22201234.qcost) e2:SetTarget(c22201234.qtg) e2:SetOperation(c22201234.qop) c:RegisterEffect(e2) end function c22201234.atg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc==Duel.GetAttacker() end if chk==0 then return true end if Duel.CheckEvent(EVENT_BE_BATTLE_TARGET) then local a=Duel.GetAttacker() local d=Duel.GetAttackTarget() if d:IsFaceup() and d:IsSetCard(0x38) and d:IsControler(tp) and Duel.IsPlayerCanDiscardDeckAsCost(tp,2) and a:IsOnField() and a:IsCanBeEffectTarget(e) and Duel.SelectYesNo(tp,aux.Stringid(22201234,0)) then e:SetProperty(EFFECT_FLAG_CARD_TARGET) e:SetLabel(1) Duel.DiscardDeck(tp,2,REASON_COST) Duel.SetTargetCard(a) end else e:SetProperty(0) e:SetLabel(0) end end function c22201234.aop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end if e:GetLabel()==1 then Duel.NegateAttack() end end function c22201234.qcon(e,tp,eg,ep,ev,re,r,rp) local d=Duel.GetAttackTarget() return d:IsFaceup() and d:IsSetCard(0x38) and d:IsControler(tp) and not e:GetHandler():IsStatus(STATUS_CHAINING) end function c22201234.qcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDiscardDeckAsCost(tp,2) end Duel.DiscardDeck(tp,2,REASON_COST) end function c22201234.qtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local tg=Duel.GetAttacker() if chkc then return chkc==tg end if chk==0 then return tg:IsOnField() and tg:IsCanBeEffectTarget(e) end Duel.SetTargetCard(tg) end function c22201234.qop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.NegateAttack() end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c35011819.lua
3
2470
--エンペラー・オーダー function c35011819.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c35011819.target1) e1:SetOperation(c35011819.activate1) c:RegisterEffect(e1) --instant local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(35011819,0)) e2:SetCategory(CATEGORY_NEGATE+CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetRange(LOCATION_SZONE) e2:SetCode(EVENT_CHAINING) e2:SetCondition(c35011819.condition2) e2:SetTarget(c35011819.target2) e2:SetOperation(c35011819.activate2) c:RegisterEffect(e2) end function c35011819.target1(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end e:SetLabel(0) local ct=Duel.GetCurrentChain() if ct==1 then return end local ct=Duel.GetCurrentChain() local te=Duel.GetChainInfo(ct-1,CHAININFO_TRIGGERING_EFFECT) local tc=te:GetHandler() if te:GetCode()==EVENT_SUMMON_SUCCESS and te:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ct-1) and Duel.IsPlayerCanDraw(tc:GetControler(),1) and Duel.SelectYesNo(tp,aux.Stringid(35011819,1)) then e:SetLabel(1) Duel.SetOperationInfo(0,CATEGORY_NEGATE,tc,1,0,0) Duel.SetTargetPlayer(tc:GetControler()) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tc:GetControler(),1) e:GetHandler():RegisterFlagEffect(0,RESET_CHAIN,EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(35011819,2)) end end function c35011819.activate1(e,tp,eg,ep,ev,re,r,rp) if e:GetLabel()~=1 then return end local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end local ct=Duel.GetChainInfo(0,CHAININFO_CHAIN_COUNT) Duel.NegateActivation(ct-1) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c35011819.condition2(e,tp,eg,ep,ev,re,r,rp) return re:IsActiveType(TYPE_MONSTER) and re:GetCode()==EVENT_SUMMON_SUCCESS and Duel.IsChainNegatable(ev) end function c35011819.target2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(rp,1) end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) Duel.SetTargetPlayer(rp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,rp,1) end function c35011819.activate2(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.NegateActivation(ev) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c65196094.lua
3
2723
--バラエティ・アウト function c65196094.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCost(c65196094.cost) e1:SetTarget(c65196094.target) e1:SetOperation(c65196094.activate) c:RegisterEffect(e1) Duel.AddCustomActivityCounter(65196094,ACTIVITY_SPSUMMON,c65196094.counterfilter) end function c65196094.counterfilter(c) return c:GetSummonType()~=SUMMON_TYPE_SYNCHRO end function c65196094.cost(e,tp,eg,ep,ev,re,r,rp,chk) e:SetLabel(1) if chk==0 then return Duel.GetCustomActivityCount(65196094,tp,ACTIVITY_SPSUMMON)==0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetTargetRange(1,0) e1:SetTarget(c65196094.splimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c65196094.splimit(e,c,tp,sumtp,sumpos) return bit.band(sumtp,SUMMON_TYPE_SYNCHRO)==SUMMON_TYPE_SYNCHRO end function c65196094.cfilter(c,e,tp,g,maxc) return c:IsFaceup() and c:IsType(TYPE_SYNCHRO) and c:IsAbleToExtraAsCost() and g:CheckWithSumEqual(Card.GetLevel,c:GetLevel(),1,maxc) end function c65196094.spfilter(c,e,tp) return c:IsType(TYPE_TUNER) and c:IsCanBeEffectTarget(e) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c65196094.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if chk==0 then if e:GetLabel()==0 then return false end e:SetLabel(0) if ft<0 then return end local spg=Duel.GetMatchingGroup(c65196094.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp) return Duel.IsExistingMatchingCard(c65196094.cfilter,tp,LOCATION_MZONE,0,1,nil,e,tp,spg,ft+1) end e:SetLabel(0) local spg=Duel.GetMatchingGroup(c65196094.spfilter,tp,LOCATION_GRAVE,0,nil,e,tp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local cg=Duel.SelectMatchingCard(tp,c65196094.cfilter,tp,LOCATION_MZONE,0,1,1,nil,e,tp,spg,ft+1) local lv=cg:GetFirst():GetLevel() Duel.SendtoDeck(cg,nil,0,REASON_COST) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=spg:SelectWithSumEqual(tp,Card.GetLevel,lv,1,ft+1) Duel.SetTargetCard(sg) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,sg,sg:GetCount(),0,0) end function c65196094.activate(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if g:GetCount()==0 or g:GetCount()>Duel.GetLocationCount(tp,LOCATION_MZONE) then return end Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end
gpl-2.0
adan830/UpAndAway
wicker/kernel_extensions/dst_abstraction/rpc/fake_singleplayer_rpcs.lua
6
1361
if IsWorldgen() then return {} end assert(IsSingleplayer(), "fake_singleplayer_rpcs.lua should only be loaded in singleplayer!") local rpcs = {} function rpcs.EquipActiveItem(player) local inv = player.components.inventory if not inv then return end local active_item = inv:GetActiveItem() if active_item ~= nil and active_item.components.equippable ~= nil and inv:GetEquippedItem(active_item.components.equippable.equipslot) == nil then inv:Equip(active_item, true) end end function rpcs.EquipActionItem(player) local inv = player.components.inventory if not inv then return end local active_item = inv:GetActiveItem() if active_item ~= nil and active_item.components.equippable ~= nil and active_item.components.equippable.equipslot == _G.EQUIPSLOTS.HANDS then inv:Equip(active_item) if inv:GetActiveItem() == active_item then inv:SetActiveItem() end end end -- Here action is the actual Action object. -- Consistency is kept by changing the multiplayer interface as well. function rpcs.DoWidgetButtonAction(player, action, target) if action == nil then return end local container = (target ~= nil and target.components.container or nil) if container == nil or container.opener == player then _G.BufferedAction(player, target, action):Do() end end return rpcs
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c69764158.lua
3
1471
--ペロペロケルペロス function c69764158.initial_effect(c) --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(69764158,0)) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_DAMAGE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetRange(LOCATION_GRAVE) e1:SetCountLimit(1) e1:SetCondition(c69764158.descon) e1:SetCost(c69764158.descost) e1:SetTarget(c69764158.destg) e1:SetOperation(c69764158.desop) c:RegisterEffect(e1) end function c69764158.descon(e,tp,eg,ep,ev,re,r,rp) return ep==tp and (bit.band(r,REASON_BATTLE)~=0 or (bit.band(r,REASON_EFFECT)~=0 and rp~=tp)) end function c69764158.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c69764158.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsOnField() and chkc:IsDestructable() end if chk==0 then return Duel.IsExistingTarget(Card.IsDestructable,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,Card.IsDestructable,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c69764158.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end
gpl-2.0
Ced-le-pingouin/microlua-sim
clp/mls/ModuleManager.lua
2
10334
------------------------------------------------------------------------------- -- Loads, initializes, and resets simulated µLua modules, such as screen, Font, -- etc. -- -- @class module -- @name clp.mls.ModuleManager -- @author Ced-le-pingouin <Ced.le.pingouin@gmail.com> -- ------------------------------------------------------------------------------- -- Copyright (C) 2009-2011 Cédric FLOQUET -- -- This file is part of Micro Lua DS Simulator. -- -- Micro Lua DS Simulator is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- Micro Lua DS Simulator is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with Micro Lua DS Simulator. If not, see <http://www.gnu.org/licenses/>. local Class = require "clp.Class" local M = Class.new() --- Constructor. -- -- @param moduleNames (table) A list of module names (string), in the order in -- which they should be loaded. Optional, because -- there's a default list/order -- @param prefixes (table) A list of prefixes that should be used when trying -- to load/register modules. By default, it's "wx." -- -- @param emulateLibs (boolean) If true, "external" modules of uLua, which were -- in fact provided by the default shell, will be -- emulated as if the shell was present. If false, -- only the "internal" uLua modules (written in C) -- are available. Please note that internal or -- emulated modules sometimes have a different -- name (e.g. ds_controls for internal version, -- Controls for emulated version) function M:ctr(moduleNames, prefixes, emulateLibs) self._moduleNames = moduleNames or { -- MUST be loaded first because other modules depend on it! "screen", "Color", "Image", "Font", -- from here the order doesn't matter "Canvas", "ds_controls", "DateTime", "Debug", "INI", "Keyboard", "Map", "Mod", "Motion", "Rumble", "ScrollMap", "Sound", "Sprite", "ds_system", "Timer", "Wifi" } self._emulatedModules = { ds_controls = "Controls", Timer = true, Debug = true, ds_system = "System", DateTime = true, Sprite = true, INI = true, Keyboard = true } -- this table will contain the moduleName/module pairs, module being the -- *address* of the module "object" self._modules = {} -- prefixes used to load modules. These are tried first, then unprefixed self._prefixes = prefixes or { "wx." } -- if MLS is to emulate libs, additional adjustments will be done self._emulateLibs = emulateLibs end --- Adds a prefix to the ones to be looked for when loading modules. -- -- @param prefix (string) The prefix -- @param prepend (boolean) If true, the prefix will be prepended to the list of -- already defined prefixes, otherwise it is added at -- the end of the list function M:addPrefix(prefix, prepend) local pos = prepend and 1 or #self._prefixes + 1 table.insert(self._prefixes, pos, prefix) end --- Enables or disables MLS libs emulation. function M:enableLibsEmulation(emulateLibs) local emulationState = emulateLibs and "enabled" or "DISABLED" Mls.logger:info("uLua libs.lua emulation is "..emulationState, "module") self._emulateLibs = emulateLibs end --- Loads and initializes simulated ML modules. -- -- @param moduleNames (table) The list of modules to be loaded -- -- @see loadModule for a detailed explanation of the parameters function M:loadModules(moduleNames) Mls.logger:info("loading uLua simulated modules", "module") moduleNames = moduleNames or self._moduleNames -- we have to also try to load modules without a prefix; we do this last if self._prefixes[#self._prefixes] ~= "" then self._prefixes[#self._prefixes + 1] = "" end for _, moduleName in ipairs(moduleNames) do if not __MLS_COMPILED then _G[moduleName] = self:_loadModule(moduleName) else self:_registerCompiledModule(moduleName) end local loadedModule = _G[moduleName] local isModuleEmulated = self._emulatedModules[moduleName] local mustInitModule = true if self._emulateLibs then if type(isModuleEmulated) == "string" then Mls.logger:debug(moduleName.." will also be emulated as "..isModuleEmulated, "module") _G[isModuleEmulated] = _G[moduleName] end else if isModuleEmulated == true then Mls.logger:debug(moduleName.." won't be available since libs.lua emulation is disabled!", "module") _G[moduleName] = nil mustInitModule = false end end if mustInitModule and loadedModule.initModule then Mls.logger:debug(moduleName.." initializing", "module") loadedModule:initModule(self._emulateLibs) end end -- this is not a "module", but it was defined until ML 3.0 beta, and -- libs.lua was using it -- @todo remove this when it's not needed anymore _G.os.initTimer = function() end end --- Resets all loaded modules. -- -- @param scriptEnvironment (table) The environment (= _G) of a script, where -- global variables should be written by the -- modules. Not all modules use this, but if -- they have to modify a global variable and -- the change should be seen by the running -- script, it's needed (e.g. NB_FPS in screen) function M:resetModules(scriptEnvironment) for moduleName, module in pairs(self._modules) do Mls.logger:debug(moduleName..": resetting module", "module") if module.resetModule then module:resetModule(scriptEnvironment) end end end --- Loads a simulated ML module. -- -- @param moduleName (string) The name of the module to load, which should also -- be the name of its Lua "class" (i.e. a lua -- "module" to "require"), so it must be in the lua -- module path to be found -- -- @return (table) The loaded module function M:_loadModule(moduleName) Mls.logger:debug(moduleName..": loading", "module") if self._modules[moduleName] then Mls.logger:debug(moduleName.." was already loaded", "module") return self._modules[moduleName] end local loaded, result, modulePath for _, prefix in ipairs(self._prefixes) do Mls.logger:debug(moduleName..": searching with prefix '"..prefix.."'", "module") modulePath = "clp.mls.modules."..prefix..moduleName loaded, result = pcall(require, modulePath) -- module was found and loaded, we end the loop if loaded then break end -- if module wasn't loaded, is it because it was found but had errors, -- i.e. the error message is NOT "module not found"... -- (then we end the loop => error) if not result:find("^module '"..modulePath.."' not found:") then break end -- ...or because it wasn't found with that prefix ? (then it's "normal" -- and we continue the loop, searching for other prefixes) Mls.logger:debug(moduleName.." not found with prefix '"..prefix.."'", "module") end assert(loaded, result) Mls.logger:debug(moduleName.." loaded OK ("..modulePath..")", "module") self._modules[moduleName] = result self._modules[moduleName].__MODULE_NAME = moduleName return result end --- Registers a simulated ML module in the "compiled" version of MLS. -- -- @param moduleName (string) The name of the module to register. Its Lua -- "class" should have been declared in the big -- single "compiled" file, prefixed with its location -- (e.g. clp_mls_modules_wx_Color for Color) function M:_registerCompiledModule(moduleName) Mls.logger:debug(moduleName..": registering compiled module", "module") -- modules won't be loaded (only initialized) if we're running a "compiled" -- version of Mls (everything in one big file). -- ugly hack to make Font work in the compiled version of MLS; -- we have to put one of the two Font implementations in global variable -- Font => only the bitmap one is available in this version if moduleName == "Font" then Font = clp_mls_modules_wx_Font_Bitmap end -- in the compiled version, modules are already set on _G, so we consider -- them already loaded... -- ...but we need to choose the right module name (clp_mls_modules_ + prefix -- + module name) for _, prefix in ipairs(self._prefixes) do prefix = prefix:gsub("\.$", "") local moduleFullName = "clp_mls_modules_".. (prefix ~= "" and prefix.."_" or "").. moduleName Mls.logger:debug(moduleName..": trying to register with prefix '"..prefix.."'", "module") if _G[moduleFullName] then Mls.logger:debug(moduleName.." registered OK ("..moduleFullName..")", "module") _G[moduleName] = _G[moduleFullName] break end end self._modules[moduleName] = _G[moduleName] end return M
gpl-3.0
anshkumar/yugioh-glaze
assets/script/c34471458.lua
3
2565
--フォーチュンレディ・ライティー function c34471458.initial_effect(c) --atk,def local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_SET_ATTACK) e1:SetValue(c34471458.value) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_SET_DEFENCE) c:RegisterEffect(e2) --level up local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(34471458,0)) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e3:SetRange(LOCATION_MZONE) e3:SetCountLimit(1) e3:SetCode(EVENT_PHASE+PHASE_STANDBY) e3:SetCondition(c34471458.lvcon) e3:SetOperation(c34471458.lvop) c:RegisterEffect(e3) --special summon local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(34471458,1)) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e4:SetCode(EVENT_LEAVE_FIELD) e4:SetCondition(c34471458.spcon) e4:SetTarget(c34471458.sptg) e4:SetOperation(c34471458.spop) c:RegisterEffect(e4) end function c34471458.value(e,c) return c:GetLevel()*200 end function c34471458.lvcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp and e:GetHandler():IsLevelAbove(1) and e:GetHandler():IsLevelBelow(11) end function c34471458.lvop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFacedown() or not c:IsRelateToEffect(e) or c:IsLevelAbove(12) then return end local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_LEVEL) e1:SetValue(1) e1:SetReset(RESET_EVENT+0x1ff0000) c:RegisterEffect(e1) end function c34471458.spcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_EFFECT) and not c:IsLocation(LOCATION_DECK) and c:IsPreviousPosition(POS_FACEUP) end function c34471458.spfilter(c,e,tp) return c:IsSetCard(0x31) and c:IsCanBeSpecialSummoned(e,0x8,tp,false,false) end function c34471458.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c34471458.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function c34471458.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c34471458.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0x8,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c80513550.lua
3
2971
--バッド・エンド・クイーン・ドラゴン function c80513550.initial_effect(c) c:EnableReviveLimit() --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetCondition(c80513550.hspcon) c:RegisterEffect(e1) --damage local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(80513550,0)) e2:SetCategory(CATEGORY_HANDES+CATEGORY_DRAW) e2:SetCode(EVENT_BATTLE_DAMAGE) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCondition(c80513550.hdcon) e2:SetTarget(c80513550.hdtg) e2:SetOperation(c80513550.hdop) c:RegisterEffect(e2) --Special Summon local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(80513550,1)) e3:SetType(EFFECT_TYPE_TRIGGER_O+EFFECT_TYPE_FIELD) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetCode(EVENT_PHASE+PHASE_STANDBY) e3:SetRange(LOCATION_GRAVE) e3:SetCondition(c80513550.spcon) e3:SetCost(c80513550.spcost) e3:SetTarget(c80513550.sptg) e3:SetOperation(c80513550.spop) c:RegisterEffect(e3) end function c80513550.hspfilter(c) return c:IsFaceup() and c:GetType()==TYPE_SPELL+TYPE_CONTINUOUS end function c80513550.hspcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c80513550.hspfilter,c:GetControler(),LOCATION_SZONE,0,3,nil) end function c80513550.hdcon(e,tp,eg,ep,ev,re,r,rp) return ep~=tp and e:GetHandler()==Duel.GetAttacker() end function c80513550.hdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,1-tp,1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c80513550.hdop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetFieldGroupCount(tp,0,LOCATION_HAND)~=0 and Duel.IsPlayerCanDraw(tp,1) then Duel.DiscardHand(1-tp,nil,1,1,REASON_EFFECT) Duel.Draw(tp,1,REASON_EFFECT) end end function c80513550.spcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp and e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD) end function c80513550.cfilter(c) return c:IsFaceup() and c:GetType()==TYPE_SPELL+TYPE_CONTINUOUS and c:IsAbleToGraveAsCost() end function c80513550.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c80513550.cfilter,tp,LOCATION_SZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,c80513550.cfilter,tp,LOCATION_SZONE,0,1,1,nil) Duel.SendtoGrave(g,REASON_COST) end function c80513550.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) end function c80513550.spop(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsRelateToEffect(e) then Duel.SpecialSummon(e:GetHandler(),0,tp,tp,false,false,POS_FACEUP) end end
gpl-2.0
nhnb/stendhal
data/script/region/atlantis/city/exterior/ZelanNPC.lua
3
2340
--[[ *************************************************************************** * Copyright © 2020 - Arianne * *************************************************************************** *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * *************************************************************************** ]] local zoneName = "-7_deniran_atlantis" if game:setZone(zoneName) then local zelan = entities:createSpeakerNPC("Zelan") -- NPC appearance & behavior zelan:setEntityClass("atlantismale01npc") zelan:setCollisionAction(CollisionAction.STOP) -- NPC location & path local nodes = { {63, 66}, {75, 66}, } zelan:setPathAndPosition(nodes, true) -- NPC dialog zelan:addGreeting() zelan:addGoodbye() -- add Zelan to the world game:add(zelan) -- quest local quest = quests.simple:create("unicorn_horns_for_zelan", "Unicorn Horns for Zelan", "Zelan") quest:setDescription("Zelan needs help gathering unicorn horns.") quest:setReply(quests.simple.ID_REQUEST, "Hello! I'm in need of some unicorn horns to make some daggers." .. " It is really dangerous in the woods surrounding Atlantis. If you are a brave sort" .. " I could really use some help gathering unicorn horns. Will you help me?") quest:setReply(quests.simple.ID_ACCEPT, "Great! Be careful out there lots of large monsters, and those centaurs are really nasty") quest:setReply(quests.simple.ID_REWARD, "Thanks a bunch!") quest:setReply(quests.simple.ID_REJECT, "Thats ok, I will find someone else to help me.") quest:setItemToCollect("unicorn horn", 10) quest:setXPReward(50000) quest:setKarmaReward(5.0) quest:addItemReward("soup", 3) quest:addItemReward("money", 20000) quest:setRegion(Region.ATLANTIS) quests:register(quest) else logger:error("Could not set zone: " .. zoneName) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c7093411.lua
3
2221
--宝玉獣 サファイア・ペガサス function c7093411.initial_effect(c) --send replace local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_TO_GRAVE_REDIRECT_CB) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetCondition(c7093411.repcon) e1:SetOperation(c7093411.repop) c:RegisterEffect(e1) --place local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(7093411,1)) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e2:SetTarget(c7093411.target) e2:SetOperation(c7093411.operation) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e3) local e4=e2:Clone() e4:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e4) end function c7093411.repcon(e) local c=e:GetHandler() return c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsReason(REASON_DESTROY) end function c7093411.repop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetCode(EFFECT_CHANGE_TYPE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+0x1fc0000) e1:SetValue(TYPE_SPELL+TYPE_CONTINUOUS) c:RegisterEffect(e1) Duel.RaiseEvent(c,47408488,e,0,tp,0,0) end function c7093411.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_HAND,0,1,nil,0x1034) and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 end end function c7093411.operation(e,tp,eg,ep,ev,re,r,rp,chk) if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local g=Duel.SelectMatchingCard(tp,Card.IsSetCard,tp,LOCATION_DECK+LOCATION_GRAVE+LOCATION_HAND,0,1,1,nil,0x1034) if g:GetCount()>0 then local tc=g:GetFirst() Duel.MoveToField(tc,tp,tp,LOCATION_SZONE,POS_FACEUP,true) local e1=Effect.CreateEffect(tc) e1:SetCode(EFFECT_CHANGE_TYPE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+0x1fc0000) e1:SetValue(TYPE_SPELL+TYPE_CONTINUOUS) tc:RegisterEffect(e1) Duel.RaiseEvent(tc,47408488,e,0,tp,0,0) end end
gpl-2.0
ilovecv/rbm_toolbox_lua
examples/testconv.lua
5
7083
codeFolder = '../code/' require('torch') require(codeFolder..'rbm') require(codeFolder..'dataset-mnist') require(codeFolder..'ProFi') require 'paths' torch.setdefaulttensortype('torch.FloatTensor') require 'nn' tester = torch.Tester() nInput = 1 filterSize = 2 pad = filterSize -1 nFilters = 3 poolSize =2 inputSize = 5 hidSize = inputSize - filterSize +1 maxPool = function(filters,poolsize) -- maxpool over several filters -- filters should be a 3d matrix local pool = function(x) --Calculate exp(x) / [sum(exp(x)) +1] in numerically stable way local m = torch.max(x) local exp_x = torch.exp(x - m) -- normalizer = sum(exp(x)) + 1 in scaled domain local normalizer = torch.exp(-m) + exp_x:sum() exp_x:cdiv( torch.Tensor(exp_x:nElement()):fill(normalizer) ) return exp_x end local maxPoolSingle = function(hf,hfres,poolsize) -- Performs probabilistic maxpooling. -- For each block of poolsize x poolsize calculate -- exp(h_i) / [sum_i(exp(h_i)) + 1] -- hf should be a 2d matrix local height = hf:size(1) local width = hf:size(2) --poshidprobs = torch.Tensor(height,width):typeAs(hf) -- notation h_(i,j) for i_start = 1,height,poolsize do i_end = i_start+poolsize -1 for j_start = 1,width,poolsize do -- columns j_end = j_start+poolsize -1 hfres[{{i_start,i_end},{j_start,j_end}}] = pool(hf[{{i_start,i_end},{j_start,j_end}}]) end end end dest = torch.Tensor(filters:size()):typeAs(filters) for i = 1, filters:size(1) do maxPoolSingle(filters[{i,{},{}}],dest[{ i,{},{} }],poolsize) end return dest end function invertWeights(x) -- a mxn matrix local xtemp = torch.Tensor(x:size()) local idx = x:size(2) for i = 1,x:size(2) do xtemp[{{},idx}] = x[{{},i}] idx = idx -1 end return xtemp end function invertWeights3d(x) res = torch.Tensor(x:size()) for i = 1,x:size(1) do res[{i,{},{}}] = invertWeights(x[{i,{},{}}]) end return x end W = torch.Tensor({1,-2,-3,7,2,1,-3,2,-1,2,5,2}) -- Filter: | 1, -2| W = W:resize(nFilters,4) -- |-3, 7| modelup = nn.Sequential() --modelup:add(nn.Reshape(1,inputSize,inputSize)) modelup:add(nn.SpatialConvolutionMM(1,nFilters,filterSize,filterSize)) --modelup:add(nn.Sigmoid()) modeldownx = nn.Sequential() modeldownx:add(nn.SpatialZeroPadding(pad, pad, pad, pad)) -- pad (filterwidth -1) modeldownx:add(nn.SpatialConvolution(nFilters,1,filterSize,filterSize)) --modeldownx:add(nn.Sigmoid()) -- SET TESTING WEIGHTS OF UP MODEL modelup.modules[1].weight = W modelup.modules[1].bias = torch.zeros(nFilters) -- -- SET TESTING WEIGHTS OF DOWNX MODEL Wtilde = invertWeights(W) -- Because the weights are unrolled to vectors flipping modeldownx.modules[2].weight = Wtilde:resize(modeldownx.modules[2].weight:size()) modeldownx.modules[2].bias = torch.zeros(1) rbmup = function(x) local res = modelup:forward(x):clone() return maxPool(res,filterSize) end rbmdownx = function(x) return modeldownx:forward(x):clone() end x = torch.Tensor({1,2,7,1,0,3,4,3,4,1,2,3,4,1,2,5,4,3,1,1,3,3,2,1,2}):resize(1,5,5) / 20 h0 = rbmup(x) -- sampler v1 = rbmdownx(h0) -- sampler h1 = rbmup(v1) nWeights = nFilters * filterSize * filterSize shrink = filterSize -1 nHidden = (x:size(2)-shrink) * (x:size(3)-shrink) hidBias = ( h0:sum(3):sum(2):squeeze() - h1:sum(3):sum(2):squeeze() ) / nHidden visBias = torch.Tensor({( x:sum() - v1:sum() ) / (x:nElement())}) -- W grads shrink = filterSize -1 x_h = x:size(2) x_w = x:size(3) hid_h =x_h-filterSize+1 hid_w =x_w-filterSize+1 --(filterSize:x_h-filterSize+1,filterSize:x_w-filterSize+1 x_in = x[ {{}, {filterSize, x_h-filterSize+1 }, {filterSize, x_w-filterSize+1 }}] h0_in = h0[{{}, {filterSize, hid_h-filterSize+1}, {filterSize, hid_w-filterSize+1}}] h0_in_filter = h0_in:resize(nFilters,nInput,h0_in:size(2),h0_in:size(3)) nnw = nn.SpatialConvolution(nInput,nFilters,filterSize,filterSize) -- -- -- -- gradsnn.weight is poshidprobs(Wfilter:Hhidden-Wfilter+1,Wfilter:Whidden-Wfilter+1,:,:) nnw.weight = h0_in_filter nnw.bias = torch.zeros(nFilters) dw_pos = nnw:forward(x_in) -- -- -- gradsnn:add(nn.Reshape(1,inputSize-filterSize,inputSize-filterSize)) -- -- DEFINING TESTS RESULTS -- x_test = torch.Tensor({ 0.0500, 0.1000, 0.3500, 0.0500, 0, 0.1500, 0.2000, 0.1500, 0.2000, 0.0500, 0.1000, 0.1500, 0.2000, 0.0500, 0.1000, 0.2500, 0.2000, 0.1500, 0.0500, 0.0500, 0.1500, 0.1500, 0.1000, 0.0500, 0.1000}):resize(1,5,5) poshidprobs_test = torch.Tensor({ 0.2756, 0.1066, 0.4334, 0.1069, 0.2042, 0.2898, 0.0792, 0.2500, 0.2405, 0.1873, 0.1723, 0.1811, 0.2405, 0.1782, 0.1904, 0.2840, 0.1723, 0.1904, 0.3180, 0.1058, 0.2445, 0.2445, 0.1579, 0.2603, 0.1586, 0.1937, 0.1956, 0.2056, 0.2749, 0.2141, 0.2056, 0.2162, 0.2073, 0.3777, 0.2121, 0.2465, 0.1614, 0.1972, 0.3327, 0.1224, 0.3485, 0.2582, 0.2598, 0.2024, 0.1819, 0.1566, 0.2127, 0.2024 }):resize(3,4,4) -- -- V1 tests v1_test = torch.Tensor({ 0.4129, 0.1453, 1.5898, -0.0524, 0.3851, 0.2243, 4.4263, 0.8105, 6.0015, 1.4578, -0.3297, 2.3153, 4.5030, 1.3770, 2.7639, 1.1535, 3.4532, 2.9705, 2.7326, 2.1365, -0.6367, 2.2036, 1.8644, 1.6806, 2.8251}):resize(1,5,5) neghidprobs_test = torch.Tensor({ 0.9549, 0.0000, 1.0000, 0.0000, 0.0000, 0.0451, 0.0000, 0.0000, 0.9848, 0.0000, 0.2265, 0.0000, 0.0152, 0.0000, 0.0001, 0.7734, 0.0558, 0.0000, 0.1035, 0.0000, 0.2138, 0.7304, 0.0000, 0.8965, 0.0009, 0.0006, 0.1927, 0.0009, 0.9923, 0.0062, 0.1175, 0.6887, 0.0000, 0.9999, 0.0000, 0.0621, 0.0000, 0.0001, 0.9379, 0.0000, 0.0000, 1.0000, 0.0287, 0.9688, 0.0000, 0.0000, 0.0010, 0.0015}):resize(3,4,4) visBias_test = torch.Tensor({-1.7306}) hidBias_test = torch.Tensor({ -0.0363, -0.0401, -0.0200}) dw_test = torch.Tensor({ -1.0870, -0.2431, -0.6546, -0.7233, -3.9614, -0.7434, -2.1294, -3.7218, -3.0255, -10.0109, -7.5756, -4.2333}) dw_pos_test = torch.Tensor({ 0.1324, 0.1054, 0.1226, 0.0986, 0.1408, 0.1168, 0.1363, 0.0956, 0.1800, 0.1607, 0.1867, 0.1078 }):resize(3,2,2) print "################ TESTS ############################" assert(checkequality(x,x_test,-4,false)) assert(checkequality(h0,poshidprobs_test,-4,false)) assert(checkequality(v1,v1_test,-4,false)) assert(checkequality(h1,neghidprobs_test,-4,false)) print("Testing Gradients...") assert(checkequality(visBias,visBias_test,-4,false)) assert(checkequality(hidBias,hidBias_test,-4,false)) --assert(checkequality(dw_pos,dw_pos_test,-4,false)) print('OK') -- -- ---UPDATES print('ADD SIGMOIDS!!! ')
bsd-3-clause
anshkumar/yugioh-glaze
assets/script/c55343236.lua
5
2986
--Sin 真紅眼の黒竜 function c55343236.initial_effect(c) c:EnableReviveLimit() --special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND) e1:SetCondition(c55343236.spcon) e1:SetOperation(c55343236.spop) c:RegisterEffect(e1) --only 1 can exists local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_CANNOT_FLIP_SUMMON) e2:SetCondition(c55343236.excon) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) c:RegisterEffect(e3) local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_FIELD) e4:SetRange(LOCATION_MZONE) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e4:SetTargetRange(1,1) e4:SetCode(EFFECT_CANNOT_SUMMON) e4:SetTarget(c55343236.sumlimit) c:RegisterEffect(e4) local e5=e4:Clone() e5:SetCode(EFFECT_CANNOT_FLIP_SUMMON) c:RegisterEffect(e5) local e6=e4:Clone() e6:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) c:RegisterEffect(e6) --selfdes local e7=Effect.CreateEffect(c) e7:SetType(EFFECT_TYPE_SINGLE) e7:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e7:SetRange(LOCATION_MZONE) e7:SetCode(EFFECT_SELF_DESTROY) e7:SetCondition(c55343236.descon) c:RegisterEffect(e7) local e8=Effect.CreateEffect(c) e8:SetType(EFFECT_TYPE_FIELD) e8:SetCode(EFFECT_SELF_DESTROY) e8:SetRange(LOCATION_MZONE) e8:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE) e8:SetTarget(c55343236.destarget) c:RegisterEffect(e8) --cannot announce local e8=Effect.CreateEffect(c) e8:SetType(EFFECT_TYPE_FIELD) e8:SetRange(LOCATION_MZONE) e8:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE) e8:SetTargetRange(LOCATION_MZONE,0) e8:SetTarget(c55343236.antarget) c:RegisterEffect(e8) end function c55343236.sumlimit(e,c) return c:IsSetCard(0x23) end function c55343236.exfilter(c) return c:IsFaceup() and c:IsSetCard(0x23) end function c55343236.excon(e) return Duel.IsExistingMatchingCard(c55343236.exfilter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil) end function c55343236.spfilter(c) return c:IsCode(74677422) and c:IsAbleToRemoveAsCost() end function c55343236.spcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c55343236.spfilter,c:GetControler(),LOCATION_DECK,0,1,nil) and not Duel.IsExistingMatchingCard(c55343236.exfilter,0,LOCATION_MZONE,LOCATION_MZONE,1,nil) end function c55343236.spop(e,tp,eg,ep,ev,re,r,rp,c) local tc=Duel.GetFirstMatchingCard(c55343236.spfilter,tp,LOCATION_DECK,0,nil) Duel.Remove(tc,POS_FACEUP,REASON_COST) end function c55343236.descon(e) local f1=Duel.GetFieldCard(0,LOCATION_SZONE,5) local f2=Duel.GetFieldCard(1,LOCATION_SZONE,5) return (f1==nil or f1:IsFacedown()) and (f2==nil or f2:IsFacedown()) end function c55343236.destarget(e,c) return c:IsSetCard(0x23) and c:GetFieldID()>e:GetHandler():GetFieldID() end function c55343236.antarget(e,c) return c~=e:GetHandler() end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c12117532.lua
5
2730
--罅割れゆく斧 function c12117532.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DISABLE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_END_PHASE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetTarget(c12117532.target) e1:SetOperation(c12117532.operation) c:RegisterEffect(e1) --Destroy local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e2:SetRange(LOCATION_SZONE) e2:SetCode(EVENT_LEAVE_FIELD) e2:SetCondition(c12117532.descon) e2:SetOperation(c12117532.desop) c:RegisterEffect(e2) --atkdown local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(12117532,0)) e3:SetCategory(CATEGORY_ATKCHANGE) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e3:SetCode(EVENT_PHASE+PHASE_STANDBY) e3:SetRange(LOCATION_SZONE) e3:SetCountLimit(1) e3:SetCondition(c12117532.atkcon) e3:SetOperation(c12117532.atkop) c:RegisterEffect(e3) end function c12117532.filter(c) return c:IsFaceup() end function c12117532.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and c12117532.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c12117532.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectTarget(tp,c12117532.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0) end function c12117532.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then c:SetCardTarget(tc) end end function c12117532.descon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsStatus(STATUS_DESTROY_CONFIRMED) then return false end local tc=c:GetFirstCardTarget() return tc and eg:IsContains(tc) and tc:IsReason(REASON_DESTROY) end function c12117532.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(e:GetHandler(),REASON_EFFECT) end function c12117532.atkcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp and e:GetHandler():GetFirstCardTarget()~=nil end function c12117532.atkop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end local tc=c:GetFirstCardTarget() if tc then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_OWNER_RELATE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(-500) e1:SetReset(RESET_EVENT+0x1fe0000) e1:SetCondition(c12117532.rcon) tc:RegisterEffect(e1,true) end end function c12117532.rcon(e) return e:GetOwner():IsHasCardTarget(e:GetHandler()) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c60493189.lua
3
1821
--E・HERO プラズマヴァイスマン function c60493189.initial_effect(c) --fusion material c:EnableReviveLimit() aux.AddFusionProcCode2(c,20721928,59793705,true,true) --spsummon condition local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) e1:SetValue(aux.fuslimit) c:RegisterEffect(e1) --pierce local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_PIERCE) c:RegisterEffect(e2) --destroy local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(60493189,0)) e3:SetCategory(CATEGORY_DESTROY) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_MZONE) e3:SetCost(c60493189.descost) e3:SetTarget(c60493189.destg) e3:SetOperation(c60493189.desop) c:RegisterEffect(e3) end function c60493189.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_COST+REASON_DISCARD) end function c60493189.filter(c) return c:IsAttackPos() and c:IsDestructable() end function c60493189.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(1-tp) and chkc:IsLocation(LOCATION_MZONE) and c60493189.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c60493189.filter,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,c60493189.filter,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end function c60493189.desop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsAttackPos() and tc:IsRelateToEffect(e) then Duel.Destroy(tc,REASON_EFFECT) end end
gpl-2.0
Zhu-Zhi-Hao/Droid_Ettercap
src/lua/share/third-party/stdlib/src/lcs.lua
12
1584
--- Longest Common Subsequence algorithm. -- After pseudo-code in <a -- href="http://www.ics.uci.edu/~eppstein/161/960229.html">lecture -- notes</a> by <a href="mailto:eppstein@ics.uci.edu">David Eppstein</a>. -- Find common subsequences. -- @param a first sequence -- @param b second sequence -- @return list of common subsequences -- @return the length of a -- @return the length of b local function commonSubseqs (a, b) local l, m, n = {}, #a, #b for i = m + 1, 1, -1 do l[i] = {} for j = n + 1, 1, -1 do if i > m or j > n then l[i][j] = 0 elseif a[i] == b[j] then l[i][j] = 1 + l[i + 1][j + 1] else l[i][j] = math.max (l[i + 1][j], l[i][j + 1]) end end end return l, m, n end --- Find the longest common subsequence of two sequences. -- The sequence objects must have an <code>__append</code> metamethod. -- This is provided by <code>string_ext</code> for strings, and by -- <code>list</code> for lists. -- @param a first sequence -- @param b second sequence -- @param s an empty sequence of the same type, to hold the result -- @return the LCS of a and b local function longestCommonSubseq (a, b, s) local l, m, n = commonSubseqs (a, b) local i, j = 1, 1 local f = getmetatable (s).__append while i <= m and j <= n do if a[i] == b[j] then s = f (s, a[i]) i = i + 1 j = j + 1 elseif l[i + 1][j] >= l[i][j + 1] then i = i + 1 else j = j + 1 end end return s end -- Public interface local M = { longestCommonSubseq = longestCommonSubseq, } return M
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c26329679.lua
3
1327
--セイクリッド・オメガ function c26329679.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsAttribute,ATTRIBUTE_LIGHT),4,2) c:EnableReviveLimit() --immune local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(26329679,0)) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1) e1:SetRange(LOCATION_MZONE) e1:SetCost(c26329679.cost) e1:SetOperation(c26329679.operation) c:RegisterEffect(e1) end function c26329679.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c26329679.filter(c) return c:IsFaceup() and c:IsSetCard(0x53) end function c26329679.operation(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(c26329679.filter,tp,LOCATION_MZONE,0,nil) local tc=g:GetFirst() while tc do local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END) e1:SetValue(c26329679.efilter) tc:RegisterEffect(e1) tc=g:GetNext() end end function c26329679.efilter(e,te) return te:IsActiveType(TYPE_SPELL+TYPE_TRAP) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c28348537.lua
3
1654
--ブリザード・プリンセス function c28348537.initial_effect(c) --summon with 1 tribute local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(28348537,0)) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_SUMMON_PROC) e1:SetCondition(c28348537.otcon) e1:SetOperation(c28348537.otop) e1:SetValue(SUMMON_TYPE_ADVANCE) c:RegisterEffect(e1) --activate limit local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_SUMMON_SUCCESS) e2:SetOperation(c28348537.actlimit) c:RegisterEffect(e2) end function c28348537.otfilter(c,tp) return c:IsRace(RACE_SPELLCASTER) and (c:IsControler(tp) or c:IsFaceup()) end function c28348537.otcon(e,c) if c==nil then return true end local tp=c:GetControler() local mg=Duel.GetMatchingGroup(c28348537.otfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,tp) return c:GetLevel()>6 and Duel.GetTributeCount(c,mg)>0 end function c28348537.otop(e,tp,eg,ep,ev,re,r,rp,c) local mg=Duel.GetMatchingGroup(c28348537.otfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,tp) local sg=Duel.SelectTribute(tp,c,1,1,mg) c:SetMaterial(sg) Duel.Release(sg, REASON_SUMMON+REASON_MATERIAL) end function c28348537.actlimit(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_ACTIVATE) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(0,1) e1:SetValue(c28348537.elimit) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end function c28348537.elimit(e,te,tp) return te:IsHasType(EFFECT_TYPE_ACTIVATE) end
gpl-2.0
Tiger66639/premake-core
tests/actions/vstudio/cs2005/test_compiler_props.lua
5
1408
-- -- tests/actions/vstudio/cs2005/test_compiler_props.lua -- Test the compiler flags of a Visual Studio 2005+ C# project. -- Copyright (c) 2012-2013 Jason Perkins and the Premake project -- local suite = test.declare("vstudio_cs2005_compiler_props") local cs2005 = premake.vstudio.cs2005 local project = premake.project -- -- Setup and teardown -- local sln, prj function suite.setup() _ACTION = "vs2005" sln, prj = test.createsolution() end local function prepare() local cfg = test.getconfig(prj, "Debug") cs2005.compilerProps(cfg) end -- -- Check handling of defines. -- function suite.defineConstants_onDefines() defines { "DEBUG", "TRACE" } prepare() test.capture [[ <DefineConstants>DEBUG;TRACE</DefineConstants> ]] end -- -- Check handling of the Unsafe flag. -- function suite.allowUnsafeBlocks_onUnsafeFlag() clr "Unsafe" prepare() test.capture [[ <DefineConstants></DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> ]] end -- -- Check handling of FatalWarnings flag. -- function suite.treatWarningsAsErrors_onFatalWarningsFlag() flags { "FatalWarnings" } prepare() test.capture [[ <DefineConstants></DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <TreatWarningsAsErrors>true</TreatWarningsAsErrors> ]] end
bsd-3-clause
PocoCraftSource/FiveNightsatFreddysGMod
entities/weapons/gmod_tool/stools/ballsocket.lua
4
2622
TOOL.Category = "Constraints" TOOL.Name = "#tool.ballsocket.name" TOOL.ClientConVar[ "forcelimit" ] = "0" TOOL.ClientConVar[ "torquelimit" ] = "0" TOOL.ClientConVar[ "nocollide" ] = "0" function TOOL:LeftClick( trace ) if ( IsValid( trace.Entity ) && trace.Entity:IsPlayer() ) then return end -- If there's no physics object then we can't constraint it! if ( SERVER && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then return false end local iNum = self:NumObjects() local Phys = trace.Entity:GetPhysicsObjectNum( trace.PhysicsBone ) self:SetObject( iNum + 1, trace.Entity, trace.HitPos, Phys, trace.PhysicsBone, trace.HitNormal ) if ( iNum > 0 ) then if ( CLIENT ) then self:ClearObjects() return true end -- Get client's CVars local nocollide = self:GetClientNumber( "nocollide", 0 ) local forcelimit = self:GetClientNumber( "forcelimit", 0 ) local torquelimit = self:GetClientNumber( "torquelimit", 0 ) -- Get information we're about to use local Ent1, Ent2 = self:GetEnt( 1 ), self:GetEnt( 2 ) local Bone1, Bone2 = self:GetBone( 1 ), self:GetBone( 2 ) local LPos = self:GetLocalPos( 2 ) local constraint = constraint.Ballsocket( Ent1, Ent2, Bone1, Bone2, LPos, forcelimit, torquelimit, nocollide ) undo.Create( "BallSocket" ) undo.AddEntity( constraint ) undo.SetPlayer( self:GetOwner() ) undo.Finish() self:GetOwner():AddCleanup( "constraints", constraint ) -- Clear the objects so we're ready to go again self:ClearObjects() else self:SetStage( iNum + 1 ) end return true end function TOOL:Reload( trace ) if ( !IsValid( trace.Entity ) || trace.Entity:IsPlayer() ) then return false end if ( CLIENT ) then return true end return constraint.RemoveConstraints( trace.Entity, "Ballsocket" ) end function TOOL:Holster() self:ClearObjects() end local ConVarsDefault = TOOL:BuildConVarList() function TOOL.BuildCPanel( CPanel ) CPanel:AddControl( "Header", { Description = "#tool.ballsocket.help" } ) CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "ballsocket", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } ) CPanel:AddControl( "Slider", { Label = "#tool.forcelimit", Command = "ballsocket_forcelimit", Type = "Float", Min = 0, Max = 50000, Help = true } ) CPanel:AddControl( "Slider", { Label = "#tool.torquelimit", Command = "ballsocket_torquelimit", Type = "Float", Min = 0, Max = 50000, Help = true } ) CPanel:AddControl( "CheckBox", { Label = "#tool.nocollide", Command = "ballsocket_nocollide", Help = true } ) end
gpl-2.0
sjznxd/lc-20130302
applications/luci-minidlna/luasrc/controller/minidlna.lua
73
1448
--[[ LuCI - Lua Configuration Interface - miniDLNA support Copyright 2012 Gabor Juhos <juhosg@openwrt.org> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- module("luci.controller.minidlna", package.seeall) function index() if not nixio.fs.access("/etc/config/minidlna") then return end local page page = entry({"admin", "services", "minidlna"}, cbi("minidlna"), _("miniDLNA")) page.dependent = true entry({"admin", "services", "minidlna_status"}, call("minidlna_status")) end function minidlna_status() local sys = require "luci.sys" local uci = require "luci.model.uci".cursor() local port = tonumber(uci:get_first("minidlna", "minidlna", "port")) local status = { running = (sys.call("pidof minidlna >/dev/null") == 0), audio = 0, video = 0, image = 0 } if status.running then local fd = sys.httpget("http://127.0.0.1:%d/" % (port or 8200), true) if fd then local html = fd:read("*a") if html then status.audio = (tonumber(html:match("Audio files: (%d+)")) or 0) status.video = (tonumber(html:match("Video files: (%d+)")) or 0) status.image = (tonumber(html:match("Image files: (%d+)")) or 0) end fd:close() end end luci.http.prepare_content("application/json") luci.http.write_json(status) end
apache-2.0
anshkumar/yugioh-glaze
assets/script/c52182715.lua
6
2020
--グリーン・ダストン function c52182715.initial_effect(c) c:SetUniqueOnField(1,0,52182715) --cannot release local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_UNRELEASABLE_SUM) e1:SetValue(1) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_UNRELEASABLE_NONSUM) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e3:SetCode(EFFECT_CANNOT_BE_FUSION_MATERIAL) e3:SetValue(1) c:RegisterEffect(e3) local e4=e3:Clone() e4:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL) c:RegisterEffect(e4) local e5=e3:Clone() e5:SetCode(EFFECT_CANNOT_BE_XYZ_MATERIAL) c:RegisterEffect(e5) --tohand local e6=Effect.CreateEffect(c) e6:SetDescription(aux.Stringid(52182715,0)) e6:SetCategory(CATEGORY_TOHAND) e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e6:SetProperty(EFFECT_FLAG_CARD_TARGET) e6:SetCode(EVENT_DESTROYED) e6:SetCondition(c52182715.retcon) e6:SetTarget(c52182715.rettg) e6:SetOperation(c52182715.retop) c:RegisterEffect(e6) end function c52182715.retcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_DESTROY) and c:IsPreviousLocation(LOCATION_ONFIELD) end function c52182715.filter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand() end function c52182715.rettg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) local prec=e:GetHandler():GetPreviousControler() if chkc then return chkc:IsControler(prec) and chkc:IsOnField() and c52182715.filter(chkc) end if chk==0 then return true end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectTarget(prec,c52182715.filter,prec,LOCATION_ONFIELD,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,g:GetCount(),0,0) end function c52182715.retop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) end end
gpl-2.0
johnparker007/mame
plugins/data/database.lua
6
1111
local sql = require("lsqlite3") local datfile = {} local db local function check_db(msg) if db:errcode() > sql.OK then emu.print_error(string.format("Error: %s (%s - %s)\n", msg, db:errcode(), db:errmsg())) end end do local dbpath = emu.subst_env(mame_manager.ui.options.entries.historypath:value():match("([^;]+)")) db = sql.open(dbpath .. "/history.db") if not db then lfs.mkdir(dbpath) db = sql.open(dbpath .. "/history.db") if not db then emu.print_error("Unable to create history.db\n") return false end check_db("opening database") end end if db then local found = false db:exec("select * from sqlite_master where name = 'version'", function() found = true return 0 end) check_db("checking for 'version' table") if not found then db:exec([[ CREATE TABLE version ( version VARCHAR NOT NULL, datfile VARCHAR UNIQUE NOT NULL)]]) check_db("creating 'version' table") end end local dbtable = { prepare = function(...) return db:prepare(...) end, exec = function(...) return db:exec(...) end, ROW = sql.ROW, check = check_db } return db and dbtable or false
gpl-2.0
kiarash14/br
bot/utils.lua
239
13499
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end
gpl-2.0
ARGANBOT/ARSHAM
bot/utils.lua
239
13499
URL = require "socket.url" http = require "socket.http" https = require "ssl.https" ltn12 = require "ltn12" serpent = require "serpent" feedparser = require "feedparser" json = (loadfile "./libs/JSON.lua")() mimetype = (loadfile "./libs/mimetype.lua")() redis = (loadfile "./libs/redis.lua")() http.TIMEOUT = 10 function get_receiver(msg) if msg.to.type == 'user' then return 'user#id'..msg.from.id end if msg.to.type == 'chat' then return 'chat#id'..msg.to.id end if msg.to.type == 'encr_chat' then return msg.to.print_name end end function is_chat_msg( msg ) if msg.to.type == 'chat' then return true end return false end function string.random(length) local str = ""; for i = 1, length do math.random(97, 122) str = str..string.char(math.random(97, 122)); end return str; end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end -- DEPRECATED function string.trim(s) print("string.trim(s) is DEPRECATED use string:trim() instead") return s:gsub("^%s*(.-)%s*$", "%1") end -- Removes spaces function string:trim() return self:gsub("^%s*(.-)%s*$", "%1") end function get_http_file_name(url, headers) -- Eg: foo.var local file_name = url:match("[^%w]+([%.%w]+)$") -- Any delimited alphanumeric on the url file_name = file_name or url:match("[^%w]+(%w+)[^%w]+$") -- Random name, hope content-type works file_name = file_name or str:random(5) local content_type = headers["content-type"] local extension = nil if content_type then extension = mimetype.get_mime_extension(content_type) end if extension then file_name = file_name.."."..extension end local disposition = headers["content-disposition"] if disposition then -- attachment; filename=CodeCogsEqn.png file_name = disposition:match('filename=([^;]+)') or file_name end return file_name end -- Saves file to /tmp/. If file_name isn't provided, -- will get the text after the last "/" for filename -- and content-type for extension function download_to_file(url, file_name) print("url to download: "..url) local respbody = {} local options = { url = url, sink = ltn12.sink.table(respbody), redirect = true } -- nil, code, headers, status local response = nil if url:starts('https') then options.redirect = false response = {https.request(options)} else response = {http.request(options)} end local code = response[2] local headers = response[3] local status = response[4] if code ~= 200 then return nil end file_name = file_name or get_http_file_name(url, headers) local file_path = "/tmp/"..file_name print("Saved to: "..file_path) file = io.open(file_path, "w+") file:write(table.concat(respbody)) file:close() return file_path end function vardump(value) print(serpent.block(value, {comment=false})) end -- taken from http://stackoverflow.com/a/11130774/3163199 function scandir(directory) local i, t, popen = 0, {}, io.popen for filename in popen('ls -a "'..directory..'"'):lines() do i = i + 1 t[i] = filename end return t end -- http://www.lua.org/manual/5.2/manual.html#pdf-io.popen function run_command(str) local cmd = io.popen(str) local result = cmd:read('*all') cmd:close() return result end -- User has privileges function is_sudo(msg) local var = false -- Check users id in config for v,user in pairs(_config.sudo_users) do if user == msg.from.id then var = true end end return var end -- Returns the name of the sender function get_name(msg) local name = msg.from.first_name if name == nil then name = msg.from.id end return name end -- Returns at table of lua files inside plugins function plugins_names( ) local files = {} for k, v in pairs(scandir("plugins")) do -- Ends with .lua if (v:match(".lua$")) then table.insert(files, v) end end return files end -- Function name explains what it does. function file_exists(name) local f = io.open(name,"r") if f ~= nil then io.close(f) return true else return false end end -- Save into file the data serialized for lua. -- Set uglify true to minify the file. function serialize_to_file(data, file, uglify) file = io.open(file, 'w+') local serialized if not uglify then serialized = serpent.block(data, { comment = false, name = '_' }) else serialized = serpent.dump(data) end file:write(serialized) file:close() end -- Returns true if the string is empty function string:isempty() return self == nil or self == '' end -- Returns true if the string is blank function string:isblank() self = self:trim() return self:isempty() end -- DEPRECATED!!!!! function string.starts(String, Start) print("string.starts(String, Start) is DEPRECATED use string:starts(text) instead") return Start == string.sub(String,1,string.len(Start)) end -- Returns true if String starts with Start function string:starts(text) return text == string.sub(self,1,string.len(text)) end -- Send image to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_photo(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function, cb_extra = cb_extra } -- Call to remove with optional callback send_photo(receiver, file_path, cb_function, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_photo_from_url(receiver, url, cb_function, cb_extra) -- If callback not provided cb_function = cb_function or ok_cb cb_extra = cb_extra or false local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, cb_function, cb_extra) else print("File path: "..file_path) _send_photo(receiver, file_path, cb_function, cb_extra) end end -- Same as send_photo_from_url but as callback function function send_photo_from_url_callback(cb_extra, success, result) local receiver = cb_extra.receiver local url = cb_extra.url local file_path = download_to_file(url, false) if not file_path then -- Error local text = 'Error downloading the image' send_msg(receiver, text, ok_cb, false) else print("File path: "..file_path) _send_photo(receiver, file_path, ok_cb, false) end end -- Send multiple images asynchronous. -- param urls must be a table. function send_photos_from_url(receiver, urls) local cb_extra = { receiver = receiver, urls = urls, remove_path = nil } send_photos_from_url_callback(cb_extra) end -- Use send_photos_from_url. -- This function might be difficult to understand. function send_photos_from_url_callback(cb_extra, success, result) -- cb_extra is a table containing receiver, urls and remove_path local receiver = cb_extra.receiver local urls = cb_extra.urls local remove_path = cb_extra.remove_path -- The previously image to remove if remove_path ~= nil then os.remove(remove_path) print("Deleted: "..remove_path) end -- Nil or empty, exit case (no more urls) if urls == nil or #urls == 0 then return false end -- Take the head and remove from urls table local head = table.remove(urls, 1) local file_path = download_to_file(head, false) local cb_extra = { receiver = receiver, urls = urls, remove_path = file_path } -- Send first and postpone the others as callback send_photo(receiver, file_path, send_photos_from_url_callback, cb_extra) end -- Callback to remove a file function rmtmp_cb(cb_extra, success, result) local file_path = cb_extra.file_path local cb_function = cb_extra.cb_function or ok_cb local cb_extra = cb_extra.cb_extra if file_path ~= nil then os.remove(file_path) print("Deleted: "..file_path) end -- Finally call the callback cb_function(cb_extra, success, result) end -- Send document to user and delete it when finished. -- cb_function and cb_extra are optionals callback function _send_document(receiver, file_path, cb_function, cb_extra) local cb_extra = { file_path = file_path, cb_function = cb_function or ok_cb, cb_extra = cb_extra or false } -- Call to remove with optional callback send_document(receiver, file_path, rmtmp_cb, cb_extra) end -- Download the image and send to receiver, it will be deleted. -- cb_function and cb_extra are optionals callback function send_document_from_url(receiver, url, cb_function, cb_extra) local file_path = download_to_file(url, false) print("File path: "..file_path) _send_document(receiver, file_path, cb_function, cb_extra) end -- Parameters in ?a=1&b=2 style function format_http_params(params, is_get) local str = '' -- If is get add ? to the beginning if is_get then str = '?' end local first = true -- Frist param for k,v in pairs (params) do if v then -- nil value if first then first = false str = str..k.. "="..v else str = str.."&"..k.. "="..v end end end return str end -- Check if user can use the plugin and warns user -- Returns true if user was warned and false if not warned (is allowed) function warns_user_not_allowed(plugin, msg) if not user_allowed(plugin, msg) then local text = 'This plugin requires privileged user' local receiver = get_receiver(msg) send_msg(receiver, text, ok_cb, false) return true else return false end end -- Check if user can use the plugin function user_allowed(plugin, msg) if plugin.privileged and not is_sudo(msg) then return false end return true end function send_order_msg(destination, msgs) local cb_extra = { destination = destination, msgs = msgs } send_order_msg_callback(cb_extra, true) end function send_order_msg_callback(cb_extra, success, result) local destination = cb_extra.destination local msgs = cb_extra.msgs local file_path = cb_extra.file_path if file_path ~= nil then os.remove(file_path) print("Deleted: " .. file_path) end if type(msgs) == 'string' then send_large_msg(destination, msgs) elseif type(msgs) ~= 'table' then return end if #msgs < 1 then return end local msg = table.remove(msgs, 1) local new_cb_extra = { destination = destination, msgs = msgs } if type(msg) == 'string' then send_msg(destination, msg, send_order_msg_callback, new_cb_extra) elseif type(msg) == 'table' then local typ = msg[1] local nmsg = msg[2] new_cb_extra.file_path = nmsg if typ == 'document' then send_document(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'image' or typ == 'photo' then send_photo(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'audio' then send_audio(destination, nmsg, send_order_msg_callback, new_cb_extra) elseif typ == 'video' then send_video(destination, nmsg, send_order_msg_callback, new_cb_extra) else send_file(destination, nmsg, send_order_msg_callback, new_cb_extra) end end end -- Same as send_large_msg_callback but friendly params function send_large_msg(destination, text) local cb_extra = { destination = destination, text = text } send_large_msg_callback(cb_extra, true) end -- If text is longer than 4096 chars, send multiple msg. -- https://core.telegram.org/method/messages.sendMessage function send_large_msg_callback(cb_extra, success, result) local text_max = 4096 local destination = cb_extra.destination local text = cb_extra.text local text_len = string.len(text) local num_msg = math.ceil(text_len / text_max) if num_msg <= 1 then send_msg(destination, text, ok_cb, false) else local my_text = string.sub(text, 1, 4096) local rest = string.sub(text, 4096, text_len) local cb_extra = { destination = destination, text = rest } send_msg(destination, my_text, send_large_msg_callback, cb_extra) end end -- Returns a table with matches or nil function match_pattern(pattern, text, lower_case) if text then local matches = {} if lower_case then matches = { string.match(text:lower(), pattern) } else matches = { string.match(text, pattern) } end if next(matches) then return matches end end -- nil end -- Function to read data from files function load_from_file(file, default_data) local f = io.open(file, "r+") -- If file doesn't exists if f == nil then -- Create a new empty table default_data = default_data or {} serialize_to_file(default_data, file) print ('Created file', file) else print ('Data loaded from file', file) f:close() end return loadfile (file)() end -- See http://stackoverflow.com/a/14899740 function unescape_html(str) local map = { ["lt"] = "<", ["gt"] = ">", ["amp"] = "&", ["quot"] = '"', ["apos"] = "'" } new = string.gsub(str, '(&(#?x?)([%d%a]+);)', function(orig, n, s) var = map[s] or n == "#" and string.char(s) var = var or n == "#x" and string.char(tonumber(s,16)) var = var or orig return var end) return new end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c87751584.lua
3
1139
--ガトリング・ドラゴン function c87751584.initial_effect(c) --fusion material c:EnableReviveLimit() aux.AddFusionProcCode2(c,81480460,25551951,true,true) --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(87751584,0)) e1:SetCategory(CATEGORY_DESTROY+CATEGORY_COIN) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetTarget(c87751584.destg) e1:SetOperation(c87751584.desop) c:RegisterEffect(e1) end function c87751584.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.SetOperationInfo(0,CATEGORY_COIN,nil,0,tp,3) end function c87751584.desop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,nil) if g:GetCount()==0 then return end local c1,c2,c3=Duel.TossCoin(tp,3) local ct=c1+c2+c3 if ct==0 then return end if ct>g:GetCount() then ct=g:GetCount() end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local dg=g:Select(tp,ct,ct,nil) Duel.HintSelection(dg) Duel.Destroy(dg,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c14799437.lua
3
4772
--インフェルノイド・ネヘモス function c14799437.initial_effect(c) c:EnableReviveLimit() --special summon condition local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_SPSUMMON_PROC) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e2:SetRange(LOCATION_HAND+LOCATION_GRAVE) e2:SetCondition(c14799437.spcon) e2:SetOperation(c14799437.spop) c:RegisterEffect(e2) --destroy local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(14799437,0)) e3:SetCategory(CATEGORY_DESTROY) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetTarget(c14799437.destg) e3:SetOperation(c14799437.desop) c:RegisterEffect(e3) --negate local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(14799437,1)) e4:SetCategory(CATEGORY_NEGATE+CATEGORY_REMOVE) e4:SetCode(EVENT_CHAINING) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetRange(LOCATION_MZONE) e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e4:SetCountLimit(1) e4:SetCondition(c14799437.negcon) e4:SetCost(c14799437.negcost) e4:SetTarget(c14799437.negtg) e4:SetOperation(c14799437.negop) c:RegisterEffect(e4) end function c14799437.spfilter(c) return c:IsSetCard(0xbb) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost() end function c14799437.spcon(e,c) if c==nil then return true end local tp=c:GetControler() local sum=0 for i=0,4 do local tc=Duel.GetFieldCard(tp,LOCATION_MZONE,i) if tc and tc:IsFaceup() and tc:IsType(TYPE_EFFECT) then if tc:IsType(TYPE_XYZ) then sum=sum+tc:GetRank() else sum=sum+tc:GetLevel() end end end if sum>8 then return false end local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<-2 then return false end if c:IsHasEffect(34822850) then if ft>0 then return Duel.IsExistingMatchingCard(c14799437.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,3,c) else local ct=-ft+1 return Duel.IsExistingMatchingCard(c14799437.spfilter,tp,LOCATION_MZONE,0,ct,nil) and Duel.IsExistingMatchingCard(c14799437.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,3,c) end else return ft>0 and Duel.IsExistingMatchingCard(c14799437.spfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,3,c) end end function c14799437.spop(e,tp,eg,ep,ev,re,r,rp,c) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) local g=nil Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) if c:IsHasEffect(34822850) then if ft>0 then g=Duel.SelectMatchingCard(tp,c14799437.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,3,3,c) else local sg=Duel.GetMatchingGroup(c14799437.spfilter,tp,LOCATION_MZONE+LOCATION_GRAVE+LOCATION_HAND,0,c) local ct=-ft+1 g=sg:FilterSelect(tp,Card.IsLocation,ct,ct,nil,LOCATION_MZONE) if ct<3 then sg:Sub(g) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g2=sg:Select(tp,3-ct,3-ct,nil) g:Merge(g2) end end else g=Duel.SelectMatchingCard(tp,c14799437.spfilter,tp,LOCATION_GRAVE+LOCATION_HAND,0,3,3,c) end Duel.Remove(g,POS_FACEUP,REASON_COST) end function c14799437.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,1,e:GetHandler()) end local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,e:GetHandler()) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function c14799437.desop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_MZONE,LOCATION_MZONE,e:GetHandler()) if g:GetCount()>0 then Duel.Destroy(g,REASON_EFFECT) end end function c14799437.negcon(e,tp,eg,ep,ev,re,r,rp) return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and re:IsActiveType(TYPE_SPELL+TYPE_TRAP) and Duel.IsChainNegatable(ev) end function c14799437.cfilter(c) return not c:IsStatus(STATUS_BATTLE_DESTROYED) end function c14799437.negcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.CheckReleaseGroup(tp,c14799437.cfilter,1,nil) end local g=Duel.SelectReleaseGroup(tp,c14799437.cfilter,1,1,nil) Duel.Release(g,REASON_COST) end function c14799437.negtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsAbleToRemove() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_REMOVE,eg,1,0,0) end end function c14799437.negop(e,tp,eg,ep,ev,re,r,rp) Duel.NegateActivation(ev) if re:GetHandler():IsRelateToEffect(re) then Duel.Remove(eg,POS_FACEUP,REASON_EFFECT) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c62434031.lua
3
1930
--森羅の花卉士 ナルサス function c62434031.initial_effect(c) --deck check local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(62434031,0)) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetTarget(c62434031.target) e1:SetOperation(c62434031.operation) c:RegisterEffect(e1) --special summon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(62434031,1)) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_TO_GRAVE) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetCondition(c62434031.tdcon) e2:SetTarget(c62434031.tdtg) e2:SetOperation(c62434031.tdop) c:RegisterEffect(e2) end function c62434031.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDiscardDeck(tp,1) end end function c62434031.operation(e,tp,eg,ep,ev,re,r,rp) if not Duel.IsPlayerCanDiscardDeck(tp,1) then return end Duel.ConfirmDecktop(tp,1) local g=Duel.GetDecktopGroup(tp,1) local tc=g:GetFirst() if tc:IsRace(RACE_PLANT) then Duel.DisableShuffleCheck() Duel.SendtoGrave(g,REASON_EFFECT+REASON_REVEAL) else Duel.MoveSequence(tc,1) end end function c62434031.tdcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousLocation(LOCATION_DECK) and (c:IsReason(REASON_REVEAL) or c:GetPreviousPosition()==POS_FACEUP_DEFENCE or Duel.IsPlayerAffectedByEffect(tp,EFFECT_REVERSE_DECK)) end function c62434031.tdtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_DECK,0,1,nil,0x90) end end function c62434031.tdop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(62434031,2)) local g=Duel.SelectMatchingCard(tp,Card.IsSetCard,tp,LOCATION_DECK,0,1,1,nil,0x90) local tc=g:GetFirst() if tc then Duel.ShuffleDeck(tp) Duel.MoveSequence(tc,0) Duel.ConfirmDecktop(tp,1) end end
gpl-2.0
assassinboy208/eagleTG
plugins/inpm.lua
1114
3008
do local function pairsByKeys (t, f) local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a, f) local i = 0 -- iterator variable local iter = function () -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end local function chat_list(msg) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] then return 'No groups at the moment' end local message = 'List of Groups:\n*Use /join (ID) to join*\n\n ' for k,v in pairs(data[tostring(groups)]) do local settings = data[tostring(v)]['settings'] for m,n in pairsByKeys(settings) do if m == 'set_name' then name = n end end message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n ' end local file = io.open("./groups/lists/listed_groups.txt", "w") file:write(message) file:flush() file:close() return message end local function run(msg, matches) if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then local data = load_data(_config.moderation.data) if matches[1] == 'join' and data[tostring(matches[2])] then if is_banned(msg.from.id, matches[2]) then return 'You are banned.' end if is_gbanned(msg.from.id) then return 'You are globally banned.' end if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then return 'Group is private.' end local chat_id = "chat#id"..matches[2] local user_id = "user#id"..msg.from.id chat_add_user(chat_id, user_id, ok_cb, false) local group_name = data[tostring(matches[2])]['settings']['set_name'] return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")" elseif matches[1] == 'join' and not data[tostring(matches[2])] then return "Chat not found." end if matches[1] == 'chats'then if is_admin(msg) and msg.to.type == 'chat' then return chat_list(msg) elseif msg.to.type ~= 'chat' then return chat_list(msg) end end if matches[1] == 'chatlist'then if is_admin(msg) and msg.to.type == 'chat' then send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) elseif msg.to.type ~= 'chat' then send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) end end end end return { patterns = { "^[/!](chats)$", "^[/!](chatlist)$", "^[/!](join) (.*)$", "^[/!](kickme) (.*)$", "^!!tgservice (chat_add_user)$" }, run = run, } end
gpl-2.0
cpluscpu/episs
plugins/inpm.lua
1114
3008
do local function pairsByKeys (t, f) local a = {} for n in pairs(t) do table.insert(a, n) end table.sort(a, f) local i = 0 -- iterator variable local iter = function () -- iterator function i = i + 1 if a[i] == nil then return nil else return a[i], t[a[i]] end end return iter end local function chat_list(msg) local data = load_data(_config.moderation.data) local groups = 'groups' if not data[tostring(groups)] then return 'No groups at the moment' end local message = 'List of Groups:\n*Use /join (ID) to join*\n\n ' for k,v in pairs(data[tostring(groups)]) do local settings = data[tostring(v)]['settings'] for m,n in pairsByKeys(settings) do if m == 'set_name' then name = n end end message = message .. '👥 '.. name .. ' (ID: ' .. v .. ')\n\n ' end local file = io.open("./groups/lists/listed_groups.txt", "w") file:write(message) file:flush() file:close() return message end local function run(msg, matches) if msg.to.type ~= 'chat' or is_sudo(msg) or is_admin(msg) and is_realm(msg) then local data = load_data(_config.moderation.data) if matches[1] == 'join' and data[tostring(matches[2])] then if is_banned(msg.from.id, matches[2]) then return 'You are banned.' end if is_gbanned(msg.from.id) then return 'You are globally banned.' end if data[tostring(matches[2])]['settings']['lock_member'] == 'yes' and not is_owner2(msg.from.id, matches[2]) then return 'Group is private.' end local chat_id = "chat#id"..matches[2] local user_id = "user#id"..msg.from.id chat_add_user(chat_id, user_id, ok_cb, false) local group_name = data[tostring(matches[2])]['settings']['set_name'] return "Added you to chat:\n\n👥"..group_name.." (ID:"..matches[2]..")" elseif matches[1] == 'join' and not data[tostring(matches[2])] then return "Chat not found." end if matches[1] == 'chats'then if is_admin(msg) and msg.to.type == 'chat' then return chat_list(msg) elseif msg.to.type ~= 'chat' then return chat_list(msg) end end if matches[1] == 'chatlist'then if is_admin(msg) and msg.to.type == 'chat' then send_document("chat#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) elseif msg.to.type ~= 'chat' then send_document("user#id"..msg.from.id, "./groups/lists/listed_groups.txt", ok_cb, false) end end end end return { patterns = { "^[/!](chats)$", "^[/!](chatlist)$", "^[/!](join) (.*)$", "^[/!](kickme) (.*)$", "^!!tgservice (chat_add_user)$" }, run = run, } end
gpl-2.0
Tiger66639/premake-core
tests/actions/vstudio/vc200x/test_debug_settings.lua
4
2449
-- -- tests/actions/vstudio/vc200x/test_debugdir.lua -- Validate handling of the working directory for debugging. -- Copyright (c) 2011-2013 Jason Perkins and the Premake project -- local suite = test.declare("vstudio_vs200x_debugdir") local vc200x = premake.vstudio.vc200x local project = premake.project -- -- Setup -- local sln, prj function suite.setup() premake.escaper(premake.vstudio.vs2005.esc) sln, prj = test.createsolution() end local function prepare() local cfg = test.getconfig(prj, "Debug") vc200x.debugSettings(cfg) end -- -- If no debug settings are specified, an empty block should be generated. -- function suite.emptyBlock_onNoSettings() prepare() test.isemptycapture() end -- -- If a debug command is provided, it should be specified relative to -- the project. -- function suite.debugCommand_onRelativePath() location "build" debugcommand "bin/emulator.exe" prepare() test.capture [[ Command="..\bin\emulator.exe" ]] end -- -- If a working directory is provided, it should be specified relative to -- the project. -- function suite.workingDir_onRelativePath() location "build" debugdir "bin/debug" prepare() test.capture [[ WorkingDirectory="..\bin\debug" ]] end -- -- Make sure debug arguments are being written. -- function suite.commandArguments_onDebugArgs() debugargs { "arg1", "arg2" } prepare() test.capture [[ CommandArguments="arg1 arg2" ]] end -- -- Make sure environment variables are being written. -- function suite.environmentVarsSet_onDebugEnvs() debugenvs { "key=value" } prepare() test.capture [[ Environment="key=value" ]] end -- -- Make sure quotes around environment variables are properly escaped. -- function suite.environmentVarsEscaped_onQuotes() debugenvs { 'key="value"' } prepare() test.capture [[ Environment="key=&quot;value&quot;" ]] end -- -- If multiple environment variables are specified, make sure they get -- separated properly. -- function suite.environmentVars_onMultipleValues() debugenvs { "key=value", "foo=bar" } prepare() test.capture [[ Environment="key=value&#x0A;foo=bar" ]] end -- -- Make sure that environment merging is turned off if the build -- flag is set. -- function suite.environmentVarsSet_onDebugEnvs() debugenvs { "key=value" } flags { "DebugEnvsDontMerge" } prepare() test.capture [[ Environment="key=value" EnvironmentMerge="false" ]] end
bsd-3-clause
WAKAMAZU/sile_fe
packages/pdf.lua
2
3304
if SILE.outputter ~= SILE.outputters.libtexpdf then SU.error("pdf package requires libtexpdf backend") end local pdf = require("justenoughlibtexpdf") SILE.registerCommand("pdf:destination", function (o,c) local name = SU.required(o, "name", "pdf:bookmark") SILE.typesetter:pushHbox({ value = nil, height = 0, width = 0, depth = 0, outputYourself= function (self, typesetter) pdf.destination(name, typesetter.frame.state.cursorX, SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY) end }); end) SILE.registerCommand("pdf:bookmark", function (o,c) local dest = SU.required(o, "dest", "pdf:bookmark") local title = SU.required(o, "title", "pdf:bookmark") local level = o.level or 1 -- Added UTF8 to UTF16-BE conversion -- For annotations and bookmarks, text strings must be encoded using -- either PDFDocEncoding or UTF16-BE with a leading byte-order marker. -- As PDFDocEncoding supports only limited character repertoire for -- European languages, we use UTF-16BE for internationalization. local ustr = SU.utf8_to_utf16be(title) SILE.typesetter:pushHbox({ value = nil, height = 0, width = 0, depth = 0, outputYourself= function () local d = "<</Title<"..ustr..">/A<</S/GoTo/D("..dest..")>>>>" pdf.bookmark(d, level) end }); end) if SILE.Commands.tocentry then SILE.scratch.pdf = { dests = {}, dc = 1 } local oldtoc = SILE.Commands.tocentry SILE.Commands.tocentry = function (o,c) SILE.call("pdf:destination", { name = "dest"..SILE.scratch.pdf.dc } ) SILE.call("pdf:bookmark", { title = c[1], dest = "dest"..SILE.scratch.pdf.dc, level = o.level }) oldtoc(o,c) SILE.scratch.pdf.dc = SILE.scratch.pdf.dc + 1 end end SILE.registerCommand("pdf:link", function (o,c) local dest = SU.required(o, "dest", "pdf:link") local llx, lly SILE.typesetter:pushHbox({ value = nil, height = 0, width = 0, depth = 0, outputYourself= function (self,typesetter) llx = typesetter.frame.state.cursorX lly = SILE.documentState.paperSize[2] - typesetter.frame.state.cursorY pdf.begin_annotation() end }); local hbox = SILE.Commands["hbox"]({}, c) -- hack SILE.typesetter:debugState() SILE.typesetter:pushHbox({ value = nil, height = 0, width = 0, depth = 0, outputYourself= function (self,typesetter) local d = "<</Type/Annot/Subtype/Link/C [ 1 0 0 ]/A<</S/GoTo/D("..dest..")>>>>" pdf.end_annotation(d, llx, lly, typesetter.frame.state.cursorX, SILE.documentState.paperSize[2] -typesetter.frame.state.cursorY + hbox.height); end });end) return { documentation = [[\begin{document} The \code{pdf} package enables (basic) support for PDF links and table-of-contents entries. It provides the three commands \command{\\pdf:destination}, \command{\\pdf:link} and \command{\\pdf:bookmark}. The \command{\\pdf:destination} parameter creates a link target; it expects a parameter called \code{name} to uniquely identify the target. To create a link to that location in the document, use \code{\\pdf:link[dest=\goodbreak{}name]\{link content\}}. If the \code{pdf} package is loaded after the \code{tableofcontents} package (e.g. in a document with the \code{book} class), then a PDF document outline will be generated. \end{document}]] }
mit
anshkumar/yugioh-glaze
assets/script/c74416224.lua
5
1724
--ブラック・レイ・ランサー function c74416224.initial_effect(c) --xyz summon aux.AddXyzProcedure(c,aux.FilterBoolFunction(Card.IsAttribute,ATTRIBUTE_WATER),3,2) c:EnableReviveLimit() --disable local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DISABLE) e1:SetDescription(aux.Stringid(74416224,0)) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCountLimit(1) e1:SetRange(LOCATION_MZONE) e1:SetCost(c74416224.cost) e1:SetTarget(c74416224.target) e1:SetOperation(c74416224.operation) c:RegisterEffect(e1) end function c74416224.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end e:GetHandler():RemoveOverlayCard(tp,1,1,REASON_COST) end function c74416224.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsFaceup() end if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0) end function c74416224.operation(e,tp,eg,ep,ev,re,r,rp,chk) local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e2) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c54514594.lua
3
1275
--ヴォルカニック・ハンマー function c54514594.initial_effect(c) --damage local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(54514594,0)) e1:SetCategory(CATEGORY_DAMAGE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1) e1:SetRange(LOCATION_MZONE) e1:SetCost(c54514594.cost) e1:SetTarget(c54514594.target) e1:SetOperation(c54514594.operation) c:RegisterEffect(e1) end function c54514594.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():GetAttackAnnouncedCount()==0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END) e:GetHandler():RegisterEffect(e1) end function c54514594.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_GRAVE,0,1,nil,0x32) end Duel.SetTargetPlayer(1-tp) Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,0) end function c54514594.operation(e,tp,eg,ep,ev,re,r,rp) local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER) local d=Duel.GetMatchingGroupCount(Card.IsSetCard,tp,LOCATION_GRAVE,0,nil,0x32)*200 Duel.Damage(p,d,REASON_EFFECT) end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c68084557.lua
7
2193
--機械竜 パワー・ツール function c68084557.initial_effect(c) --synchro summon aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1) c:EnableReviveLimit() --draw local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DRAW) e1:SetDescription(aux.Stringid(68084557,0)) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_DAMAGE_STEP) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_EQUIP) e1:SetCountLimit(1,68084557) e1:SetCondition(c68084557.drcon) e1:SetTarget(c68084557.drtg) e1:SetOperation(c68084557.drop) c:RegisterEffect(e1) --equip change local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(68084557,1)) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetCode(EVENT_FREE_CHAIN) e2:SetTarget(c68084557.eqtg) e2:SetOperation(c68084557.eqop) c:RegisterEffect(e2) end function c68084557.drcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetTurnPlayer()==tp end function c68084557.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end function c68084557.drop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) end function c68084557.eqfilter(c,ec) return c:IsType(TYPE_EQUIP) and c:GetEquipTarget() and c:GetEquipTarget()~=ec and c:CheckEquipTarget(ec) end function c68084557.eqtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_SZONE) and c68084557.eqfilter(chkc,e:GetHandler()) end if chk==0 then return Duel.IsExistingTarget(c68084557.eqfilter,tp,LOCATION_SZONE,LOCATION_SZONE,1,nil,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c68084557.eqfilter,tp,LOCATION_SZONE,LOCATION_SZONE,1,1,nil,e:GetHandler()) end function c68084557.eqop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToEffect(e) and c:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:CheckEquipTarget(c) then Duel.Equip(tp,tc,c) end end
gpl-2.0
anshkumar/yugioh-glaze
assets/script/c28890974.lua
5
1806
--光神化 function c28890974.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(c28890974.target) e1:SetOperation(c28890974.activate) c:RegisterEffect(e1) end function c28890974.filter(c,e,tp) return c:IsRace(RACE_FAIRY) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c28890974.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c28890974.filter,tp,LOCATION_HAND,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_HAND) end function c28890974.activate(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c28890974.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc then local atk=tc:GetAttack() if Duel.SpecialSummonStep(tc,0,tp,tp,false,false,POS_FACEUP) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetCode(EFFECT_SET_ATTACK) e1:SetValue(atk/2) e1:SetReset(RESET_EVENT+0x1fe0000) tc:RegisterEffect(e1,true) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e2:SetRange(LOCATION_MZONE) e2:SetCode(EVENT_PHASE+PHASE_END) e2:SetOperation(c28890974.desop) e2:SetReset(RESET_EVENT+0x1fe0000) e2:SetCountLimit(1) tc:RegisterEffect(e2,true) Duel.SpecialSummonComplete() end end end function c28890974.desop(e,tp,eg,ep,ev,re,r,rp) Duel.Destroy(e:GetHandler(),REASON_EFFECT) end
gpl-2.0