Skip to content

Instantly share code, notes, and snippets.

@charmingLitteDeveloper
Forked from littlecodersh/main.py
Created August 30, 2023 15:38
Show Gist options
  • Save charmingLitteDeveloper/6c658cfe5a66cce85f145794a8c84f1f to your computer and use it in GitHub Desktop.
Save charmingLitteDeveloper/6c658cfe5a66cce85f145794a8c84f1f to your computer and use it in GitHub Desktop.

Revisions

  1. @littlecodersh littlecodersh revised this gist Feb 6, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions main.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #coding=utf8
    import itchat
    # tuling plugin can be get here:
    # https://github.com/littlecodersh/EasierLife/tree/master/Plugins/Tuling
  2. @littlecodersh littlecodersh revised this gist Nov 15, 2016. 1 changed file with 19 additions and 20 deletions.
    39 changes: 19 additions & 20 deletions main.py
    Original file line number Diff line number Diff line change
    @@ -1,50 +1,49 @@
    #!python3
    import itchat
    # tuling plugin can be get here:
    # https://github.com/littlecodersh/EasierLife/tree/master/Plugins/Tuling
    from tuling import get_response

    @itchat.msg_register('Text')
    def text_reply(msg):
    if '作者' in msg['Text'] or '主人' in msg['Text']:
    return '你可以在这里了解他:https://github.com/littlecodersh'
    elif '源代码' in msg['Text'] or '获取文件' in msg['Text']:
    if u'作者' in msg['Text'] or u'主人' in msg['Text']:
    return u'你可以在这里了解他:https://github.com/littlecodersh'
    elif u'源代码' in msg['Text'] or u'获取文件' in msg['Text']:
    itchat.send('@[email protected]', msg['FromUserName'])
    return '这就是现在机器人后台的代码,是不是很简单呢?'
    elif '获取图片' in msg['Text']:
    return u'这就是现在机器人后台的代码,是不是很简单呢?'
    elif u'获取图片' in msg['Text']:
    itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture
    else:
    return get_response(msg['Text']) or '收到:' + msg['Text']
    return get_response(msg['Text']) or u'收到:' + msg['Text']

    @itchat.msg_register(['Picture', 'Recording', 'Attachment', 'Video'])
    def atta_reply(msg):
    return ({ 'Picture': '图片', 'Recording': '录音',
    'Attachment': '附件', 'Video': '视频', }.get(msg['Type']) +
    '已下载到本地') # download function is: msg['Text'](msg['FileName'])
    return ({ 'Picture': u'图片', 'Recording': u'录音',
    'Attachment': u'附件', 'Video': u'视频', }.get(msg['Type']) +
    u'已下载到本地') # download function is: msg['Text'](msg['FileName'])

    @itchat.msg_register(['Map', 'Card', 'Note', 'Sharing'])
    def mm_reply(msg):
    if msg['Type'] == 'Map':
    return '收到位置分享'
    return u'收到位置分享'
    elif msg['Type'] == 'Sharing':
    return '收到分享' + msg['Text']
    return u'收到分享' + msg['Text']
    elif msg['Type'] == 'Note':
    return '收到:' + msg['Text']
    return u'收到:' + msg['Text']
    elif msg['Type'] == 'Card':
    return '收到好友信息:' + msg['Text']['Alias']
    return u'收到好友信息:' + msg['Text']['Alias']

    @itchat.msg_register('Text', isGroupChat = True)
    def group_reply(msg):
    if msg['isAt']:
    return '@%s\u2005%s' % (msg['ActualNickName'],
    get_response(msg['Text']) or '收到:' + msg['Text'])
    return u'@%s\u2005%s' % (msg['ActualNickName'],
    get_response(msg['Text']) or u'收到:' + msg['Text'])

    @itchat.msg_register('Friends')
    def add_friend(msg):
    itchat.add_friend(**msg['Text'])
    itchat.send_msg('项目主页:github.com/littlecodersh/ItChat\n'
    + '源代码 :回复源代码\n' + '图片获取:回复获取图片\n'
    + '欢迎Star我的项目关注更新!', msg['RecommendInfo']['UserName'])
    itchat.send_msg(u'项目主页:github.com/littlecodersh/ItChat\n'
    + u'源代码 :回复源代码\n' + u'图片获取:回复获取图片\n'
    + u'欢迎Star我的项目关注更新!', msg['RecommendInfo']['UserName'])

    itchat.auto_login(True, enableCmdQR = True)
    itchat.auto_login(True, enableCmdQR=True)
    itchat.run()
  3. @littlecodersh littlecodersh created this gist Aug 25, 2016.
    50 changes: 50 additions & 0 deletions main.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,50 @@
    #!python3
    import itchat
    # tuling plugin can be get here:
    # https://github.com/littlecodersh/EasierLife/tree/master/Plugins/Tuling
    from tuling import get_response

    @itchat.msg_register('Text')
    def text_reply(msg):
    if '作者' in msg['Text'] or '主人' in msg['Text']:
    return '你可以在这里了解他:https://github.com/littlecodersh'
    elif '源代码' in msg['Text'] or '获取文件' in msg['Text']:
    itchat.send('@[email protected]', msg['FromUserName'])
    return '这就是现在机器人后台的代码,是不是很简单呢?'
    elif '获取图片' in msg['Text']:
    itchat.send('@[email protected]', msg['FromUserName']) # there should be a picture
    else:
    return get_response(msg['Text']) or '收到:' + msg['Text']

    @itchat.msg_register(['Picture', 'Recording', 'Attachment', 'Video'])
    def atta_reply(msg):
    return ({ 'Picture': '图片', 'Recording': '录音',
    'Attachment': '附件', 'Video': '视频', }.get(msg['Type']) +
    '已下载到本地') # download function is: msg['Text'](msg['FileName'])

    @itchat.msg_register(['Map', 'Card', 'Note', 'Sharing'])
    def mm_reply(msg):
    if msg['Type'] == 'Map':
    return '收到位置分享'
    elif msg['Type'] == 'Sharing':
    return '收到分享' + msg['Text']
    elif msg['Type'] == 'Note':
    return '收到:' + msg['Text']
    elif msg['Type'] == 'Card':
    return '收到好友信息:' + msg['Text']['Alias']

    @itchat.msg_register('Text', isGroupChat = True)
    def group_reply(msg):
    if msg['isAt']:
    return '@%s\u2005%s' % (msg['ActualNickName'],
    get_response(msg['Text']) or '收到:' + msg['Text'])

    @itchat.msg_register('Friends')
    def add_friend(msg):
    itchat.add_friend(**msg['Text'])
    itchat.send_msg('项目主页:github.com/littlecodersh/ItChat\n'
    + '源代码 :回复源代码\n' + '图片获取:回复获取图片\n'
    + '欢迎Star我的项目关注更新!', msg['RecommendInfo']['UserName'])

    itchat.auto_login(True, enableCmdQR = True)
    itchat.run()