死磕itchat源码--__init__.py
itchat包中的__init__.py
是该库的入口;在该文件中的源码如下:
# -*- coding: utf-8 -*-
from . import content
from .core import Core
from .config import VERSION
from .log import set_logging
__version__ = VERSION
# 实例列表,添加处理微信的实例对象
instanceList = []
def new_instance():
"""
用于创建一个新的`Core`的实例化对象,并且返回,
newInstance = Core()是最终封装的实例化对象,封装了Storage,requests,等属性
"""
newInstance = Core()
instanceList.append(newInstance)
return newInstance
# 封装`Core`的实例化对象在`originInstance`
# `originInstance` = `newInstance` = `Core()`
originInstance = new_instance()
# I really want to use sys.modules[__name__] = originInstance
# but it makes auto-fill a real mess, so forgive me for my following **
# actually it toke me less than 30 seconds, god bless Uganda
# components.login
# 在components.login中实现重构
login = originInstance.login
get_QRuuid = originInstance.get_QRuuid
get_QR = originInstance.get_QR
check_login = originInstance.check_login
web_init = originInstance.web_init
show_mobile_login = originInstance.show_mobile_login
start_receiving = originInstance.start_receiving
get_msg = originInstance.get_msg
logout = originInstance.logout
# components.contact
# 在components.contact中实现重构
update_chatroom = originInstance.update_chatroom
update_friend = originInstance.update_friend
get_contact = originInstance.get_contact
get_friends = originInstance.get_friends
get_chatrooms = originInstance.get_chatrooms
get_mps = originInstance.get_mps
set_alias = originInstance.set_alias
set_pinned = originInstance.set_pinned
add_friend = originInstance.add_friend
get_head_img = originInstance.get_head_img
create_chatroom = originInstance.create_chatroom
set_chatroom_name = originInstance.set_chatroom_name
delete_member_from_chatroom = originInstance.delete_member_from_chatroom
add_member_into_chatroom = originInstance.add_member_into_chatroom
# components.messages
# 在components.login中实现重构
send_raw_msg = originInstance.send_raw_msg
send_msg = originInstance.send_msg
upload_file = originInstance.upload_file
send_file = originInstance.send_file
send_image = originInstance.send_image
send_video = originInstance.send_video
send = originInstance.send
revoke = originInstance.revoke
# components.hotreload
# 在components.hotreload中实现重构
dump_login_status = originInstance.dump_login_status
load_login_status = originInstance.load_login_status
# components.register
# 在components.register中实现重构
auto_login = originInstance.auto_login
configured_reply = originInstance.configured_reply
msg_register = originInstance.msg_register
run = originInstance.run
# other functions
search_friends = originInstance.search_friends
search_chatrooms = originInstance.search_chatrooms
search_mps = originInstance.search_mps
set_logging = set_logging
死磕itchat源码--__init__.py的更多相关文章
- 死磕itchat源码--core.py
core.py文件中的Core类定义了itchat的所有接口.且,仅仅是定义了接口,全部在component包中实现重构.其用法如下表述: 缺省 源码如下: # -*- encoding: utf-8 ...
- 死磕itchat源码--config.py
itchat的配置文件,源码: import os, platform # 版本及微信的url,二维码等 VERSION = '1.3.10' BASE_URL = 'https://login.we ...
- 死磕itchat源码--content.py
content.py中定义了接受消息的类型,即,用于注册消息函数时的参数类型.源码如下: TEXT = 'Text' MAP = 'Map' CARD = 'Card' NOTE = 'Note' S ...
- 死磕itchat源码--目录结构
阅读itchat源码时,先弄清itchat的目录结构 itchat │ config.py │ content.py │ core.py │ log.py │ returnvalues.py │ ut ...
- 死磕Spring源码之AliasRegistry
死磕Spring源码之AliasRegistry 父子关系 graph TD; AliasRegistry-->BeanDefinitionRegistry; 代码实现 作为bean定义的最顶层 ...
- 【死磕jeestie源码】类型后面三个点(String...)和数组(String[])的区别
类型后面三个点(String...),是从Java 5开始,Java语言对方法参数支持一种新写法,叫可变长度参数列表,其语法就是类型后跟...,表示此处接受的参数为0到多个Object类型的对象,或者 ...
- 死磕abstractqueuedsynchronizer源码
第一次写博客,先练练手. 1.AQS是什么? 在Lock中,用到了一个同步队列AQS,全称为AbstractQueuedSynchronizer,它是一个同步工具也是lock用来实现线程同步的核心组件 ...
- 【死磕jeesite源码】Jeesite配置定时任务
一.主要是注意XML文件中设置3个地方和类文件中配置 第一步配置: 第二步配置:注解扫描 第三步配置:开启任务 类中注解配置:如下 @Service 或者Component @Lazy(false) ...
- 【死磕jeesite源码】jeesite添加多数据源
本文转载自jeesite添加多数据源 1.jeesite.properties 添加数据源信息,(url2,username2,pawwword2) #mysql database setting j ...
随机推荐
- 彻底禁用chrome请停用以开发者模式运行的扩展程序弹框
首先上图 怎么解决呢? 进入安装目录-->下图目录(一串数字的目录) 2. 找到chrome.dll 3.下载patch.exe 下载网址 https://itdocs.pipipan.co ...
- App后台开发运维和架构实践学习总结(1)——App后台核心技术之用户验证方案
对于初学者来说,对Token和Session的使用难免会限于困境,开发过程中知道有这个东西,但却不知道为什么要用他?更不知道其原理,今天我就带大家一起分析分析这东西. 一.使用Token进行身份鉴权 ...
- 0223实战:MySQL Sending data导致查询很慢的问题详细分析
转自博客http://blog.csdn.net/yunhua_lee/article/details/8573621 [问题现象] 使用sphinx支持倒排索引,但sphinx从mysql查询源数据 ...
- Hadoop入门进阶步步高(一)-环境准备
前言 Hadoop从存储上来说,是相似于冗余磁盘阵列(RAID)的存储方式.将数据分散存储并提供以提供吞吐量,它的存储系统就是HDFS(Hadoop Distuibute Fils System).从 ...
- 邮箱smtpserver及port收集
网易 163邮箱 POP3:pop.126.com SMTP:smtp.126.com SMTPport号:25 126邮箱 POP3:pop.126.com SMTP:smtp.126.co ...
- JS禁用右键+禁用Ctrl+u+禁用F12
第一种方法: , , ]; document.oncontextmenu = new Function("event.returnValue=false;"),//禁用右键 doc ...
- linux命令之man和info
linux命令之man和info man ➜ ~ man ls result: LS(1)中1这样的数字的意义例如以下所看到的: 代号 内容 1 用户在shell环境中能够操作的命令或可运行文件 2 ...
- KVO---视图间数据的传递:标签显示输入的内容【多个视图中】
RootViewController.m #import "ModalViewController.h" @interface RootViewController () @end ...
- PHP之实现双向链表(代码篇)
<?php/** * PHP之实现双向链表 */class Hero{ public $pre=null; public $no; public $name; public $next=null ...
- pyhton 从web获取json数据 保存到本地然后再读取
从web中获取json数据直接进行处理总认为太慢.主要是从web中获取获取数据的过程有点慢. 所以就在想 假设先利用空暇时间把json数据获取并保存到本地,然后再从本地文件里读取和操作.应该就要快非常 ...