這篇是繼上篇另外做添加管理權限權限 @Display_name 111110
DO
$do$
BEGIN
IF EXISTS(SELECT uid FROM group_right WHERE uid='{uid}') THEN UPDATE group_right SET add_message_right={bool(int(right[0]))}, delete_message_right={bool(int(right[1]))},view_right={bool(int(right[2]))},add_buyer_right={bool(int(right[3]))},delete_buyer_right={bool(int(right[4]))},allow_changeright_right={bool(int(right[5]))} WHERE uid='{uid}';
ELSE INSERT INTO group_right (uid,add_message_right,delete_message_right,view_right,add_buyer_right,delete_buyer_right,allow_changeright_right) VALUES ('{uid}',{bool(int(right[0]))},{bool(int(right[1]))},{bool(int(right[2]))},{bool(int(right[3]))},{bool(int(right[4]))},{bool(int(right[5]))});
END IF;
END
$do$"
if(event.message.text[:2:]=="權限" and rights[5]):
if not event.message.mention is None:
for user in event.message.mention.mentionees:
uid=user.user_id
lastLength=3
text=event.message.text[3::]
right=text[text.find(" ",lastLength+1)+1:len(text):]
cursor = conn.cursor()
cursor.execute(f"DO $do$ BEGIN IF EXISTS(SELECT uid FROM group_right WHERE uid='{uid}') THEN UPDATE group_right SET add_message_right={bool(int(right[0]))}, delete_message_right={bool(int(right[1]))},view_right={bool(int(right[2]))},add_buyer_right={bool(int(right[3]))},delete_buyer_right={bool(int(right[4]))},allow_changeright_right={bool(int(right[5]))} WHERE uid='{uid}'; ELSE INSERT INTO group_right (uid,add_message_right,delete_message_right,view_right,add_buyer_right,delete_buyer_right,allow_changeright_right) VALUES ('{uid}',{bool(int(right[0]))},{bool(int(right[1]))},{bool(int(right[2]))},{bool(int(right[3]))},{bool(int(right[4]))},{bool(int(right[5]))}); END IF; END $do$")
conn.commit()
cursor.close()
message=TextSendMessage("權限已變更")
line_bot_api.reply_message(event.reply_token,message)