本文整理汇总了Python中bot.Bot.reply方法的典型用法代码示例。如果您正苦于以下问题:Python Bot.reply方法的具体用法?Python Bot.reply怎么用?Python Bot.reply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bot.Bot
的用法示例。
在下文中一共展示了Bot.reply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _hexchar2bin
# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import reply [as 别名]
#.........这里部分代码省略.........
def message_received(self, msg):
if msg['retcode'] == 0:
for i in msg['result']:
poll_type = i['poll_type']
data = i['value']
if poll_type == 'message':
from_uin = data['from_uin']
content = data['content'][1]
logger.info('[%s]:%s' % (self._get_name(from_uin), content))
if(type(content) == list):
content = str(content)
else:
content = _(content)
tt = threading.Thread(target=self.send_user_msg, args=(from_uin, self._botmsg(content,datetime.datetime.now,self._get_name(from_uin),from_uin),))
tt.start()
elif poll_type == 'group_message':
from_uin = data['from_uin']
groupname = self._get_name(from_uin)
send_uin = data['send_uin']
username = self._get_name(send_uin)
content = data['content'][1]
logger.info('[%s][%s]:%s' % (groupname, username, content))
if(type(content) == list):
content = str(content)
else:
content = _(content)
tt = threading.Thread(target=self.send_group_msg, args=(from_uin, self._botmsg(content,datetime.datetime.now(),username,send_uin,groupname,from_uin),))
tt.start()
else:
pass
def _botmsg(self, msg,msg_time=datetime.datetime.now(),buddy_name=None,buddy_num=None,qun_name=None,qun_num=None): return self.bot.reply(msg,msg_time,buddy_name,buddy_num,qun_name,qun_num)
def _get_name(self, uin):
'''<group> only,do not it use in <message>'''
if uin in self._user_info:
return self._user_info[uin]
elif uin in self._group_info:
return self._group_info[uin]
else:
logger.warn("can't find user's info")
def _get_info(self):
self._group_info = {}
self._user_info = {}
self._group_code={}
urlv = "http://s.web2.qq.com/api/get_user_friends2"
status = {'h': 'hello', 'vfwebqq': self._login_info['vfwebqq']}
data = {'r': json.dumps(status)}
res = self._request(urlv, data)
data = json.loads(res)
if data['retcode'] == 0:
self._user_info.update(dict([(x['uin'], x['nick']) for x in data['result']['info']]))
try:
self._user_info.update(dict([(x['uin'], x['markname']) for x in data['result']['marknames']]))
except KeyError:
logger.warn('have no markname')
logger.debug('fetch users info sucess')
else:
logger.error('fetch users info fail')
urlv = "http://s.web2.qq.com/api/get_group_name_list_mask2"
status = {"vfwebqq": self._login_info['vfwebqq']}
data = {'r': json.dumps(status)}