死磕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 ...
随机推荐
- 学习EXTJS6(6)基本功能-工具栏和菜单
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- elasticsearch 分析器阅读笔记(五)
倒排索引 可以查看这里得分词原理https://www.cnblogs.com/LQBlog/articles/5743991.html 分析器 分析器处理过程的3步骤 1.字符过滤器:去除字符的特殊 ...
- Tyvj - 1286 - 校门外的树2
描述 Description 某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是1米.我们可以把马路看成一个数轴,马路的一端在数轴0的位置,另一端在L的位置:数轴上的每个整数点,即0,1 ...
- 洛谷 P1463 [SDOI2005]反素数ant
P1463 [SDOI2005]反素数ant 题目描述 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4. 如果某个正整数x满足:g(x)>g(i) 0<i< ...
- POJ 1329
模板题,注意一下输出就可以. #include <iostream> #include <cstdio> #include <cmath> #include < ...
- BZOJ 1044 HAOI2008 木棍切割 二分答案+动态规划
题目大意:给定n个连在一起的木棍.分成m+1段.使每段最大值最小,求最大值的最小值及最大值最小时切割的方案数 第一问水爆了--二分答案妥妥秒过 第二问就有些难度了 首先我们令f[i][j]表示用前j个 ...
- [Javascript Crocks] Recover from a Nothing with the `alt` method
Once we’re using Maybes throughout our code, it stands to reason that at some point we’ll get a Mayb ...
- 积跬步,聚小流------界面经常使用的jeecms标签
* JEECMS初印象 第一次接触JEECMS,突然脑海就浮现了一句话"20元建站,立等可取",原来这都是真的... * JEECMS的界面经常使用标签 临时忽略掉环境搭建.栏目配 ...
- #leetcode#Anagrames
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be ...
- 2015年趋势科技笔试A卷
题目原题来源:url=BHz9dr7Dbql5Ai0fTaUsi8QH-ieA9UAtw8kpf-Us_cGUnsz7ZIU1SfHIp33Cphcp0n6uPikWL6r8n0a0zQ0wNOMLG ...