死磕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 ...
随机推荐
- 0923关于安装mysql两种简单方式
http://blog.csdn.net/liumm0000/article/details/18841197 方式一:利用RPM安装包进行安装 RPM方式安装MySQL5.6 RPM方式安装MySQ ...
- Js计算指定日期
function DateAdd(interval,number,date) { /* * 功能:实现VBScript的DateAdd功能. * 参数:interval,字符串表达式,表示要添加的时间 ...
- matplotlib的cmap
今天又看到了这样的代码: plt.imshow(X_train[0], cmap=plt.get_cmap('PuBuGn_r')) #plt.imshow(X_train[0], cmap=plt. ...
- Node.js具体解析
介绍 JavaScript 高涨的人气带来了非常多变化.以至于现在使用其进行网络开发的形式也变得截然不同了.就如同在浏览器中一样,现在我们也能够在server上执行 JavaScript ,从前端跨越 ...
- WAS_集群部署应用遭遇ADMA0085E和ADMA0109W错误
原创作品,出自 "深蓝的blog" 博客.深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/47143431 近日 ...
- SVNserver搭建和使用(二)
上一篇介绍了VisualSVN Server和TortoiseSVN的下载,安装,汉化.这篇介绍一下怎样使用VisualSVN Server建立版本号库,以及TortoiseSVN的使用. 首先打开V ...
- Java Word Break(单词拆解)
给定一个字符串 String s = "leetcode" dict = ["leet", "code"]. 查看一下是够是字典中的词语组成 ...
- css让文字旋转270度
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD ...
- graphviz.js划线操作
digraph A{ graph[color=red bgcolor="cadetblue" label="海阔天空",fontname="FangS ...
- Linux - 如何关闭防火墙
关闭防火墙,就可以外部访问了.不受端口限制.生产环境,最好开启防火墙,开启部分端口. 1.永久有效 开启: chkconfig iptables on 关闭: chkconfig iptables o ...