scrape pronouns

This commit is contained in:
vulpine 2020-08-11 16:45:19 -04:00
parent 8f035e1c18
commit a238a18d25
1 changed files with 30 additions and 0 deletions

30
modules/scrape.py Normal file
View File

@ -0,0 +1,30 @@
# '[\x0303Pronouns\x03] Pronouns for xfnw: he/him'
async def scraper(self,c,n,m):
m = m.split(' ')
if len(m) > 4:
if m.pop(0) in ('[\x0303Pronouns\x03]', '[Pronouns]') and m.pop(0) == 'Pronouns' and m.pop(0) == 'for':
person = m.pop(0)[:-1]
pronouns = ' '.join(m)
print('found pronouns of {}: {}'.format(person,pronouns))
self.pronoundb.upsert(dict(nick=person,pronouns=pronouns),['nick'])
async def getPronouns(self,c,n,m):
m = m.strip()
if not m:
m = n
pronoun = self.pronoundb.find_one(nick=m)
if pronoun:
await self.message(c,'[\x036scrape\x0f] Pronouns for {}: {}'.format(pronoun['nick'],pronoun['pronouns']))
else:
await self.message(c,'[\x036scrape\x0f] sorry i could not find {}\'s pronouns. (i scrape pronouns from logs, you dont need to set them :3 )'.format(m))
async def init(self):
self.raw['scraper'] = scraper
self.pronoundb = self.db['pronouns']
self.cmd['pronouns'] = getPronouns