Пример #1
0
 def Update(self, update=False):
     if (update):
         bot.Login([
             '-q', self.qq_num_sender, '-ip', self.ip, '-hp', self.port,
             '--daemon', '-r'
         ])
         bot.Update('buddy')
         bot.Update('group')
         return "update successfully!"
Пример #2
0
def sendMessage(bot, group, content):
    bot.Update('group')
    gl = bot.List('group', group)
    print gl[0].qq
    if gl:
        qq_item = {
            'xnr_qq_number': bot.session.qq,
            'xnr_nickname': bot.session.nick,
            'timestamp': int(round(time.time())),
            'speaker_qq_number': bot.session.qq,
            'text': content,
            'speaker_nickname': bot.session.nick,
            'qq_group_number': gl[0].qq,
            'qq_group_nickname': group
        }
        qq_json = json.dumps(qq_item)
        print qq_json

        conMD5 = string_md5(content)

        nowDate = datetime.datetime.now().strftime('%Y-%m-%d')
        index_name = sent_group_message_index_name_pre + str(nowDate)
        index_id = bot.conf.qq + '_' + gl[0].qq + '_' + str(
            int(round(time.time()))) + '_' + conMD5
        # 将发送的信息存入es
        if not es.indices.exists(index=index_name):
            group_message_mappings(bot.session.qq, nowDate)

        es.index(index=index_name,
                 doc_type=group_message_index_type,
                 id=index_id,
                 body=qq_item)

        bot.SendTo(gl[0], content)
        return 1
    else:
        print 'you no own this group', group
        return 0
Пример #3
0
 def update(cls):
     bot.Update('buddy')
     bot.Update('group')
Пример #4
0
from qqbot import _bot as bot

bot.Login(['-q', '3391775316'])

bot.Update('buddy')

g = bot.List('buddy', 'imp')  # 直接输入qq号不行
g = g[0]
print([g, type(g), g.qq, g.name, g.uin, g.mark])
bot.SendTo(g, 'hello')