예제 #1
0
# -*- coding: utf-8 -*-

from snsapi.snspocket import SNSPocket
from datetime import datetime
import time

TEXTS = ['凌晨好', '清晨好', '早上好', '下午好', '傍晚好', '晚上好']
#URL = 'https://github.com/hupili/snsapi/tree/master/app/clock'
URL = 'http://t.cn/zj1VSdV'
AD = '10行写个跨平台的钟:%s' % URL

sp = SNSPocket() # SNSPocket 是一个承载各种SNS的容器
sp.load_config() # 如名
sp.auth()        # 批量授权(如果已授权,读取授权信息)

while True: 
    h, m = datetime.now().hour, datetime.now().minute                        # 获取当前小时和分钟
    if m == 0:                                                               # 每小时0分钟的时候发状态
        t = '%s -- 0x%X点钟, %s。( %s )' % ('烫' * h, h, TEXTS[h / 4], AD)  # 构造钟的报时文字
        print t
        sp.update(t)                                                         # 发一条新状态
    time.sleep(60)                                                           # 睡一分钟
예제 #2
0
# -*- coding: utf-8 -*-

from snsapi.snspocket import SNSPocket
from snsapi.utils import console_input,console_output
        
if __name__ == "__main__":
    '''
    QQ weibo may fail sometimes, even with same input. May be the invoking frequency limit.
    Sina weibo is better, and more stable.
    '''

    sp = SNSPocket()
    sp.read_config()

    sp.auth()
    
    for cname in sp:
        print "listen first___________________________%s" % cname
        sl = sp.home_timeline(channel = cname)
        print sl
        
        print "update status__________________________%s" % cname
        print "Input text:"
        text = raw_input()
        ret = sp.update(text, channel = cname)
        print ret
예제 #3
0
# -*- coding: utf-8 -*-

from snsapi.snspocket import SNSPocket
from datetime import datetime
import time

TEXTS = ['凌晨好', '清晨好', '早上好', '下午好', '傍晚好', '晚上好']
#URL = 'https://github.com/hupili/snsapi/tree/master/app/clock'
URL = 'http://t.cn/zj1VSdV'
AD = '10行写个跨平台的钟:%s' % URL

sp = SNSPocket()  # SNSPocket 是一个承载各种SNS的容器
sp.load_config()  # 如名
sp.auth()  # 批量授权(如果已授权,读取授权信息)

while True:
    h, m = datetime.now().hour, datetime.now().minute  # 获取当前小时和分钟
    if m == 0:  # 每小时0分钟的时候发状态
        t = '%s -- 0x%X点钟, %s。( %s )' % ('烫' * h, h, TEXTS[h / 4], AD
                                         )  # 构造钟的报时文字
        print t
        sp.update(t)  # 发一条新状态
    time.sleep(60)  # 睡一分钟
예제 #4
0
파일: clock.py 프로젝트: junstrix/pi
# -*- coding: utf-8 -*-
import snsapi
from snsapi.snspocket import SNSPocket
from datetime import datetime
import time

sp = SNSPocket()
sp.load_config()
sp.auth()

while True:
    h, m = datetime.now().hour, datetime.now().minute
    if h == 22 and m == 50:
		t = '%s:%s, Pi要关机睡觉了,Goodnight everyone!' % (h,m)
        # SNSAPI use unicode internally
		sp.update(t.decode('utf-8'))
    if h == 6 and m == 10:
		t = '%s:%s, Pi 起床工作了哦,大家也起来吧,效率每一天,不要忘记梦想哦,Goodmorning everyong! http://junstrix.oicp.net' % (h,m)
		sp.update(t.decode('utf-8'))
    time.sleep(60)
예제 #5
0
파일: youdao1.py 프로젝트: junstrix/pi
    get_data = urllib2.urlopen(baseurl+keyword)
    data = get_data.read()
    json_data = json.loads(data)
    yinbiao_data = json_data.get('basic',[]).get('phonetic') # 音标
    num_str = len(json_data.get('basic',[]).get('explains')[:])
    if num_str == 1:
        t_update = keyword + ': ' + '[%s] ' % (yinbiao_data) + json_data.get('basic',[]).get('explains')[0] + youdaourl
    if num_str == 2:
        t_update = keyword + ': ' + '[%s] ' % (yinbiao_data) + json_data.get('basic',[]).get('explains')[0]+' ' + json_data.get('basic',[]).get('explains')[1] + youdaourl
    if num_str == 3:
        t_update = keyword + ': ' + '[%s] ' % (yinbiao_data) + json_data.get('basic',[]).get('explains')[0]+' ' + json_data.get('basic',[]).get('explains')[1] + ' ' + json_data.get('basic',[]).get('explains')[2] + youdaourl
    if num_str == 4:
        t_update = keyword + ': ' + '[%s] ' % (yinbiao_data) + json_data.get('basic',[]).get('explains')[0]+' ' + json_data.get('basic',[]).get('explains')[1] + ' ' + json_data.get('basic',[]).get('explains')[2] + ' ' + json_data.get('basic',[]).get('explains')[3] + youdaourl
    deletelist = "sed -i '/%s/d' %s" % (keyword,cet4_src) # system command: delete a word form list
    os.system(deletelist)
    return t_update

while True:
    h, m = datetime.now().hour, datetime.now().minute
#    nowtime = datetime.now().strftime('%b-%d-%y %H:%M:%S')
    if h == 22 and m == 50:
        t = '%s 晚安,远方的星。' %(EveryGoodNight())
        sp.update(t.decode('utf-8'))
        quit()
    if h == 6 and m == 10:
        t = '%s 早安,璀璨。' % (English_Everyday())
        sp.update(t.decode('utf-8'))
    if m == 0 or m == 30:
        sp.update(Send_Weibo())
    time.sleep(60)
예제 #6
0

sp.add_channel(nc) 


sp.auth()
sp.save_config()


sp.list_channel()


status =  sp.home_timeline()
#print status
nc2 = sp.new_channel();
nc2["platform"] = "RSS2RW"
nc2["channel_name"] = "output"
nc2["url"] = "output.atom"
sp.add_channel(nc2) 
sp.auth()
sp.save_config()
sp.list_channel()

sl = sp.home_timeline(5)
print sl[0]
print sp.home_timeline(channel = "output")
sp.update(text = unicode(sl[0]), channel = "output")
print sp.home_timeline(channel = "output")
sp.update(text = unicode(sl[3]), channel = "output")
print sp.home_timeline(channel = "output")
예제 #7
0
'''
Update status on all channels

docstring placeholder
'''

from snsapi.snspocket import SNSPocket
from snsapi.utils import console_input,console_output

if __name__ == "__main__":
    '''
    QQ weibo may fail sometimes, even with same input. May be the invoking frequency limit.
    Sina weibo is better, and more stable.
    '''

    sp = SNSPocket()
    sp.load_config()

    sp.auth()

    for cname in sp:
        print "listen first___________________________%s" % cname
        sl = sp.home_timeline(channel = cname)
        print sl

        print "update status__________________________%s" % cname
        print "Input text:"
        text = raw_input()
        ret = sp.update(text, channel = cname)
        print ret
예제 #8
0
파일: clock.py 프로젝트: xxr3376/snsapi
# -*- coding: utf-8 -*-
'''
clock (SNSAPI Sample Apps)

docstring placeholder
'''

from snsapi.snspocket import SNSPocket
from datetime import datetime
import time

TEXTS = ['凌晨好', '清晨好', '早上好', '下午好', '傍晚好', '晚上好']
#URL = 'https://github.com/hupili/snsapi/tree/master/app/clock'
URL = 'http://t.cn/zj1VSdV'
AD = '10行写个跨平台的钟:%s' % URL

sp = SNSPocket()
sp.load_config()
sp.auth()

while True:
    h, m = datetime.now().hour, datetime.now().minute
    if m == 0:
        t = '%s -- 0x%X点钟, %s。( %s )' % ('烫' * h, h, TEXTS[h / 4], AD)
        print t
        # SNSAPI use unicode internally
        sp.update(t.decode('utf-8'))
    time.sleep(60)