Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ usersbackup.txt

# Distribution / packaging
.Python
bin
build/
develop-eggs/
dist/
Expand All @@ -20,6 +21,7 @@ eggs/
.eggs/
lib/
lib64/
lib64
parts/
sdist/
var/
Expand Down Expand Up @@ -132,6 +134,7 @@ ENV/
env.bak/
venv.bak/
bot-env/
pyvenv.cfg

# Spyder project settings
.spyderproject
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Autoproxy settings work the same way on RevoltKit as they do [on PluralKit](http
- `rk;auto latch` - Sets your system's autoproxy in this server to proxy the last manually proxied member.

##### RevoltKit's Latch Mode
Unlike PluralKit where the last member to proxy in a specific server will be used again when posting in the same server, RevoltKit's `latch` setting currently latches across all of Revolt and has no timeout. You will still need to turn it on in each server, however once the mode is set to `latch` the last proxied member for that mode is tracked across all servers.
~~Unlike PluralKit where the last member to proxy in a specific server will be used again when posting in the same server, RevoltKit's `latch` setting currently latches across all of Revolt and has no timeout.~~ RevoltKit's latch setting is similar to PluralKit's. You will need to turn it on in each server you want the latch to work in, and it will track per-server.

#### Optional: Log Switches using RevoltKit
When [authorized to do so](#Optional:Authorize-RevoltKit), RevoltKit can run all of the switch related commands that PluralKit can; [see more info on those here](https://pluralkit.me/commands/#switching-commands). Please note that while all the switch commands are supported, switch flags (such as the `-append` flag in the command `rk;sw edit -append [Name]`) are not supported yet.
34 changes: 22 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def auto(message: Message):
sid = message.channel.id
else:
sid = message.channel.server_id
autoproxy = next((x for x in user['auto'] if x['server'] == sid), None)
autoproxy = next((x for x in user['auto'] if x['server'] == sid), None)
if arg == f"{prefix}auto":
if autoproxy is None:
user['auto'].append({'mode': AutoproxyMode.OFF.value, 'server':sid})
Expand All @@ -248,7 +248,7 @@ async def auto(message: Message):
await message.channel.send(content="Will autoproxy with your front in this server.")
case AutoproxyMode.LATCH.value:
user['auto'].append({'mode': AutoproxyMode.LATCH.value, 'server': sid})
await message.channel.send(content="Will autoproxy with latch in this server. (note: current latch is global)")
await message.channel.send(content="Will autoproxy with latch in this server.")
case _:
await message.channel.send(content=f"Incorrect argument, use {prefix}auto [off/front/latch]")

Expand Down Expand Up @@ -429,7 +429,7 @@ async def on_ready(_) -> None:
Command(name="switch delete", description=f"sw delete", run=switch_delete, shorthand=True)
Command(name="switch", description=f"usage: {prefix}switch [name] | Log a new switch with the specified members (Requires Auth)\nusage: {prefix}switch move 1d 6h 3m | Move a switch to some time ago (Requires Auth)\nusage: {prefix}switch edit | Edit your current switch (Requires Auth)\nusage: {prefix}switch delete | Delete your current switch (Requires Auth)", run=switch)
Command(name="case", description=f"usage: {prefix}case | Toggle your proxy's case sensitivity", run=case)
Command(name="autoproxy", description=f"usage: {prefix}auto [front/latch] | Set your autoproxy state per-server\n> Front mode will automatically use the first current fronter, while Latch mode will proxy as whoever proxied last *anywhere on Stoat*", run=auto)
Command(name="autoproxy", description=f"usage: {prefix}auto [front/latch] | Set your autoproxy state per-server\n> Front mode will automatically use the first current fronter, while Latch mode will proxy as whoever proxied last in that server", run=auto)
Command(name="auto", description="ap shorthand", run=auto, shorthand=True)
Command(name="ap", description="ap shorthand", run=auto, shorthand=True)
Command(name="sw out", description=f"sw out", run=switch_out, shorthand=True)
Expand Down Expand Up @@ -501,7 +501,18 @@ async def send(message: Message):
return
if not user['proxy']:
return

if type(message.channel) is not pyvolt.TextChannel:
sid = message.channel.id
else:
sid = message.channel.server_id

if message.content.startswith("\\\\"):
user['latch'] = False
auto = next((x for x in user['auto'] if x['server'] == sid), None)
if auto is not None and auto['mode'] == 'latch':
auto['member'] = None
return
if message.content.startswith("\\"):
user['latch'] = False
return
Expand All @@ -527,7 +538,9 @@ async def send(message: Message):
if pt(check):
user['latch'] = True
proxier = await client.get_member(member['id'])
user['members'].insert(0, user['members'].pop(user['members'].index(member)))
auto = next((x for x in user['auto'] if x['server'] == sid), None)
if auto is not None and auto['mode'] == 'latch':
auto['member'] = member['id']
if pt.prefix is not None:
content = remove_prefix_ci(content, pre)
if pt.suffix is not None:
Expand Down Expand Up @@ -557,18 +570,16 @@ async def send(message: Message):
if pt(check):
user['latch'] = True
proxier = await client.get_member(member['id'])
user['members'].insert(0, user['members'].pop(user['members'].index(member)))
auto = next((x for x in user['auto'] if x['server'] == sid), None)
if auto is not None and auto['mode'] == 'latch':
auto['member'] = member['id']
if pt.prefix is not None:
content = remove_prefix_ci(emoji.emojize(content, language='alias'), pre)
if pt.suffix is not None:
content = remove_suffix_ci(emoji.emojize(content, language='alias'), suf)
break

if proxier is None:
if type(message.channel) is not pyvolt.TextChannel:
sid = message.channel.id
else:
sid = message.channel.server_id
auto = next((x for x in user['auto'] if x['server'] == sid), None)
if auto is None:
return
Expand All @@ -580,9 +591,8 @@ async def send(message: Message):
proxier = member
break
case AutoproxyMode.LATCH.value:
for member in user['members']:
proxier = await client.get_member(member['id'])
break
if auto.get('member') is not None:
proxier = await client.get_member(auto['member'])

except Unauthorized:
if user['error']:
Expand Down