Skip to content

Instantly share code, notes, and snippets.

@Brawl345
Last active August 25, 2016 00:55
Show Gist options
  • Save Brawl345/18e98229c8c29da6843a10e329d45a02 to your computer and use it in GitHub Desktop.
Save Brawl345/18e98229c8c29da6843a10e329d45a02 to your computer and use it in GitHub Desktop.
Brawlbot Alternative Plugins
-- Put this in the same folder as the Brawlbot v2 and run it. It will only be a dry run and show everything that'll be migrated.
-- There NEEDN'T be any new data (with a -) in redis! This is IMPORTANT!
-- Run this on your NEW Redis Server that your bot will use obvisouly
local config = require('config')
local redis = (loadfile './otouto/redis.lua')()
-- local redis = (loadfile './miku/redis.lua')() -- Uncomment for Mikubot v2
local dry_run = true -- change to false for the real deal
if dry_run then
print('--- THIS IS A DRY RUN! NO DATA WILL BE MIGRATED! ---')
end
print('--- MIGRATION STARTED ---')
-- AFK
local keys = redis:keys('afk:*')
for k,v in pairs(keys) do
local string_after = v:match('afk:(.+)')
print('afk:'..string_after..' -> afk:-'..string_after)
if not dry_run then
redis:rename('afk:'..string_after, 'afk:-'..string_after)
end
end
-- BANHAMMER
local keys = redis:keys('banned:*')
for k,v in pairs(keys) do
local string_after = v:match('banned:(.+)')
print('banned:'..string_after..' -> banned:-'..string_after)
if not dry_run then
redis:rename('banned:'..string_after, 'banned:-'..string_after)
end
end
-- CHAT
local keys = redis:keys('chat:*')
for k,v in pairs(keys) do
local string_after = v:match('chat:(.+)')
print('chat:'..string_after..' -> chat:-'..string_after)
if not dry_run then
redis:rename('chat:'..string_after, 'chat:-'..string_after)
end
end
-- MSGS
local keys = redis:keys('msgs:*:*')
for k,v in pairs(keys) do
local string_middle = v:match('msgs:(.+):.+')
local string_after = v:match('msgs:.+:(.+)')
print('msgs:'..string_middle..':'..string_after..' -> msgs:'..string_middle..':-'..string_after)
if not dry_run then
redis:rename('msgs:'..string_middle..':'..string_after, 'msgs:'..string_middle..':-'..string_after)
end
end
-- WHITELIST
local keys = redis:keys('whitelist:chat#id*')
for k,v in pairs(keys) do
local string_after = v:match('whitelist:chat#id(.+)')
print('whitelist:chat#id'..string_after..' -> whitelist:chat#id-'..string_after)
if not dry_run then
redis:rename('whitelist:chat#id'..string_after, 'whitelist:chat#id-'..string_after)
end
end
-- RSS
local keys = redis:keys('rss:chat#id*')
for k,v in pairs(keys) do
local string_after = v:match('rss:chat#id(.+)')
print('rss:chat#id'..string_after..' -> rss:chat#id-'..string_after)
if not dry_run then
redis:rename('rss:chat#id'..string_after, 'rss:chat#id-'..string_after)
end
end
-- RSS Subscriptions
local keys = redis:keys('rss:*:subs')
if keys then
for k,v in pairs(keys) do
local feed = string.match(v, "rss:(.+):subs")
local members = redis:smembers('rss:'..feed..':subs')
print('rss:'..feed..':subs - Changing IDs in set...')
for k,v in pairs(members) do
local string_after = v:match('chat#id(.+)')
if string_after then
print('chat#id'..string_after..' -> chat#id-'..string_after)
if not dry_run then
redis:srem('rss:'..feed..':subs', 'chat#id'..string_after)
redis:sadd('rss:'..feed..':subs', 'chat#id-'..string_after)
end
end
end
end
print('-- MIGRATION ENDED ---')
if dry_run then
print('--- DRY RUN ENDED ---')
end
end
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment