-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Several improvement about supergroup and channel #61
Changes from all commits
e3790d9
037ba78
a32a555
3e17303
84ca3ed
5cb2593
fab5c77
a27a5ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
TGL_PEER_USER = u("user") | ||
TGL_PEER_ENCR_CHAT = u("encr_chat") | ||
TGL_PEER_GEO_CHAT = u("geo_chat") #todo: does this even exists? | ||
TGL_PEER_CHANNEL = u("channel") | ||
|
||
def fix_message(message): | ||
# skip if not has message typical elements | ||
|
@@ -32,21 +33,28 @@ def fix_message(message): | |
# create the peer, thats where to reply to. | ||
if message["own"]: | ||
message["peer"] = None | ||
elif message["receiver"]["type"] == TGL_PEER_CHAT or message["receiver"]["type"] == TGL_PEER_GEO_CHAT: | ||
elif message["receiver"]["type"] in [TGL_PEER_CHAT, TGL_PEER_GEO_CHAT, TGL_PEER_CHANNEL]: | ||
message["peer"] = message["receiver"] | ||
elif message["receiver"]["type"] == TGL_PEER_USER or message["receiver"]["type"] == TGL_PEER_ENCR_CHAT: | ||
elif message["receiver"]["type"] in [TGL_PEER_USER, TGL_PEER_ENCR_CHAT]: | ||
message["peer"] = message["sender"] | ||
# return it | ||
return message | ||
|
||
|
||
def fix_peer(peer): | ||
# rename peer_type => type | ||
if "peer_type" in peer and peer["peer_type"]: | ||
peer["type"] = peer["peer_type"] | ||
del peer["peer_type"] | ||
|
||
# add cmd field | ||
if peer["type"] == TGL_PEER_ENCR_CHAT: | ||
assert peer["print_name"].startswith(ENCR_CHAT_PREFIX) | ||
peer["cmd"] = peer["print_name"] | ||
elif peer["type"] == TGL_PEER_CHANNEL: | ||
peer["cmd"] = u("%s#id%d") % (peer["type"], peer["peer_id"]) | ||
else: | ||
peer["cmd"] = peer["type"] + u("#") + u(str(peer["id"])) | ||
peer["cmd"] = u("%s#%d") % (peer["type"], peer["peer_id"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be more happy if you could use u("{type}#{id}").format(type=peer["type"], id=peer["peer_id"]) instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, there is a problem here. In test branch, what used to be "id" is renamed with "peer_id" and "id" now is something else. But I'm not sure whether it's OK for master branch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if you are confusing the u("{foo}#{bar}").format(foo=peer["type"], bar=peer["peer_id"]) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. never mind. I saw the u("{type}#{id}").format(type=peer["type"], id=peer["id"]) (You currently have more insight to the code then me 😄 You can decide) |
||
|
||
#remove print_name field | ||
#create name field | ||
|
@@ -62,7 +70,7 @@ def fix_peer(peer): | |
peer["name"] = peer["first_name"] | ||
elif "username" in peer and peer["username"]: | ||
peer["name"] = peer["username"] | ||
elif peer["type"] == TGL_PEER_CHAT: | ||
elif peer["type"] in [TGL_PEER_CHAT, TGL_PEER_CHANNEL]: | ||
if "title" in peer and peer["title"]: | ||
peer["name"] = peer["title"] | ||
elif peer["type"] == TGL_PEER_ENCR_CHAT: | ||
|
@@ -75,4 +83,4 @@ def fix_peer(peer): | |
peer["name"] = peer["username"] # there are no other choices. | ||
else: | ||
logger.error("Unknown peer type: {type}".format(type={peer["type"]})) | ||
return peer | ||
return peer |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,7 @@ | |
# functions["channel_set_admin"] = ("channel_set_admin", <channel> <admin> <type> Sets channel admin. 0 - not admin, 1 - moderator, 2 - editor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you can have a look at this old line here, while your on it. |
||
functions["channel_set_username"] = ("channel_set_username", [args.Channel("channel"), args.UnicodeString("name")], res.success_fail, None, "Sets channel username info.") | ||
functions["channel_set_photo"] = ("channel_set_photo", [args.Channel("channel"), args.File("file")], res.something, 120.0, "Sets channel photo. Photo will be cropped to square") | ||
functions["channel_rename"] = ("rename_channel", [args.Channel("channel"), args.UnicodeString("new_name")], res.success_fail, None, "Renames channel") | ||
|
||
# own profile | ||
functions["set_profile_name"] = ("set_profile_name", [args.UnicodeString("first_name"), args.UnicodeString("last_name")], res.something, 60.0, "Sets profile name.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a duplicate of line 100...?
Will fix this.