编辑Line的bot

时间:2017-11-14 02:13:00

标签: python github termux

我从https://github.com/merkremont/LineVodka

获得了机器人脚本

我想添加这个脚本,但它说语法错误/意外缩进

elif msg.text in ["Tag all","Tagall"]:
    if msg.from_ in admin:
        group = client.getGroup(msg.to)
        nama = [contact.mid for contact in group.members]

        cb = ""
        cb2 = ""
        strt = int(0)
        akh = int(0)
        for md in nama:
           akh = akh + int(6)

           cb += """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(md)+"},"""

           strt = strt + int(7)
           akh = akh + 1
           cb2 += "@nrik \n"

        cb = (cb[:int(len(cb)-1)])
        msg.contentType = 0
        msg.text = cb2
        msg.contentMetadata ={'MENTION':'{"MENTIONEES":['+cb+']}','EMTVER':'4'}

        try:
           sendMessage(msg)
        except Exception as error:
           print error

1 个答案:

答案 0 :(得分:0)

问题可能出在这一行

cb += """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(md)+"},"""

您将字符串作为单个双引号(")输入,但用三元组关闭(""")。

尝试

cb += """{"S":"""+json.dumps(str(strt))+""","E":"""+json.dumps(str(akh))+""","M":"""+json.dumps(md)+"},"

修改 对不起,再一次读到这个问题,我意识到这不是问题所在。尽管如此,我还是期待一个错误。无论如何......再次检查你的缩进是否与脚本一致,特别是如果你的elif与其他if和else语句一致。