Skip to content

Instantly share code, notes, and snippets.

@pqcfox
Created February 6, 2022 07:08
Show Gist options
  • Save pqcfox/929c198c84a16a3311b6bdc5d7296904 to your computer and use it in GitHub Desktop.
Save pqcfox/929c198c84a16a3311b6bdc5d7296904 to your computer and use it in GitHub Desktop.
The script running nWab (@nwab_uwu)
# All credit to Daniel Liu (https://github.com/Daniel-Liu-c0deb0t/uwu) for the uwuification algorithm
import random
import requests
import tweepy
from bs4 import BeautifulSoup
from string import ascii_lowercase
from subprocess import Popen, PIPE
r = requests.get('https://ncatlab.org/nlab/all_pages')
soup = BeautifulSoup(r.content, 'html.parser')
items = [item.find('a')['href'] for item in soup.find_all('li')]
swaps = {
'small': 'smol',
'cute': 'kawaii~',
'fluff': 'floof',
'love': 'luv',
'stupid': 'baka',
'what': 'nani',
'meow': 'nya~',
}
emoji = [
' rawr x3',
' OwO',
' UwU',
' o.O',
' -.-',
' >w<',
' (⑅˘꒳˘)',
' (ꈍᴗꈍ)',
' (˘ω˘)',
' (U ᵕ U❁)',
' σωσ',
' òωó',
' (///ˬ///✿)',
' (U ﹏ U)',
' ( ͡o ω ͡o )',
' ʘwʘ',
' :3',
' :3',
' XD',
' nyaa~~',
' mya',
' >_<',
' 😳',
' 🥺',
' 😳😳😳',
' rawr',
' ^^',
' ^^;;',
' (ˆ ﻌ ˆ)♡',
' ^•ﻌ•^',
' /(^•ω•^)',
' (✿oωo)'
]
whitespace = [' ', '\t', '\n']
punctuation = ['.', ',', '!']
def uwuify(m):
for key, value in swaps.items():
m = m.replace(key, value)
for w in whitespace:
m = m.replace(w + 'n', w + 'ny')
m = m.lower()
m = m.replace('l', 'w')
m = m.replace('r', 'w')
for i in range(len(m) - 1):
if m[i] in whitespace and m[i + 1] in ascii_lowercase:
if random.choice([True, False]):
m = m[:i + 1] + m[i + 1] + '-' + m[i + 1:]
for i in range(1, len(m) - 1):
if m[i] in punctuation and m[i - 1] not in punctuation:
if m[i + 1] in whitespace:
m = m[:i + 1] + random.choice(emoji) + m[i + 1:]
return m
while True:
page_url = random.choice(items)
r = requests.get(page_url)
soup = BeautifulSoup(r.content, 'html.parser')
idea_h2 = soup.find(id='idea')
if idea_h2 is None:
continue
idea_p = idea_h2.next_sibling.next_sibling
text = idea_p.get_text().split('.')[0] + '.'
post_text = uwuify(text)
# uwu = Popen(['/home/katie/.cargo/bin/uwuify'],
# stdout=PIPE, stdin=PIPE, stderr=PIPE)
# post_text = uwu.communicate(input=text.encode())[0].decode()
if len(post_text) <= 280:
break
auth = tweepy.OAuthHandler('<redacted>',
'<redacted>')
auth.set_access_token('<redacted>',
'<redacted>')
api = tweepy.API(auth)
try:
api.verify_credentials()
except:
print('Oops, auth error.')
api.update_status(post_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment