Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
可通过 qq 号码(而不是 uin )发消息
Browse files Browse the repository at this point in the history
  • Loading branch information
pandolia committed Sep 16, 2016
1 parent 07c473b commit 802c7d4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ QQBot 登录完成后,可以进行消息收发了,且 好友/群/讨论组
...]
>>> print bot.buddyStr
好友列表:
1880557506 - Jack
2776164208 - Mike
1880557506, Jack, uin2311151202
2776164208, Mike, uin4578565512
...

#### 2. 消息收发
Expand All @@ -116,7 +116,13 @@ QQBot 登录完成后,可以进行消息收发了,且 好友/群/讨论组

**send** 方法的三个参数为 **msgType****to_uin****message** ,分别代表 **消息类型****接收者的 uin** 以及 **消息内容** ,消息内容必须是一个 **utf8** 编码的 string 。

请注意:这里说的 **uin** 不是 好友/群/讨论组 的 **qq 号码** ,而是每次登录成功后给该 好友/群/讨论组 分配的的一个 **临时 id**
请注意:这里说的 **uin** 不是 好友/群/讨论组 的 **qq 号码** ,而是每次登录成功后给该 好友/群/讨论组 分配的的一个 **临时 id** 。用以下语句可以通过 **uin** 获得好友 **qq 号码**

self.buddiesDictU[uin]['qq']

用以下语句可以通过 **qq 号码** 获得好友的 **uin**

self.buddiesDictQ[qq]['uin']

如果发送消息的频率过快, qq 号码可能会被锁定甚至封号。因此每发送一条消息之前,会强制 sleep 3~5 秒钟,每发送 10 条消息之前,会强制 sleep 10 秒钟。

Expand Down
17 changes: 10 additions & 7 deletions qqbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
author: pandolia@yeah.net
"""

QQBotVersion = "QQBot-v1.8.1"
QQBotVersion = "QQBot-v1.8.2"

import json, os, logging, pickle, sys, time, random, platform, subprocess
import requests, Queue, threading
Expand Down Expand Up @@ -255,8 +255,9 @@ def fetchBuddies(self):
self.buddies.append(buddy)
self.buddiesDictU[uin] = buddy
self.buddiesDictQ[qq] = buddy
ss.append('%d - %s' % (qq, name))
QLogger.info('好友: %d - %s' % (qq, name))
s = '%d, %s, uin%d' % (qq, name, uin)
ss.append(s)
QLogger.info('好友: ' + s)
self.buddyStr = '好友列表:\n' + '\n'.join(ss)
QLogger.info('获取朋友列表成功,共 %d 个朋友' % len(self.buddies))

Expand All @@ -280,8 +281,9 @@ def fetchGroups(self):
self.groups.append(group)
self.groupsDictU[uin] = group
self.groupsDictQ[qq] = group
ss.append('%d - %s' % (qq, name))
QLogger.info('群: %d - %s' % (qq, name))
s = '%d, %s, uin%d' % (qq, name, uin)
ss.append(s)
QLogger.info('群: ' + s)
self.groupStr = '群列表:\n' + '\n'.join(ss)
QLogger.info('获取群列表成功,共 %d 个朋友' % len(self.groups))

Expand All @@ -299,8 +301,9 @@ def fetchDiscusses(self):
discuss = dict(uin=uin, name=name)
self.discusses.append(discuss)
self.discussesDict[uin] = discuss
ss.append('%d - %s' % (uin, name))
QLogger.info('讨论组: %d - %s' % (uin, name))
s = '%s, uin%d' % (name, uin)
ss.append(s)
QLogger.info('讨论组: ' + s)
self.discussStr = '讨论组列表:\n' + '\n'.join(ss)
QLogger.info('获取讨论组列表成功,共 %d 个讨论组' % len(self.discusses))

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name = 'qqbot',
version = '1.8.1',
version = '1.8.2',
py_modules = ['qqbot'],
entry_points = {
'console_scripts': [
Expand All @@ -16,7 +16,7 @@
author = 'pandolia',
author_email = 'pandolia@yeah.net',
url = 'https://github.com/pandolia/qqbot/',
download_url = 'https://github.com/pandolia/qqbot/archive/v1.8.1.tar.gz',
download_url = 'https://github.com/pandolia/qqbot/archive/v1.8.2.tar.gz',
keywords = ['QQBot', 'conversation robot', 'tencent', 'qq', 'web', 'network', 'python', 'http'],
classifiers = [],
)
4 changes: 4 additions & 0 deletions uploadtopip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
python setup.py register -r pypitest
python setup.py sdist upload -r pypitest
python setup.py register -r pypi
python setup.py sdist upload -r pypi

0 comments on commit 802c7d4

Please sign in to comment.