MCPcopy Index your code
hub / github.com/wechaty/python-wechaty / FakePuppet

Class FakePuppet

src/wechaty/fake_puppet.py:229–772  ·  view source on GitHub ↗

puppet interface class, which is the abstract of puppet implementation. python-wechaty-puppet-XX can be all of the protocol of IM software.

Source from the content-addressed store, hash-verified

227
228
229class FakePuppet(Puppet, FakeContactManagerMixin, FakeMessageManagerMixin, FakeRoomManagerMixin):
230 """
231 puppet interface class, which is the abstract of puppet implementation.
232
233 python-wechaty-puppet-XX can be all of the protocol of IM software.
234 """
235
236 def __init__(self, options: PuppetOptions, name: str = 'puppet') -> None:
237 """_summary_
238
239 Args:
240 options (PuppetOptions): _description_
241 name (str, optional): _description_. Defaults to 'puppet'.
242 """
243 super().__init__(options=options, name=name)
244 self.name: str = name
245 self.options = options
246 self.emitter = AsyncIOEventEmitter()
247
248 self.login_user_id = self.add_random_fake_contact()
249
250 def add_random_fake_contact_message(
251 self,
252 msg: Optional[str] = None,
253 contact_id: Optional[str] = None
254 ) -> str:
255 """_summary_
256
257 Args:
258 msg (Optional[str], optional): _description_. Defaults to None.
259 contact_id (Optional[str], optional): _description_. Defaults to None.
260
261 Returns:
262 str: _description_
263 """
264 if not msg:
265 msg = str(uuid4())
266 if not contact_id:
267 contact_id = random.choice(list(self._contact_payloads.keys()))
268
269 message = MessagePayload(
270 id=str(uuid4()),
271 from_id=contact_id,
272 text=msg
273 )
274 self.add_fake_message(message)
275 return message.id
276
277 def add_random_fake_room_message(
278 self,
279 msg: Optional[str] = None,
280 contact_id: Optional[str] = None,
281 room_id: Optional[str] = None
282 ) -> str:
283 """_summary_
284
285 Args:
286 msg (Optional[str], optional): _description_. Defaults to None.

Callers 2

test_botFunction · 0.90
test_finderMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_botFunction · 0.72
test_finderMethod · 0.72