예제 #1
0
def sendWeatherMsg(receivers, msg):
    try:
        #receivers = [u'拉卡拉', u'证明给他看', u'李静']

        #receivers = u'李静,情绕指尖'
        ''' 
        #发送给指定好友 如果好友不存在 则发送给文件夹传输助手
        Sender(receivers = u'证明给他看').send(msg)
        Sender(receivers = u'拉卡拉').send(msg)
        Sender(receivers = u'李静').send(msg)
        '''
        '''   '''
        #发送给指定接收的用户
        #receivers = u'拉卡拉'
        #接受者必须是监听对象的子集
        sender = Sender(receivers=receivers, token='weather_report_123456789')
        sender.send(msg)  #如果没有指定receivers则发送给文件传输助手
        ''' 
        receivers = u'李静,情绕指尖'
        sender = Sender(receivers = receivers, token = 'weather_report_123456789')
       
        #有时候好使    有时候不好使
        sender.send_to('@wss', u'拉卡拉') #消息发送失败 会默认发送给receivers的第一个用户 Sender和Listen
        #sender.send_to(msg, u'证明给他看')
        '''

        #测试控制命令
        '''
        receivers = u'拉卡拉'
        sender = Sender(receivers = receivers, token = 'weather_report_123456789')
        sender.send('@wss')#文如果没有指定receivers则发送给文件传输助手件传输助手
        '''

    except BaseException as e:
        print(e)
예제 #2
0
 def __init__(self):
     self.now = datetime.datetime.now()
     self.total = 0
     self.sender = Sender('rapospectre',
                          'rapospectre',
                          'http://114.215.153.187',
                          port=10245)
     super(WechatSenderPipeline, self).__init__()
예제 #3
0
def sendanswer(defen, answer, df, question):
    ff = open('friends.txt')
    aaa = ff.read()
    msg = str('参考答案:' + answer + '。' + '\n' + '详细信息:' + '\n' + df + '\n' +
              '选项得分分别为:' + str(tuple(defen)) + '\n' + '问题:' + question + '\n' +
              '仅供参考,更多内容请关注SQuant')
    Sender(receivers=aaa, port=10015).send(msg)
예제 #4
0
파일: history.py 프로젝트: zwffff2015/stock
def initWeChat():
    host = 'http://127.0.0.1'
    token = '295cc3d8-c977-11e6-a341-0090f5f61084'
    global SENDER
    SENDER = Sender(token=token,
                    receivers=unicode('踏雪'),
                    host=host,
                    port='9090')
예제 #5
0
class WechatSenderPipeline(object):
    def __init__(self):
        self.now = datetime.datetime.now()
        self.total = 0
        self.sender = Sender('rapospectre',
                             'rapospectre',
                             'http://114.215.153.187',
                             port=10245)
        super(WechatSenderPipeline, self).__init__()

    def close_spider(self, spider):
        msg = '[{time:%Y-%m-%d %H:%M:%S}]抓取专栏{slug}文章成功,抓取数目: {count}'.format(
            count=self.total, time=self.now, slug=spider.obj.slug)
        self.sender.send(msg)

    def process_item(self, item, spider):
        self.total += 1
        return item
예제 #6
0
    def __init__(self, host, token, port, senderList):
        reload(sys)
        sys.setdefaultencoding('utf-8')

        self.host = host
        self.token = token
        self.port = port

        dictSender = {}
        for sender in senderList:
            dictSender[sender] = Sender(token=token,
                                        receivers=unicode(sender),
                                        host='http://' + host,
                                        port=port)

        self.senders = dictSender
예제 #7
0
from wechat_sender import Sender

msg = 'it is a bot send message to u'
Sender().send(msg)
예제 #8
0
def send2wechat(title):
    sender = Sender(receivers='漫画更新push!', token='rolevblf')
    sender.send('Comic updated! Download on Kindle from secret url!%s' % title)
예제 #9
0
#!/usr/bin/env Python
# coding=utf-8

from wxpy import *
from wechat_sender import Sender
import datetime
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import time
"""
    登陆微信,持续监听
"""
send = Sender()
time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
send.delay_send(content="信息",
                title="标题",
                remind=datetime.timedelta(minutes=59),
                time=time)
예제 #10
0
def send_price(url='https://www.michelin.com/eng/finance/share-information/share-price-history'):

    Sender(receivers=u"gaoshan'secretary").send(u'今日米其林股今日米其林股价信息'+url)
예제 #11
0
def send_weather(weather):
    Sender(receivers=u"gaoshan'secretary").send(weather)
예제 #12
0
파일: ziru.py 프로젝트: WUZHEN1991/ziroom
def sendanswer(answer):
    msg = str(answer)
    Sender(receivers='吴震', port=10003).send(msg)
예제 #13
0
def get_mail_to_wechat():
    global id, server, sender
    try:
        mail = server.get_latest()
        maxid = mail["id"]

        while id < maxid:
            id += 1
            logger.info(f" 获取 id 为 {id} 的邮件")
            mail = server.get_mail(id)
            # 主题 + 正文
            content = ("".join(mail["content"]) if mail["content"] != [] else
                       "".join(mail["content_html"]))
            message = f"""主题:\n{mail['subject']}\n正文:\n{content}"""
            logger.info(message)
            send_ip = mail["raw"][17].decode("utf-8").split(":")[1].replace(
                " ", "")
            # logger.info(type(send_ip))
            logger.info(f" from {send_ip}")
            # 来自指定IP发送的邮件才发送微信
            if send_ip in settings.ip:
                # 逐个发送微信
                logger.info(f": 来自 {send_ip},发消息至以朋友")
                print(mail["to"])
                for index in mail["to"].replace(",", ";").split(";"):
                    print(index)
                    friends = (settings.receiver.get(index.replace(" ", ""),
                                                     "清如許")).split(",")
                    logger.info(friends)
                    for friend in friends:
                        while True:
                            try:
                                re = sender.send_to(content=message,
                                                    search=friend)
                                if re[0]:
                                    break
                            except:
                                pass

                        # if friend == "清如許":
                        #    re = sender.send(message)
                        #    logger.info(re)
                        # else:
                        #    re = sender.send_to(content=message, search=friend)
                        #    logger.info(re)
                # 向群组发送微信
                if mail["subject"].startswith("group:"):
                    groups = (mail["subject"].replace("group:", "")).split(",")
                    for g in groups:
                        while True:
                            try:
                                re = sender.send_to(
                                    content=f"打扰了,这是一条告警信息,请关注\n{content}",
                                    search=g)
                                if re[0]:
                                    break
                            except:
                                pass

        # 删除邮件会导致id>maxid 此时重新定义id为maxid
        if id > maxid:
            id = maxid

    except Exception as e:
        logger.info(f": send err is [{e}] \n开始重新登陆邮箱")
        server = zmail.server(settings.mail_user,
                              settings.mail_pwd,
                              pop_host=settings.mail_host)
        logger.info(f" 登陆成功,获取到最新邮件编号 { id }\n")
        sender = Sender()
예제 #14
0
    #执行插入数据库的操作
    insertData(dirpath, studentid)


def selectNoDownStudentCount():
    """
    查询没有被查询的学生的个数
    :return:
    """
    sql = "SELECT  count(studentId)  FROM student  where updatetime IS  NULL "
    param = []
    return mysql.get_one(sql=sql, params=param)


if __name__ == "__main__":
    send = Sender()
    # 每24个小时调用一次

    # [1]拿到登陆成功的session
    session = login()
    logger.info("<<<<<<<<<<<<<<<<<<<<<<爬取个人数据开始>>>>>>>>>>>>>>>>>>>>>>>>")

    #[2]读取数据库,拿到studentid,爬取每一个学生的信息和贴子数据
    StudentIDlist = selectStuID()

    if len(StudentIDlist) > 0:
        for studentid in StudentIDlist:
            studentid = str(studentid[0])
            logger.info("爬取" + studentid + "这名学生的主页")
            try:
                #根据id,爬取数据
예제 #15
0
파일: send.py 프로젝트: madongmei/work
#!/usr/bin/python
# encoding: utf-8
""" 
@version: v1.0
@author: madongmei
@contact: [email protected]
@file: login.py
@time: 2017/10/22 11:43
"""


from wechat_sender import Sender
sender=Sender(token='h3i39pasNMge2sMq4s3gSb_IvWjs_nuu93IIVBXmTlgIWoDN-pXWtvEhDUDcT6faAQ0BaD0jiGS-4YOpqQjy6Fq5DYVA1zNeRxMzaDqVydBiDHx5uNfajvCMzANGbCEaUNRhAGAQJN',
                     receivers='Mei', host=u'http://47.94.222.71', port=10245)
Sender().send('Hello From Wechat Sender')

예제 #16
0
import time, queue, threading, schedule
from multiprocessing.managers import BaseManager
from wechat_sender import Sender
from weather_beta import Weather
from translation_beta import YouDaoTranslation
from multiinfo_beta import GetInfo
from stock_beta import Stock
from settings_beta import YouDao_Lang

sender = Sender(token='houwei2018')

task_queue = queue.Queue()
result_queue = queue.Queue()

lock = threading.Lock()
stock_user = dict()
is_schedule = []


# 从BaseManager继承的QueueManager:
class QueueManager(BaseManager):
    pass


def task_q():
    return task_queue


def result_q():
    return result_queue
예제 #17
0
파일: sender.py 프로젝트: renyushu/study
from wechat_sender import Sender

sender = Sender(token='test')
sender.send('hello wechat')
sender.send('send to wechat')
예제 #18
0
def send_english(english):
    Sender(receivers=u"gaoshan'secretary").send(english)
예제 #19
0
# coding: utf-8
from wechat_sender import Sender

sender = Sender(token='test')

sender.send('hello world!')
예제 #20
0
fh = logging.FileHandler(filename="./mailToWeChat.log")
formatter = logging.Formatter(
    "%(asctime)s - %(filename)s - %(name)s - line:%(lineno)d - %(levelname)s - %(message)s"
)
fh.setFormatter(formatter)
ch.setFormatter(formatter)
logger.addHandler(ch)  # 将日志输出至屏幕
logger.addHandler(fh)  # 将日志输出至文件

server = zmail.server(settings.mail_user,
                      settings.mail_pwd,
                      pop_host=settings.mail_host)
mail = server.get_latest()
id = mail["id"] - 1
logger.info(f" 登陆成功,获取到最新邮件编号 { id }\n")
sender = Sender()


def get_mail_to_wechat():
    global id, server, sender
    try:
        mail = server.get_latest()
        maxid = mail["id"]

        while id < maxid:
            id += 1
            logger.info(f" 获取 id 为 {id} 的邮件")
            mail = server.get_mail(id)
            # 主题 + 正文
            content = ("".join(mail["content"]) if mail["content"] != [] else
                       "".join(mail["content_html"]))
예제 #21
0
players = {
    134976802: '白杨',
    194765012: '李明昊',
    163287641: 'P酱',
    137479998: '涛神',
    397440385: '亮亮',
    144128282: '肥导',
    142874459: '冯帆',
    135885299: '蛋酱',
    189119223: '高远见',
    307998042: '头娃',
    163338929: '航儿',
    139095627: '刘洋'
}

sender = Sender(token='test')
key = "C1117CC15AFE30841DF863B901A0D35A"
domain = "wxdotarobot"

api = dota2api.Initialise(key)
heroes = api.get_heroes()
refresh_sencond = 300
#match = api.get_match_details(match_id=5668508119)
#player_matches = api.get_match_history(134976802)


def get_hero_by_id(id):
    for item in heroes['heroes']:
        if id == item['id']:
            return item['localized_name']
예제 #22
0
def send_hello():
    Sender(receivers=u"gaoshan\'secretary").send(u'早上好!')
예제 #23
0
    获取需要抓取的栏目的id
    :return:
    """
    return (19, 13, 38, 41, 15)


def getNewFormatTime():
    """
    返回当前格式后的时间
    :return:
    """
    return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))


if __name__ == "__main__":
    send = Sender()

    # [1]拿到登陆成功的session
    session = login()
    send.delay_send(content="爬取帖子,抽取数据开始",
                    title="下课聊",
                    time=getNewFormatTime())
    # [2] 抓取昨天发布的全部帖子,一些小的栏目帖子不算
    # 获取上一天的年月日
    yesterday = getYesterday("%Y-%m-%d")
    print yesterday
    # 模拟抓取的时间戳
    # 0.0.0 的时间戳  23.59.59 的时间戳
    befor_timestamp = str(yesterday) + " 00:00:00"
    after_timestamp = str(yesterday) + " 23:59:59"
    print befor_timestamp
예제 #24
0
def sendanswer(defen,answer,df,question):
    msg=str('参考答案:'+answer+'。'+'\n'+df+'\n'+'选项得分分别为:'+str(tuple(defen))+'\n'+'问题:'+question+'\n'+'仅供参考,更多内容请关注SQuant')
    Sender(receivers='吴震,吴明,朱依心',port=10111).send(msg)
예제 #25
0
def send_ip():
    with open('./cip.txt', 'r') as f:
        cip = f.read()
        cipurl = 'https://%s:8443/wordpress/' % cip
    Sender(receivers=u"gaoshan'secretary").send(cipurl)
예제 #26
0
# coding: utf-8
from wechat_sender import Sender
Sender().send('hello world')
예제 #27
0
import sys
from wechat_sender import Sender

reload(sys)
sys.setdefaultencoding('utf-8')

host = 'http://47.95.6.27'
token = '295cc3d8-c977-11e6-a341-0090f5f61084'
sender = Sender(token=token, receivers=unicode('踏雪'), host=host, port='9090')
sender.send('阿斯蒂芬')
예제 #28
0
def sendmessage(value):
    Sender().send(value)
예제 #29
0
def login(token, port):
    sender = Sender(token=token, port=port)
    return sender