Compare commits

...

3 Commits

  1. 2
      .gitignore
  2. 51
      portbot.py
  3. 7
      porthyph.txt

2
.gitignore vendored

@ -1,3 +1,5 @@
.*
!.gitignore
!.gitmodules
config.toml
clients/

@ -11,6 +11,7 @@ from mastodon import Mastodon, MastodonNotFoundError
from fedbot.bot import Bot, BotClient
POST_INTERVAL = timedelta(seconds = 15)
TEST = False
def next_dt():
dt = datetime.now(timezone.utc)
@ -52,19 +53,20 @@ class WordMaker:
print("Loading dictionaries")
with open ("mhyph.txt", "r", encoding = "mac-roman") as f:
lines = [line.strip() for line in f.readlines()]
lines = filter(lambda word: len(word) > 0 and not re.search(r'[- A-Z]', word), lines)
lines = filter(lambda w: len(w) > 0 and not re.search(r'[- A-Z]', w), lines)
words = [line.split("") for line in lines]
words = sorted(words, key = lambda w: len(w), reverse = True)
self.words = words
self.first_words = list(filter(lambda word: not is_suffixed(word), words))
self.plain_words = ["".join(word) for word in words]
self.first_words = list(filter(lambda w: not is_suffixed(w), words))
self.plain_words = ["".join(w).lower() for w in words]
with open("porthyph.txt", "r") as f:
lines = [line.strip() for line in f.readlines()]
lines = filter(lambda l: len(l) > 0, lines)
words = [line.split("=") for line in lines]
words = sorted(words, key = lambda w: len(w), reverse = True)
self.alt_words = words
self.plain_words.append(["".join(word) for word in words])
self.plain_words.extend(["".join(w).lower() for w in words])
def get_one_word(self, words):
weights = [int(100.0 * (x + 1.0) / len(words)) for x in range(0, len(words))]
@ -72,7 +74,7 @@ class WordMaker:
def get_second_word(self, first_word):
first_word = list(first_word)
first_end = first_word[-1].lower()
first_end = first_word[-1]
if random.randint(0, 100) < 50:
second_dict = self.alt_words
@ -80,20 +82,18 @@ class WordMaker:
second_dict = self.words
if random.randint(0, 100) < 50:
second_iter = filter(lambda w: w[0].lower().startswith(first_end) or first_end.startswith(w[0].lower()), second_dict)
second_iter = filter(lambda w: w[0].lower().startswith(first_end.lower()) or first_end.lower().startswith(w[0].lower()), second_dict)
else:
second_iter = filter(lambda w: w[0].lower().startswith(first_end), second_dict)
second_iter = filter(lambda w: w[0].lower().startswith(first_end.lower()), second_dict)
second_words = list(second_iter)
#if len(second_words) < 8:
# return None
while len(second_words) > 0:
second_word_orig = self.get_one_word(second_words)
second_word = [s.lower() for s in second_word_orig]
second_words.remove(second_word_orig)
second_word = [s.lower() for s in second_word_orig]
word = [*first_word[:-1], *second_word]
if not "".join(word) in self.plain_words:
if not "".join(word).lower() in self.plain_words:
return word
return None
@ -109,20 +109,16 @@ class WordMaker:
while True:
word = self.get_one_word(words)
end = word[-1]
times = target_times
while times > 0:
next_word = self.get_second_word(word)
if next_word is None:
break
else:
word = next_word
times -= 1
if times > 0:
continue
else:
word = next_word
times -= 1
if times == 0:
break
word_str = "".join(word)
@ -180,11 +176,15 @@ def post():
else:
visibility = "unlisted"
client.api.status_post("\n".join(words), visibility = visibility)
if not TEST:
client.api.status_post("\n".join(words), visibility = visibility)
dt = next_dt()
print("Scheduling at", dt)
scheduler.enterabs(dt.timestamp(), 1, post)
if TEST:
scheduler.enter(1, 1, post)
else:
scheduler.enterabs(dt.timestamp(), 1, post)
wm = WordMaker()
scheduler = sched.scheduler(timefunc = time.time, delayfunc = time.sleep)
@ -197,5 +197,8 @@ print("Running")
dt = next_dt()
print("Scheduling at", dt)
scheduler.enterabs(dt.timestamp(), 1, post)
if TEST:
scheduler.enter(1, 1, post)
else:
scheduler.enterabs(dt.timestamp(), 1, post)
scheduler.run()

@ -21,6 +21,9 @@ ba=ka
ba=sed
b=as=ed
Bar=bie
Bat=man
Ba=t=man
Bat=m=an
bi=sex=u=al
Bit=coin
block=chain
@ -43,6 +46,7 @@ Buzz=feed
Bu=zz=feed
brain=let
bra=in=let
brain=l=et
bruh
bull=shit
butt=load
@ -345,6 +349,9 @@ So=n=ic
spam
sp=am
sperg
Spi=der=man
Sp=i=der=man
Spi=der=m=an
Sponge=bob
Spot=i=fy
Spo=ti=fy

Loading…
Cancel
Save