Skip to content

Commit

Permalink
DMs bug fix: handle args to commands that don't take them
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Feb 5, 2025
1 parent 4e1692e commit 709e06b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def reply(text, type=None):

# dispatch!
kwargs = {}
if cmd_arg:
if arg and cmd_arg:
kwargs['arg'] = cmd_arg
if arg == 'handle':
kwargs['to_user'] = to_user
Expand Down
27 changes: 15 additions & 12 deletions tests/test_dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,18 +463,21 @@ def test_receive_help_strip_mention_of_bot(self):
self.assert_replied(OtherFake, alice, '?', "<p>Hi! I'm a friendly bot")

def test_receive_did_atproto(self):
self.make_user(id='bsky.brid.gy', cls=Web)
alice = self.make_user(id='efake:alice', cls=ExplicitFake,
enabled_protocols=['atproto'], obj_as1={'x': 'y'},
copies=[Target(protocol='atproto', uri='did:abc:123')])
obj = Object(our_as1={
**DM_BASE,
'to': ['bsky.brid.gy'],
'content': 'did',
})
self.assertEqual(('OK', 200), receive(from_user=alice, obj=obj))
self.assert_replied(ATProto, alice, '?',
'Your DID is <code>did:abc:123</code>')
for content in 'did', 'did foo':
ExplicitFake.sent = []
with self.subTest(content=content):
self.make_user(id='bsky.brid.gy', cls=Web)
alice = self.make_user(id='efake:alice', cls=ExplicitFake,
enabled_protocols=['atproto'], obj_as1={'x': 'y'},
copies=[Target(protocol='atproto', uri='did:abc:123')])
obj = Object(our_as1={
**DM_BASE,
'to': ['bsky.brid.gy'],
'content': 'did',
})
self.assertEqual(('OK', 200), receive(from_user=alice, obj=obj))
self.assert_replied(ATProto, alice, '?',
'Your DID is <code>did:abc:123</code>')

def test_receive_block(self):
alice, bob = self.make_alice_bob()
Expand Down

0 comments on commit 709e06b

Please sign in to comment.