Пример #1
0
    def recover_login_data(self):
        cm = ConfigManager()
        # 恢复鉴权参数
        self.clientid = int(cm.get('login_data', 'clientid'))
        self.urlPtwebqq = cm.get('login_data', 'url_ptwebqq')
        self.ptwebqq = cm.get('login_data', 'ptwebqq')
        self.vfwebqq = cm.get('login_data', 'vfwebqq')
        self.uin = int(cm.get('login_data', 'uin'))
        self.psessionid = cm.get('login_data', 'psessionid')
        self.hash = cm.get('login_data', 'hash')
        self.bkn = int(cm.get('login_data', 'bkn'))
        self.user['qq'] = cm.get('login_data', 'user_qq')
        self.user['nick'] = cm.get('login_data', 'user_nick')

        # 恢复cookies
        file_dir = cm.getpath('cookie')
        with open(file_dir, 'rb') as f:
            cookies = requests.utils.cookiejar_from_dict(pickle.load(f))
            self.session = requests.session()
            self.session.cookies = cookies
            self.session.headers.update({
                'User-Agent': ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9;'
                               ' rv:27.0) Gecko/20100101 Firefox/27.0'),
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
            })

        return True
Пример #2
0
    def __init__(self, reactor):
        self.reactor = reactor
        self.num_protocols = 0

        conf = ConfigManager().default
        self.shadow = ShadowProtocol(
            key=conf.get('local', 'key'),
            data_salt=conf.get('local', 'data_salt'),
            pro_salt=conf.get('local', 'pro_salt'),
            data_cipher=conf.get('local', 'data_cipher'),
            pro_cipher=conf.get('local', 'pro_cipher'),
        )
Пример #3
0
def register_nick_and_username():
    servconn().send_message(string.join([
        "NICK",
        ConfigManager.get("nick")], " "
    ))

    servconn().send_message(string.join([
        "USER",
        ConfigManager.get("nick"),
        socket.gethostname(),
        ConfigManager.get("server"),
        ConfigManager.get("nick")], " "
    ))
Пример #4
0
def send_login_mail(img_dir):
    try:
        host = Constant.send_mail_host
        port = Constant.send_mail_ssl_port
        sender = Constant.send_mail_addr
        pwd = Constant.send_mail_apikey
        receiver = Constant.send_login_addr

        cm = ConfigManager()
        if img_dir:
            msg = MIMEMultipart('alternative')
            msg['subject'] = 'deepintell测试记录发送'  # 设置标题
            msg['from'] = sender  # 设置发送人
            msg['to'] = receiver  # 设置接收人

            mail_msg = '重新登录帐号:%s(%s)\n' % \
                       (cm.get('login_data', 'user_nick'), cm.get('login_data', 'user_qq'))
            mail_msg += '二维码见附件\n'
            msg.attach(MIMEText(mail_msg, 'plain', 'utf-8'))

            # 添加图片
            with open(img_dir, 'rb') as f:
                att1 = MIMEText(f.read(), 'base64', 'utf-8')
                att1["Content-Type"] = 'application/octet-stream'
                att1[
                    "Content-Disposition"] = 'attachment; filename="%s"' % img_dir.split(
                        '/')[-1]
                msg.attach(att1)

        else:
            msg = MIMEMultipart()
            text = '已经停止为帐号:%s(%s)进行重新登录,程序即将退出,请重新打开程序登录。' % \
                   (cm.get('login_data', 'user_nick'), cm.get('login_data', 'user_qq'))
            msg.attach(MIMEText(text, 'plain', 'utf-8'))
            msg['subject'] = 'deepintell测试记录发送'  # 设置标题
            msg['from'] = sender  # 设置发送人
            msg['to'] = receiver  # 设置接收人

        s = smtplib.SMTP_SSL(host, port)  # 使用SSL端口
        s.login(sender, pwd)  # 登陆邮箱
        s.sendmail(sender, receiver, msg.as_string())  # 发送邮件
        s.quit()  # 关闭链接
        print '邮件发送成功\n'
    except:
        error(traceback.format_exc())
        print '邮件发送失败\n'
    finally:
        exit()  # 退出子进程
Пример #5
0
 def __init__ (self):
   pygame.init()
   pygame.key.set_repeat(10,10)
   res = ConfigManager.get("resolution")
   self.screen = pygame.display.set_mode(res, pygame.DOUBLEBUF)
   self.ball = Ball()
   self.space = Space(res)
Пример #6
0
 def sendAuthentication(self):
     conf = ConfigManager().default
     token = conf.get('local', 'token', fallback='').encode()
     request = b''.join(
         [struct.pack('!BB', constants.SOCKS5_VER, len(token)), token])
     log.debug('sendAuthentication {data!r}', data=request)
     self.write(request)
     self.set_state(self.STATE_SentAuthentication)
Пример #7
0
    def register_default_actions():
        def bot_command_action(bot_command_mo):
            command.execute(
                caller_nick=bot_command_mo.group(1),
                channel=bot_command_mo.group(2),
                command=bot_command_mo.group(4),
                arguments=bot_command_mo.group(5)
            )

        command_prefix_esc = re.escape(ConfigManager.get('command_prefix'))
        nick_esc = re.escape(ConfigManager.get('nick'))
        actions = [Action(
            regex=r"^:([^\s]+)![^\s]+ PRIVMSG ([^\s]+) :(%s|%s: )([\w-]+)[\s]*(.*)" % (command_prefix_esc, nick_esc),
            action=bot_command_action
        ),

        # Pinging
        Action(
            regex=r"^PING .*",
            action=lambda match_object: irc.pong(match_object.group(0))
        ),

        # Connection accepted (AKA RPL_WELCOME, status 001)
        Action(
            regex=r".* 001 %s" % ConfigManager.get('nick'),
            action=lambda match_object: irc.join_config_channels()
        ),

        # Nickname registered already
        # ':NickServ!NickServ@snoonet/services/NickServ NOTICE nickenbot :This nickname is registered and protected.  If it is your'

        Action(
            regex=r"^:NickServ!NickServ@[^\s]+ NOTICE %s :.*registered.*" % ConfigManager.get('nick'),
            action=lambda match_object: irc.identify_with_nickserv()
        )]
        Action.actions = actions
Пример #8
0
    def __init__(self, host='wx.qq.com'):
        super(WeChat, self).__init__(host)

        self.db = None
        self.save_data_folder = ''  # 保存图片,语音,小视频的文件夹
        self.last_login = 0  # 上次退出的时间
        self.time_out = 5  # 同步时间间隔(单位:秒)
        self.msg_handler = None
        self.start_time = time.time()
        self.bot = None

        cm = ConfigManager()
        self.save_data_folders = cm.get_wechat_media_dir()
        self.cookie_file = cm.get_cookie()
        self.pickle_file = cm.get_pickle_files()
        self.log_mode = cm.get('setting', 'log_mode') == 'True'
        self.exit_code = 0
Пример #9
0
    def start_client(self):
        self.log.info('start client')

        self.transport.pauseProducing()
        conf = ConfigManager().default
        proxy_host_port = conf.get('local', 'proxy_host_port')
        point = clientFromString(self.factory.reactor,
                                 f"tcp:{proxy_host_port}")

        d = connectProtocol(point, ProxyClient(self))

        def error(failure):
            raise errors.HostUnreachable()

        d.addErrback(error)

        return d
Пример #10
0
    def __init__(self, host='wx.qq.com'):
        super(WeChat, self).__init__(host)

        self.db = None
        self.save_data_folder = ''  # 保存图片,语音,小视频的文件夹
        self.last_login = 0  # 上次退出的时间
        self.time_out = 5  # 同步时间间隔(单位:秒)
        self.msg_handler = None
        self.start_time = time.time()
        self.bot = None

        cm = ConfigManager()
        self.save_data_folders = cm.get_wechat_media_dir()
        self.cookie_file = cm.get_cookie()
        self.pickle_file = cm.get_pickle_files()
        self.log_mode = cm.get('setting', 'log_mode') == 'True'
        self.exit_code = 0
Пример #11
0
    def __init__(self, host='wx.qq.com'):
        super(WeChat, self).__init__(host)

        self.time_out = 2  # 同步时间间隔(单位:秒)此设置并不是越短越好
        self.start_time = time.time()
        self.msg_handler = None
        self.bot = None

        cm = ConfigManager()
        self.save_data_folders = cm.get_wechat_media_dir()
        self.log_mode = cm.get('setting', 'log_mode') == 'True'
        self.exit_code = 0

        # 用于处理信息的类内全局
        self.CommandList = []
        self.DBStoreMSGList = []
        self.GroupNeedReplyList = []
        self.UserNeedReplyList = []
        self.ReplyList = []
        self.DBStoreBOTReplyList = []

        self.AddUserList = []  # 等待添加为好友的用户
Пример #12
0
 def create_socket(self):
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.sock.connect((ConfigManager.get('server'), ConfigManager.get('port')))
     time.sleep(1)
Пример #13
0
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#  
#  

import pygame

from config import ConfigManager
from utils import *

WIDTH, HEIGHT = ConfigManager.get("resolution")  
    
class Ball(pygame.sprite.Sprite):
  '''
  Ball class (sprite)
  '''
  
  def __init__ (self):
    pygame.sprite.Sprite.__init__(self)
    self.image = load_image("ship.png")
    self.rect = self.image.get_rect()
    self.rect.centerx = HEIGHT / 2
    self.rect.centery = WIDTH / 2
    self.speed = 10
    self.dir = "UP"
Пример #14
0
def identify_with_nickserv():
    servconn().send_message(
        COMMANDS['NICKSERV_IDENTIFY'] % (ConfigManager.get("nick"), ConfigManager.get("password"))
    )
Пример #15
0
def join_config_channels():
    for channel in ConfigManager.get("channels"):
        join_channel(channel)
Пример #16
0
from config import Log
#---------------------------------------------------
from flask import Flask, render_template, send_file, jsonify, request
import threading
import traceback
import os
import logging
import time
#===================================================


cm = ConfigManager()
db = SqliteDB(cm.getpath('database'))
# db = MysqlDB(cm.mysql())
wechat_msg_processor = WeChatMsgProcessor(db)
wechat = WeChat(cm.get('wechat', 'host'))
wechat.db = db
wechat.bot = Bot()
wechat.msg_handler = wechat_msg_processor
wechat_msg_processor.wechat = wechat

PORT = int(cm.get('setting', 'server_port'))
app = Flask(__name__, template_folder='flask_templates')
app.config['UPLOAD_FOLDER'] = cm.getpath('uploaddir')

logger = logging.getLogger('werkzeug')
log_format_str = Constant.SERVER_LOG_FORMAT
formatter = logging.Formatter(log_format_str)
flask_log_handler = logging.FileHandler(cm.getpath('server_log_file'))
flask_log_handler.setLevel(logging.INFO)
flask_log_handler.setFormatter(formatter)
Пример #17
0
from config import Log
#---------------------------------------------------
from flask import Flask, render_template, send_file, jsonify, request
import threading
import traceback
import os
import logging
import time
#===================================================


cm = ConfigManager()
db = SqliteDB(cm.getpath('database'))
# db = MysqlDB(cm.mysql())
wechat_msg_processor = WeChatMsgProcessor(db)
wechat = WeChat(cm.get('wechat', 'host'))
wechat.db = db
wechat.bot = Bot()
wechat.msg_handler = wechat_msg_processor
wechat_msg_processor.wechat = wechat

PORT = int(cm.get('setting', 'server_port'))
app = Flask(__name__, template_folder='flask_templates')
app.config['UPLOAD_FOLDER'] = cm.getpath('uploaddir')

logger = logging.getLogger('werkzeug')
log_format_str = Constant.SERVER_LOG_FORMAT
formatter = logging.Formatter(log_format_str)
flask_log_handler = logging.FileHandler(cm.getpath('server_log_file'))
flask_log_handler.setLevel(logging.INFO)
flask_log_handler.setFormatter(formatter)
Пример #18
0
import os
import logging
import time
import signal
#===================================================
import roslib
import rospy
from std_msgs.msg import String
from robot_msgs.srv import Speak
#===================================================

cm = ConfigManager()
db = SqliteDB(cm.getpath('database'))
# db = MysqlDB(cm.mysql())
wechat_msg_processor = WeChatMsgProcessor(db)
wechat = WeChat(cm.get('wechat', 'host'))
wechat.db = db
wechat.bot = Bot()
wechat.msg_handler = wechat_msg_processor
wechat_msg_processor.wechat = wechat

PORT = int(cm.get('setting', 'server_port'))
app = Flask(__name__, template_folder='flask_templates')
app.config['UPLOAD_FOLDER'] = cm.getpath('uploaddir')

logger = logging.getLogger('werkzeug')
log_format_str = Constant.SERVER_LOG_FORMAT
formatter = logging.Formatter(log_format_str)
flask_log_handler = logging.FileHandler(cm.getpath('server_log_file'))
flask_log_handler.setLevel(logging.INFO)
flask_log_handler.setFormatter(formatter)
Пример #19
0
from config import Constant
from config import Log
#---------------------------------------------------
import flask
import threading
import traceback
import os
import logging
import time
#===================================================

cm = ConfigManager()
db = SqliteDB(cm.getpath('database'))
# db = MysqlDB(cm.mysql())
wechat_msg_processor = WeChatMsgProcessor(db)
wechat = WeChat(cm.get('wechat', 'host'))
wechat.db = db
wechat.bot = Bot()
wechat.msg_handler = wechat_msg_processor
wechat_msg_processor.wechat = wechat

PORT = int(cm.get('setting', 'server_port'))
app = flask.Flask(__name__)
app.config['UPLOAD_FOLDER'] = cm.getpath('uploaddir')

logger = logging.getLogger('werkzeug')
log_format_str = Constant.SERVER_LOG_FORMAT
formatter = logging.Formatter(log_format_str)
flask_log_handler = logging.FileHandler(cm.getpath('server_log_file'))
flask_log_handler.setLevel(logging.INFO)
flask_log_handler.setFormatter(formatter)
Пример #20
0
from config import Constant
from config import Log
#---------------------------------------------------
from flask import Flask, render_template, send_file, jsonify, request
import threading
import traceback
import os
import logging
import time
#===================================================

cm = ConfigManager()
db = SqliteDB(cm.getpath('database'))
# db = MysqlDB(cm.mysql())
wechat_msg_processor = WeChatMsgProcessor(db)
wechat = WeChat(cm.get('wechat', 'host'))
wechat.db = db
wechat.bot = Bot()
wechat.msg_handler = wechat_msg_processor
wechat_msg_processor.wechat = wechat

PORT = int(cm.get('setting', 'server_port'))
app = Flask(__name__, template_folder='flask_templates')
app.config['UPLOAD_FOLDER'] = cm.getpath('uploaddir')

logger = logging.getLogger('werkzeug')
log_format_str = Constant.SERVER_LOG_FORMAT
formatter = logging.Formatter(log_format_str)
flask_log_handler = logging.FileHandler(cm.getpath('server_log_file'))
flask_log_handler.setLevel(logging.INFO)
flask_log_handler.setFormatter(formatter)