Esempio n. 1
0
def forward_post(msg_id):
    sp.auth()
    comment = request.forms.get('comment')
    comment = snsapi_utils.console_input(comment)
    op = "forward status '%s' with comment '%s'" % (msg_id, comment)
    #result = "s"
    result = q.forward(msg_id, comment)
    return {'result': result, 'operation': op}
Esempio n. 2
0
def forward_post(msg_id):
    sp.auth()
    comment = request.forms.get('comment')
    comment = snsapi_utils.console_input(comment)
    op = "forward status '%s' with comment '%s'" % (msg_id, comment)
    #result = "s"
    result = q.forward(msg_id, comment)
    return {'result': result, 'operation': op}
Esempio n. 3
0
def unlike_post(msg_id):
    (k, sp, ap, q) = token_to_user(request.get_cookie('token'))
    sp.auth()
    comment = request.forms.get('comment')
    ch = request.forms.get("platform")
    comment = snsapi_utils.console_input(comment)
    op = "unlike status '%s'" % (msg_id, )
    result = q.unlike(msg_id, channel=ch)
    return {'result': result}
Esempio n. 4
0
def reply_post(msg_id):
    (k, sp, ap, q) = token_to_user(request.get_cookie('token'))
    sp.auth()
    comment = request.forms.get('comment')
    ch = request.forms.get("platform")
    comment = snsapi_utils.console_input(comment)
    op = "reply status '%s' with comment '%s'" % (msg_id, comment)
    result = q.reply(msg_id, comment, channel=ch)
    return {'result': result, 'operation': op}
Esempio n. 5
0
def update_post():
    (k, sp, ap, q) = token_to_user(request.get_cookie('token'))
    os.chdir("." + delimeter + "User" + delimeter + str(k))
    sp.auth()
    status = request.forms.get('status')
    status = snsapi_utils.console_input(status)
    result = sp.update(status)
    os.chdir(".." + delimeter + ".." + delimeter)
    return {'result': result, 'status': status, 'submit': True}
Esempio n. 6
0
def forward_post(msg_id):
    (k, sp, ap, q) = token_to_user(request.get_cookie('token'))
    os.chdir("." + delimeter + "User" + delimeter + str(k))
    sp.auth()
    comment = request.forms.get('comment')
    ch = request.forms.getall("platform")
    comment = snsapi_utils.console_input(comment)
    op = "forward status '%s' with comment '%s'" % (msg_id, comment)
    result = q.forward(msg_id, comment, channel=ch)
    os.chdir(".." + delimeter + ".." + delimeter)
    return {'result': result, 'operation': op}
Esempio n. 7
0
def update_from_console(t, *al, **ad):
    '''
    A wrapper function to deal with user input from console. 

    String input from console is in console encoding. We must 
    first cast it to unicode, which is the standard across 
    SNSAPI. 

    '''
    if isinstance(t, str):
        return sp.update(console_input(t), *al, **ad)
    elif isinstance(t, snstype.Message):
        return sp.update(t, *al, **ad)
    else:
        logger.warning("unknown type: %s", type(t))
Esempio n. 8
0
def update_from_console(t, *al, **ad):
    '''
    A wrapper function to deal with user input from console. 

    String input from console is in console encoding. We must 
    first cast it to unicode, which is the standard across 
    SNSAPI. 

    '''
    if isinstance(t, str):
        return sp.update(console_input(t), *al, **ad)
    elif isinstance(t, snstype.Message):
        return sp.update(t, *al, **ad)
    else:
        logger.warning("unknown type: %s", type(t))
Esempio n. 9
0
    elif isinstance(t, snstype.Message):
        return sp.update(t, *al, **ad)
    else:
        logger.warning("unknown type: %s", type(t))

lc = load_config = lambda *al, **ad : sp.load_config(*al, **ad)
sc = save_config = lambda *al, **ad  : sp.save_config(*al, **ad)
lsc = list_channel = lambda  *al, **ad : sp.list_channel(*al, **ad)
lsp = list_platform = lambda  *al, **ad : sp.list_platform(*al, **ad)
newc = new_channel = lambda *al, **ad : sp.new_channel(*al, **ad)
addc = add_channel = lambda *al, **ad : sp.add_channel(*al, **ad)
clc = clear_channel = lambda *al, **ad : sp.clear_channel(*al, **ad)
auth = lambda  *al, **ad : sp.auth(*al, **ad)
ht = home_timeline = lambda *al, **ad : sp.home_timeline(*al, **ad)
up = update = lambda  t, *al, **ad : update_from_console(t, *al, **ad)
re = reply = lambda  m, t, *al, **ad : sp.reply(m, console_input(t), *al, **ad)
fwd = forward = lambda  m, t, *al, **ad : sp.forward(m, console_input(t), *al, **ad)

#==== documentation ====

helpdoc = \
"""
snscli -- the interactive CLI to operate all SNS!

Type "print helpdoc" again to see this document. 

To start your new journey, type "print tut"

Here's the command list:
   * load_config 
   * save_config 
Esempio n. 10
0
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()

    status_list = sp.home_timeline()

    print "==== read messages from all channels ===="

    no = 0
    for s in status_list:
        print "--No. %d --" % no
        s.show()
        no = no + 1

    print "==== try to reply one ===="

    print "Input the no:"
    no = int(console_input())
    print "Input the text:"
    text = console_input()

    sID = status_list[no].ID
    print sp.reply(sID, text)
Esempio n. 11
0
 def to_unicode(s):
     if isinstance(s, str):
         return console_input(s)
     else:
         return s
Esempio n. 12
0
        return sp.update(t, *al, **ad)
    else:
        logger.warning("unknown type: %s", type(t))


lc = load_config = lambda *al, **ad: sp.load_config(*al, **ad)
sc = save_config = lambda *al, **ad: sp.save_config(*al, **ad)
lsc = list_channel = lambda *al, **ad: sp.list_channel(*al, **ad)
lsp = list_platform = lambda *al, **ad: sp.list_platform(*al, **ad)
newc = new_channel = lambda *al, **ad: sp.new_channel(*al, **ad)
addc = add_channel = lambda *al, **ad: sp.add_channel(*al, **ad)
clc = clear_channel = lambda *al, **ad: sp.clear_channel(*al, **ad)
auth = lambda *al, **ad: sp.auth(*al, **ad)
ht = home_timeline = lambda *al, **ad: sp.home_timeline(*al, **ad)
up = update = lambda t, *al, **ad: update_from_console(t, *al, **ad)
re = reply = lambda m, t, *al, **ad: sp.reply(m, console_input(t), *al, **ad)
fwd = forward = lambda m, t, *al, **ad: sp.forward(m, console_input(t), *al, **
                                                   ad)

#==== documentation ====

helpdoc = \
"""
snscli -- the interactive CLI to operate all SNS!

Type "print helpdoc" again to see this document. 

To start your new journey, type "print tut"

Here's the command list:
   * load_config 
Esempio n. 13
0
def update_post():
    sp.auth()
    status = request.forms.get('status')
    status = snsapi_utils.console_input(status)
    result = sp.update(status)
    return {'result': result, 'status': status, 'submit': True}
Esempio n. 14
0
def update_post():
    sp.auth()
    status = request.forms.get('status')
    status = snsapi_utils.console_input(status)
    result = sp.update(status)
    return {'result': result, 'status': status, 'submit': True}
Esempio n. 15
0
    '''
    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()

    status_list = sp.home_timeline()

    print "==== read messages from all channels ===="
    
    no = 0
    for s in status_list:
        print "--No. %d --" % no
        s.show()
        no = no + 1
        
    print "==== try to reply one ===="

    print "Input the no:"
    no = int(console_input())
    print "Input the text:"
    text = console_input()

    sID = status_list[no].ID
    print sp.reply(sID, text)