def test_complex_message(self): message = ComplexMessage(['Hello, ', RefAttach('user_id_here', '@world')]) text, attachments = smart_split_complex_message(message) self.assertEqual(text, 'Hello, @world') self.assertEqual(attachments, [{ 'loci': [[7, 6]], 'type': 'mentions', 'user_ids': ['user_id_here'] }])
def post(self, message: "ComplexMessage") -> "DirectMessage": text, attachments = smart_split_complex_message(message) return DirectMessageCreateRequest( self.gmi, self.gmi.user.get().user_id, self.other_user.user_id, text, attachments, ).result
def post(self, text): from lowerpines.message import smart_split_complex_message text, attachments = smart_split_complex_message(text) message = TestMessage(self.gmi, group_id=self.group_id, text=text, attachments=attachments) message.favorited_by = [] message.name = self.name message.save()
def test_complex_message(self) -> None: message = ComplexMessage( ["Hello, ", RefAttach("user_id_here", "@world")]) text, attachments = smart_split_complex_message(message) self.assertEqual(text, "Hello, @world") self.assertEqual( attachments, [{ "loci": [[7, 6]], "type": "mentions", "user_ids": ["user_id_here"] }], )
def post(self, message): text, attachments = smart_split_complex_message(message) obj = Message(self.gmi, self.group_id, str(datetime.now()), text, attachments) obj.save() return obj
def test_str_message(self): text, attachments = smart_split_complex_message('Hello!') self.assertEqual(text, 'Hello!') self.assertEqual(attachments, [])
def test_bad_input(self) -> None: with self.assertRaises(ValueError): smart_split_complex_message(1) # type: ignore
def test_str_message(self) -> None: text, attachments = smart_split_complex_message("Hello!") self.assertEqual(text, "Hello!") self.assertEqual(attachments, [])
def post(self, message: Union["ComplexMessage", str]) -> None: text, attachments = smart_split_complex_message(message) BotPostRequest(self.gmi, self.bot_id, text, attachments)
def post(self, text): text, attachments = smart_split_complex_message(text) BotPostRequest(self.gmi, self.bot_id, text, attachments)