confuse.py added (props to wrk)

This commit is contained in:
Dionysus 2023-06-19 12:54:20 -04:00
parent 0c45e3d527
commit a988e7f06c
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE

112
scripts/python/confuse.py Normal file
View File

@ -0,0 +1,112 @@
# -*- coding: utf-8 -*-
# confusables - developed by acidvegas in python (https://git.acid.vegas/random)
# adapted as a weechat script by wrk
'''
This script contains a dictionary of keyboard typable characters unicode variants that are very similar.
Other possible variants exist, for now we are only matching the ones that do not "look" like unicode.
This can be used to evade spam filtering by replacing characters with their similar unicode variants.
Todo:
- Convert unicode characters into raw codepoints in the dictionary (Example: \u202e)
- Add variants for missing typable characters (iIl)
- Extend to more variants than already in the database
- Set different odds on character replacement for chance feature on the confuse function
'''
import weechat
import random
def confuse(data, chance=False):
'''chance set to True will give each replacable character a 50% chance of being replaced'''
confused = str()
for char in data:
if char in confusable and (not chance or random.choice((True,False))):
confused += random.choice(list(confusable[char]))
else:
confused += char
return confused
confusable = {
' ':' ',
'.':'܂․.⡀',
'!':'ǃ',
'$':'',
'%':'',
'&':'',
':':'ː˸։׃',
';':';',
'<':'',
'=':'',
'>':'',
'?':'',
'@':'',
'0':'߀𝛰𐊒𝟬𝜪O𝞞𝝤Օ𝟢𝗢𝘖ОΟ𝟎𝐎𐊫𝙾𐐄𝟶𝑶𝚶𐓂𐐬𐓪',
'1':'𝚕𝟏𝟙𝟣𝟭𝟷',
'2':'Ƨ𝟐𝟤𝟮𝟸',
'3':'ƷȜЗӠ',
'4':'𝟒𝟜𝟦𝟰𝟺',
'5':'Ƽ',
'6':'б',
'7':'𐓒',
'8':'𐌚𝟖𝟠𝟪𝟴',
'9':'',
'A':'ΑАᎪᗅᴀꓮꭺA𐊠',
'B':'ΒВ𐊂𐊡𝐁𝐵𝑩𝔹𝖡𝗕𝘉𝘽𝚩𝜝𝝗𝞑',
'C':'СᏟᑕℂⅭ⊂ⲤꓚC𐊢𐐕',
'D':'ᎠᗞᗪⅮꓓꭰD𝐃𝐷𝑫𝔻𝖣𝗗𝘋𝘿𝙳',
'E':'ΕЕᎬ⋿ⴹꓰꭼE𐊆',
'F':'ϜᖴꓝꞘF𐊇𐊥𝟋',
'G':'ɢԌᏀᏳᏻꓖꮐG𝐆𝐺𝑮𝔾𝖦𝗚𝘎𝙂𝙶',
'H':'ʜΗНнᎻᕼⲎꓧH𐋏𝐇𝐻𝑯𝖧𝗛𝘏𝙃𝚮𝛨𝜢𝝜𝞖',
'J':'ͿЈᎫᒍᴊꓙꞲꭻJ𝐉𝐽𝑱𝕁𝖩𝗝𝙹',
'K':'ΚК',
'L':'ʟᏞᒪⅬⳐⳑꓡꮮL𐐛𐑃',
'M':'ΜϺМ𐊰𐌑𝐌𝑀𝑴𝕄𝖬𝗠𝘔𝙈𝙼𝚳𝛭𝜧𝝡𝞛',
'N':'ɴΝⲚꓠN',
'O':'OΟОՕ𐊒𐊫𐐄𐐬𐓂𐓪',
'P':'ΡРᏢᑭᴘᴩℙⲢꓑꮲP𐊕𝐏𝑃𝑷𝖯𝗣𝘗𝙋𝙿𝚸𝛲𝜬𝝦𝞠',
'Q':'𝐐𝑄𝑸𝖰𝗤𝘘𝙌𝚀',
'R':'ƦʀᎡᏒᖇᚱꓣꭱꮢR𐒴',
'S':'ЅՏ𐊖𐐠',
'T':'ΤТтᎢᴛ⊤⟙ⲦꓔꭲT𐊗𐊱𐌕',
'U':'Ս𐓎',
'V':'Ѵ٧۷',
'W':'Ԝ',
'X':'ΧХ𐊐𐊴𐌗𐌢',
'Y':'ΥϒУҮ𐊲',
'Z':'Ζ𐋵',
'a':'ɑαа𝐚𝑎𝒂𝕒𝖆𝖺𝗮𝘢𝙖𝚊𝛂𝛼𝜶𝝰𝞪',
'b':'ƄЬ𝐛𝑏𝒃𝖇𝖻𝗯𝘣𝙗𝚋',
'c':'ϲс𐐽𝐜𝑐𝒄𝕔𝖈𝖼𝗰𝘤𝙘𝚌',
'd':'ԁ𝐝𝑑𝒅𝒹𝓭𝖽𝗱𝘥𝙙𝚍',
'e':'еҽ𝐞𝕖𝖾𝗲𝚎',
'f':'',
'g':'ƍɡց𝐠𝑔𝒈𝕘𝖌𝗀𝗴𝘨𝙜𝚐',
'h':'һ𝒉𝕙𝗁𝗵𝘩𝙝𝚑',
'j':'ϳј𝐣𝚓',
'k':'𝐤𝑘𝒌𝕜𝖐𝗄𝗸𝘬𝙠𝚔',
'm':'m𝕞𝙢𝗺ⅿ',
'n':'ոռ𝗇𝗻𝘯𝙣𝚗',
'o':'OΟОՕ𐊒𐊫𐐄𐐬𐓂𐓪',
'p':'ρϱр𝑝𝕡𝗉𝗽𝘱𝙥𝚙𝛒𝜌𝝆𝞀𝞺',
'q':'ԛ𝐪𝕢𝗊𝗾𝘲𝙦𝚚',
'r':'г𝐫𝗋𝗿𝚛',
's':'ѕ𐑈',
't':'𝘁𝚝',
'u':'ʋυս𐓶',
'v':'νѵ',
'w':'ɯѡԝա',
'x':'×х𝐱𝑥𝒙𝔵𝕩𝖝𝗑𝘅𝘹𝙭𝚡',
'y':'ɣγуүỿ',
'z':'𝙯𝗓𝕫𝚣𝒛'
}
def cmd_confuse(data, buf, msg):
weechat.command(buf, f'/input send {confuse(msg)}')
return weechat.WEECHAT_RC_OK
if weechat.register('confuse', 'acidvegas & wrk', '1.0', 'ISC', 'confuse mfers', '', ''):
weechat.hook_command('confuse', 'confuse text', '<text>', '', '', 'cmd_confuse', '')