MCPcopy
hub / github.com/wechaty/python-wechaty / Wechaty

Class Wechaty

src/wechaty/wechaty.py:130–848  ·  view source on GitHub ↗

A robot is a Wechaty instance, \ and all user-related modules should be accessed through the instance, \ which ensures consistency of service connections. \ In addition, all logic should be organized in the form of plug-ins and \ event subscriptions to ensure isolation between d

Source from the content-addressed store, hash-verified

128
129# pylint:disable=R0902,R0904
130class Wechaty(AsyncIOEventEmitter):
131 """
132 A robot is a Wechaty instance, \
133 and all user-related modules should be accessed through the instance, \
134 which ensures consistency of service connections. \
135 In addition, all logic should be organized in the form of plug-ins and \
136 event subscriptions to ensure isolation between different businesses.
137 """
138
139 _global_instance: Optional['Wechaty'] = None
140
141 # define the event
142
143 # save login user contact_id
144 contact_id: str
145
146 def __init__(self, options: Optional[WechatyOptions] = None):
147 """
148 init Wechaty instance
149 Args:
150 options: WechatyOptions
151 Examples:
152 >>> from wechaty import Wechaty
153 >>> bot = Wechaty()
154 """
155 super().__init__()
156
157 # 1. int the puppet options
158 if options is None:
159 options = WechatyOptions(puppet='wechaty-puppet-service')
160
161 if options.puppet_options is None:
162 options.puppet_options = PuppetOptions()
163
164 options.puppet_options.token = options.puppet_options.token or options.token
165 options.puppet_options.end_point = options.puppet_options.end_point or options.endpoint
166 options.puppet = self._load_puppet(options)
167
168 # 2. init the scheduler options
169 self._options = options
170
171 # pylint: disable=C0103
172 self.Tag: Type[Tag] = Tag
173 # pylint: disable=C0103
174 self.Contact: Type[Contact] = Contact
175 # pylint: disable=C0103
176 self.ContactSelf: Type[ContactSelf] = ContactSelf
177 # pylint: disable=C0103
178 self.Friendship: Type[Friendship] = Friendship
179 # pylint: disable=C0103
180 self.Message: Type[Message] = Message
181 # pylint: disable=C0103
182 self.Room: Type[Room] = Room
183 # pylint: disable=C0103
184 self.Image: Type[Image] = Image
185 # pylint: disable=C0103
186 self.RoomInvitation: Type[RoomInvitation] = RoomInvitation
187 self.Favorite: Type[Favorite] = Favorite

Callers 7

test_botFunction · 0.90
test_finderMethod · 0.90
test_constructorFunction · 0.90
test_schedulerFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by 4

test_botFunction · 0.72
test_finderMethod · 0.72
test_constructorFunction · 0.72
test_schedulerFunction · 0.72