Skip to content

Instantly share code, notes, and snippets.

@samjaninf
Created April 11, 2018 05:19
Show Gist options
  • Save samjaninf/41f6327401419c7cdc62321001ef0df1 to your computer and use it in GitHub Desktop.
Save samjaninf/41f6327401419c7cdc62321001ef0df1 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.0">
<TriggerPackage>
<TriggerGroup isActive="yes" isFolder="yes" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>DBI Triggers Group</name>
<script></script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList/>
<regexCodePropertyList/>
<Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>Chat</name>
<script>selectCurrentLine()
copy()
appendBuffer(&quot;Chat&quot;)
deleteLine()
</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>You say</string>
<string>-&lt;OOC&gt;-</string>
<string>[FreedomOfSpeech]</string>
<string>[MuSiC]</string>
<string>&gt;&gt;Human&lt;&lt;</string>
<string>(QUESTION)</string>
<string>[TRAFFIC-</string>
<string>{WARTALK|</string>
<string>You tell</string>
<string>tells you</string>
<string>-=[Misc|</string>
</regexCodeList>
<regexCodePropertyList>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
<integer>0</integer>
</regexCodePropertyList>
</Trigger>
<Trigger isActive="yes" isFolder="no" isTempTrigger="no" isMultiline="no" isPerlSlashGOption="no" isColorizerTrigger="no" isFilterTrigger="no" isSoundTrigger="no" isColorTrigger="no" isColorTriggerFg="no" isColorTriggerBg="no">
<name>maybe empty</name>
<script>selectCurrentLine()
deleteLine()</script>
<triggerType>0</triggerType>
<conditonLineDelta>0</conditonLineDelta>
<mStayOpen>0</mStayOpen>
<mCommand></mCommand>
<packageName></packageName>
<mFgColor>#ff0000</mFgColor>
<mBgColor>#ffff00</mBgColor>
<mSoundFile></mSoundFile>
<colorTriggerFgColor>#000000</colorTriggerFgColor>
<colorTriggerBgColor>#000000</colorTriggerBgColor>
<regexCodeList>
<string>^$</string>
</regexCodeList>
<regexCodePropertyList>
<integer>1</integer>
</regexCodePropertyList>
</Trigger>
</TriggerGroup>
</TriggerPackage>
<TimerPackage/>
<AliasPackage>
<AliasGroup isActive="yes" isFolder="yes">
<name>deleteOldProfiles</name>
<script></script>
<command></command>
<packageName>deleteOldProfiles</packageName>
<regex></regex>
<Alias isActive="yes" isFolder="no">
<name>delete old profiles</name>
<script>deleteOldProfiles(matches[3], matches[2]==&quot;maps&quot;)
--Syntax examples: &quot;delete old profiles&quot; -&gt; deletes profiles older than 31 days
-- &quot;delete old maps 10&quot; -&gt; deletes maps older than 10 days</script>
<command></command>
<packageName></packageName>
<regex>^delete old (profiles|maps)(?: (\d+))?$</regex>
</Alias>
</AliasGroup>
<AliasGroup isActive="yes" isFolder="yes">
<name>echo</name>
<script></script>
<command></command>
<packageName>echo</packageName>
<regex></regex>
<Alias isActive="yes" isFolder="no">
<name>`echo</name>
<script>local s = matches[2]
s = string.gsub(s, &quot;%$&quot;, &quot;\n&quot;)
feedTriggers(&quot;\n&quot; .. s .. &quot;\n&quot;)
echo(&quot;\n&quot;)</script>
<command></command>
<packageName></packageName>
<regex>`echo (.+)</regex>
</Alias>
</AliasGroup>
<AliasGroup isActive="yes" isFolder="yes">
<name>run-lua-code-v4</name>
<script></script>
<command></command>
<packageName>run-lua-code-v4</packageName>
<regex></regex>
<Alias isActive="yes" isFolder="no">
<name>run lua code</name>
<script>local f,e = loadstring(&quot;return &quot;..matches[2])
if not f then
f,e = assert(loadstring(matches[2]))
end
local r = f()
if r ~= nil then display(r) end</script>
<command></command>
<packageName></packageName>
<regex>^lua (.*)$</regex>
</Alias>
</AliasGroup>
</AliasPackage>
<ActionPackage/>
<ScriptPackage>
<ScriptGroup isActive="yes" isFolder="yes">
<name>deleteOldProfiles</name>
<packageName>deleteOldProfiles</packageName>
<script></script>
<eventHandlerList/>
<Script isActive="yes" isFolder="no">
<name>deleteOldProfiles</name>
<packageName></packageName>
<script>function deleteOldProfiles(keepdays_arg, delete_maps)
--[[
Deletes old profiles/maps in the &quot;current&quot;/&quot;map&quot; folders of the Mudlet home directory.
The following files are NOT deleted:
- Files newer than the amount of days specified as an argument to deleteOldProfiles(), or 31 days if not specified.
- One file for every month before that. Specifically: The first available file of every month prior to this.
Setting the second argument to true will delete maps instead of profiles. (e.g. deleteOldProfiles(10, true))
--]]
local keepdays = tonumber(keepdays_arg) or 31
local profile_table = {}
local used_last_mod_months = {}
local slash = (string.char(getMudletHomeDir():byte()) == &quot;/&quot;) and &quot;/&quot; or &quot;\\&quot;
local dirpath = getMudletHomeDir()..slash..(delete_maps and &quot;map&quot; or &quot;current&quot;)
local delnum = 0
-- Traverse the profiles folder and create a table of files:
for filename in lfs.dir(dirpath) do
if filename~=&quot;.&quot; and filename~=&quot;..&quot; then
profile_table[#profile_table+1] = {name = filename, last_mod = lfs.attributes(dirpath..slash..filename, &quot;modification&quot;)}
end
end
-- Sort the table according to last modification date from old to new:
table.sort(profile_table, function (a,b) return a.last_mod &lt; b.last_mod end)
echo(string.format(&quot;\nDeleting old %s. Files newer than %d days and one profile for every month before that will be kept.&quot;, delete_maps and &quot;maps&quot; or &quot;profiles&quot;, keepdays))
for i,v in ipairs(profile_table) do
local days = math.floor(os.difftime(os.time(), v.last_mod)/86400)
local last_mod_month = os.date(&quot;%Y/%m&quot;, v.last_mod)
if days &gt; keepdays then
-- For profiles older than X days, check if we already kept a table for this month:
if not table.contains(used_last_mod_months, last_mod_month) then
-- If not, do nothing and mark this month as &quot;kept&quot;.
used_last_mod_months[#used_last_mod_months+1] = last_mod_month
else
-- Otherwise remove the file:
local success, errorstring = os.remove(dirpath..slash..v.name)
if success then
delnum = delnum + 1
else
cecho(&quot;\n&lt;red&gt;ERROR: &quot;..errorstring)
end
end
end
end
echo(string.format(&quot;\nDeletion complete. %d/%d files were removed successfully.&quot;, delnum, #profile_table))
end
</script>
<eventHandlerList/>
</Script>
</ScriptGroup>
<ScriptGroup isActive="yes" isFolder="yes">
<name>DBI Scripts</name>
<packageName></packageName>
<script>-------------------------------------------------
-- Put your Lua functions here. --
-- --
-- Note that you can also use external Scripts --
-------------------------------------------------
</script>
<eventHandlerList/>
<Script isActive="yes" isFolder="no">
<name>ChatScript</name>
<packageName></packageName>
<script>-------------------------------------------------
-- Put your Lua functions here. --
-- --
-- Note that you can also use external Scripts --
-------------------------------------------------
Chat = Geyser.MiniConsole:new({
name=&quot;Chat&quot;,
x=&quot;60%&quot;, y=0,
wrapAt = 100,
width=&quot;40%&quot;, height=&quot;100%&quot;,
})
--clearWindow(&quot;Chat&quot;)
--enableScrollBar(ChatWindow)
--ChatWindow:setColor(&quot;pink&quot;)
</script>
<eventHandlerList/>
</Script>
</ScriptGroup>
</ScriptPackage>
<KeyPackage/>
</MudletPackage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment