forked from rDrama/rDrama
add ability to bulk add and bulk kick ppl in private chats
parent
4234c35d0c
commit
3bba1f9356
|
@ -11,8 +11,8 @@ valid_username_patron_regex = re.compile("^[\w-]{1,25}$", flags=re.A)
|
||||||
mention_regex = re.compile('(?<![:/\w])@([\w-]{1,30})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
mention_regex = re.compile('(?<![:/\w])@([\w-]{1,30})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
group_mention_regex = re.compile('(?<![:/\w])!([\w-]{3,25})' + NOT_IN_CODE_OR_LINKS, flags=re.A|re.I)
|
group_mention_regex = re.compile('(?<![:/\w])!([\w-]{3,25})' + NOT_IN_CODE_OR_LINKS, flags=re.A|re.I)
|
||||||
|
|
||||||
chat_adding_regex = re.compile('\+@[\w-]{1,30}' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
chat_adding_regex = re.compile('\+@([\w-]{1,30})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
chat_kicking_regex = re.compile('\-@[\w-]{1,30}' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
chat_kicking_regex = re.compile('\-@([\w-]{1,30})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
|
|
||||||
everyone_regex = re.compile('(^|\s|>)!(everyone)' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
everyone_regex = re.compile('(^|\s|>)!(everyone)' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
|
|
||||||
|
|
|
@ -155,8 +155,8 @@ def speak(data, v):
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
|
|
||||||
if v.id == chat.owner_id:
|
if v.id == chat.owner_id:
|
||||||
if chat_adding_regex.fullmatch(text):
|
for i in chat_adding_regex.finditer(text):
|
||||||
user = get_user(text[2:], graceful=True, attributes=[User.id])
|
user = get_user(i.group(1), graceful=True, attributes=[User.id])
|
||||||
if user and not user.has_muted(v) and not user.has_blocked(v):
|
if user and not user.has_muted(v) and not user.has_blocked(v):
|
||||||
existing = g.db.query(ChatMembership.user_id).filter_by(user_id=user.id, chat_id=chat_id).one_or_none()
|
existing = g.db.query(ChatMembership.user_id).filter_by(user_id=user.id, chat_id=chat_id).one_or_none()
|
||||||
leave = g.db.query(ChatLeave.user_id).filter_by(user_id=user.id, chat_id=chat_id).one_or_none()
|
leave = g.db.query(ChatLeave.user_id).filter_by(user_id=user.id, chat_id=chat_id).one_or_none()
|
||||||
|
@ -167,8 +167,9 @@ def speak(data, v):
|
||||||
)
|
)
|
||||||
g.db.add(chat_membership)
|
g.db.add(chat_membership)
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
elif chat_kicking_regex.fullmatch(text):
|
|
||||||
user = get_user(text[2:], graceful=True, attributes=[User.id])
|
for i in chat_kicking_regex.finditer(text):
|
||||||
|
user = get_user(i.group(1), graceful=True, attributes=[User.id])
|
||||||
if user:
|
if user:
|
||||||
existing = g.db.query(ChatMembership).filter_by(user_id=user.id, chat_id=chat_id).one_or_none()
|
existing = g.db.query(ChatMembership).filter_by(user_id=user.id, chat_id=chat_id).one_or_none()
|
||||||
if existing:
|
if existing:
|
||||||
|
|
Loading…
Reference in New Issue