shift 修复 telethon 错误识别 id 的问题

This commit is contained in:
xtaodada 2021-08-07 23:52:36 +08:00
parent 2f8929c3e1
commit 2b6d7be27b
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 17 additions and 7 deletions

View File

@ -722,7 +722,7 @@
}, },
{ {
"name": "shift", "name": "shift",
"version": "1.02", "version": "1.03",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "5.3 kb", "size": "5.3 kb",

View File

@ -29,14 +29,14 @@ async def shift_set(context):
if not channel.broadcast: if not channel.broadcast:
await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。") await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。")
return return
channel = channel.id channel = int(f'-100{channel.id}')
except Exception: except Exception:
try: try:
channel = await context.client.get_entity(context.parameter[1]) channel = await context.client.get_entity(context.parameter[1])
if not channel.broadcast: if not channel.broadcast:
await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。") await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。")
return return
channel = channel.id channel = int(f'-100{channel.id}')
except Exception: except Exception:
await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。") await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。")
return return
@ -48,7 +48,11 @@ async def shift_set(context):
to = int(context.parameter[2]) to = int(context.parameter[2])
except Exception: except Exception:
try: try:
to = (await context.client.get_entity(context.parameter[2])).id to = await context.client.get_entity(context.parameter[2])
if to.broadcast or to.gigagroup or to.megagroup:
to = int(f'-100{to.id}')
else:
to = to.id
except Exception: except Exception:
await context.edit("出错了呜呜呜 ~ 无法识别的目标对话。") await context.edit("出错了呜呜呜 ~ 无法识别的目标对话。")
return return
@ -68,6 +72,8 @@ async def shift_set(context):
except Exception: except Exception:
try: try:
channel = (await context.client.get_entity(context.parameter[1])).id channel = (await context.client.get_entity(context.parameter[1])).id
if channel.broadcast or channel.gigagroup or channel.megagroup:
channel = int(f'-100{channel.id}')
except Exception: except Exception:
await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。") await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。")
return return
@ -88,14 +94,14 @@ async def shift_set(context):
if not channel.broadcast: if not channel.broadcast:
await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。") await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。")
return return
channel = channel.id channel = int(f'-100{channel.id}')
except Exception: except Exception:
try: try:
channel = await context.client.get_entity(context.parameter[1]) channel = await context.client.get_entity(context.parameter[1])
if not channel.broadcast: if not channel.broadcast:
await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。") await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。")
return return
channel = channel.id channel = int(f'-100{channel.id}')
except Exception: except Exception:
await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。") await context.edit("出错了呜呜呜 ~ 无法识别的来源对话。")
return return
@ -107,7 +113,11 @@ async def shift_set(context):
to = int(context.parameter[2]) to = int(context.parameter[2])
except Exception: except Exception:
try: try:
to = (await context.client.get_entity(context.parameter[2])).id to = await context.client.get_entity(context.parameter[2])
if to.broadcast or to.gigagroup or to.megagroup:
to = int(f'-100{to.id}')
else:
to = to.id
except Exception: except Exception:
await context.edit("出错了呜呜呜 ~ 无法识别的目标对话。") await context.edit("出错了呜呜呜 ~ 无法识别的目标对话。")
return return