mypy: Add annotations for encrypt.
This commit is contained in:
parent
b382eacd18
commit
1cdb0bffe6
|
@ -1,4 +1,6 @@
|
||||||
def encrypt(text):
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
def encrypt(text: str) -> str:
|
||||||
# This is where the actual ROT13 is applied
|
# This is where the actual ROT13 is applied
|
||||||
# WHY IS .JOIN NOT WORKING?!
|
# WHY IS .JOIN NOT WORKING?!
|
||||||
textlist = list(text)
|
textlist = list(text)
|
||||||
|
@ -21,18 +23,18 @@ class EncryptHandler(object):
|
||||||
It encrypts/decrypts messages starting with @mention-bot.
|
It encrypts/decrypts messages starting with @mention-bot.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def usage(self):
|
def usage(self) -> str:
|
||||||
return '''
|
return '''
|
||||||
This bot uses ROT13 encryption for its purposes.
|
This bot uses ROT13 encryption for its purposes.
|
||||||
It responds to me starting with @mention-bot.
|
It responds to me starting with @mention-bot.
|
||||||
Feeding encrypted messages into the bot decrypts them.
|
Feeding encrypted messages into the bot decrypts them.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def handle_message(self, message, bot_handler):
|
def handle_message(self, message: Dict[str, str], bot_handler: Any) -> None:
|
||||||
bot_response = self.get_bot_encrypt_response(message)
|
bot_response = self.get_bot_encrypt_response(message)
|
||||||
bot_handler.send_reply(message, bot_response)
|
bot_handler.send_reply(message, bot_response)
|
||||||
|
|
||||||
def get_bot_encrypt_response(self, message):
|
def get_bot_encrypt_response(self, message: Dict[str, str]) -> str:
|
||||||
original_content = message['content']
|
original_content = message['content']
|
||||||
temp_content = encrypt(original_content)
|
temp_content = encrypt(original_content)
|
||||||
send_content = "Encrypted/Decrypted text: " + temp_content
|
send_content = "Encrypted/Decrypted text: " + temp_content
|
||||||
|
|
|
@ -5,7 +5,7 @@ from zulip_bots.test_lib import StubBotTestCase
|
||||||
class TestEncryptBot(StubBotTestCase):
|
class TestEncryptBot(StubBotTestCase):
|
||||||
bot_name = "encrypt"
|
bot_name = "encrypt"
|
||||||
|
|
||||||
def test_bot(self):
|
def test_bot(self) -> None:
|
||||||
dialog = [
|
dialog = [
|
||||||
("", "Encrypted/Decrypted text: "),
|
("", "Encrypted/Decrypted text: "),
|
||||||
("Let\'s Do It", "Encrypted/Decrypted text: Yrg\'f Qb Vg"),
|
("Let\'s Do It", "Encrypted/Decrypted text: Yrg\'f Qb Vg"),
|
||||||
|
|
Loading…
Reference in a new issue