« first day (4724 days earlier)      last day (64 days later) » 

12:08 AM
Also the fact that the bot automatically leaves means this page gets reloaded whenever I ctrl-C which is strange to get used to
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Okay, I've tried to handle incoming markdown stuff. I want to see if it actually works. give me some bold or monospace text
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: I only have to process it in the SE -> Discord direction, the other way works out of the box
 
lyxal: test message
unless ofc its turned off :p
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: <:squant:817467355042545715>
...dammit
@lyxal That doesn't have markdown though
 
i know i know i wanted to see if it confused anyone :p
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: On the Discord side I will eventually be able to make it change username and pfp per-message with help from webhooks so
 
 
12:12 AM
That caused a NameError. Thanks
 
25 mins ago, by Ginger
can't believe you're just letting the lyxal be in the same room as your bot
 
No that was on me
I refactored something and forgot to change the variable name somewhere
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: okay send that again
 
function is not iterable
...I messed up the argument order to map
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: surely this time it will work
 
12:17 AM
what happens if a message is edited?
 
nothing yet
 
ah
 
@Ginger I love automatically leaving the room when my code breaks
TypeError: sequence item 0: expected str instance, generator found
 
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: STOP IT
 
12:18 AM
that's just the risk you take for using an alt account
 
had to do it to em
 
okay I shut it off
 
and now you know what ginger meant
 
The error is coming from return ''.join(map(translate_tag, soup.children)). translate_tag is a Callable[[bs4.PageElement], Generator[str, Any, None]]. What do I need to change to get this to work
oh duh flatmap instead of map
...how do you flatmap in python
 
there's something for it in itertools I think
 
12:21 AM
sum(map(func, values), []) apparently
 
that is beyond cursed, wow
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: frickin python. I like fluent interfaces better than this ridiculous nesting
 
saaaaame
 
okay send the image again
 
anyway:
 
12:23 AM
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: TypeError: can only concatenate list (not "generator") to list
 
and that's why i love scala
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: In JS this would be soup.children.flatMap(translateTag).join(''). Nice and simple. Python is making me jump through so many hoops for this frickin
 
I'm considering making a new version of sechat in Kotlin
 
yes please
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: screw it, comprehension time.
```py
return ''.join([
i for child in soup.children for i in translate_tag(child)
])
```
 
now you're thinking with Python!
 
12:31 AM
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: @Ginger @lyxal one of you send the image again
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: AttributeError 🙃
 
Oh I know what I did
@lyxal already shut it off :P
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Send the image
 
12:34 AM
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: fricking typeerror again aaaaaa
 
do you even typecheck
:p
 
my editor says this is a str but at runtime it's a generator
    def translate_tag(tag: bs4.PageElement):
        if isinstance(tag, bs4.Tag):
            match tag.name:
                case 'i' | 'em':
                    yield '*'
                    yield from map(translate_tag, tag.children)
                    yield '*'
                case 'b' | 'strong':
                    yield '**'
                    yield from map(translate_tag, tag.children)
                    yield '**'
                case 'code':
                    marker = '`' if '``' in tag.text else '``'
why is join receiving a list that contains a generator
also yes I need to add case 'a', but first i need to get it to stop crashing
 
soup.children is a generator, no?
just wrap it in list or tuple
 
yeah but shouldn't the comprehension take care of that
i is a str. The comprehension should give a List[str], then, no?
why is it giving a List[generator] at runtime?
 
I've never used nested for comprehensions like that, so idk
maybe you have the fors backwards?
try for i in translate_tag(child) for child in soup.children
 
12:42 AM
nope, if I do that then the first child is undefined and the second one is unused
 
or just for i in map(translate_tag, soup.children)
 
@Ginger oh duh
If I spell it as i for i in map(translate_tag, soup.children) now i is a generator
i for gen in map(translate_tag, soup.children) for i in gen?
 
duh
 
what does translate_tag return?
 
translate_tag returns a generator
 
12:43 AM
^
 
hm
map(list, map(translate_tag, soup.children))
 
but then I need to flatten it -- that's why I'm using a comprehension instead of doing that
I need to turn an Iterable[Generator[str]] into a List[str]
 
check the itertools stdlib module
I think it has a function for that
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: I want to see if this double-comprehension works first
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: send the image again
 
 
12:47 AM
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: thanks
@Ginger can you do it?
 
wrong link
 
WELL SCREW YOU TOO PYTHON
 
 
guess what error I got
TypeError: sequence item 0: expected str instance, generator found
m = map(translate_tag, soup.children)
c = itertools.chain(*m)
l = list(c)
return ''.join(l)
trying this now
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Please let this work
 
12:52 AM
 
NO HOW DOES THIS KEEP HAPPENING
EVEN THAT FOUND A GENERATOR
...oh
I figured it out
I'm yield froming an iterable of the wrong type
In any other language I would've gotten a type error long ago that my IDE would point out
 
always annotate your functions :b
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: I did... but the IDE doesn't warn me when I feed something the wrong type
 
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: I suppose this is my first time using a language that isn't compiled in a good while
success
 
hm.
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Do I need to special-case ob-youtube? Try other websites' oneboxes
 
An egg is an organic vessel grown by an animal to carry a possibly fertilized egg cell (a zygote) and to incubate from it an embryo within the egg until the embryo has become an animal fetus that can survive on its own, at which point the animal hatches. Most arthropods, vertebrates (excluding live-bearing mammals), and mollusks lay eggs, although some, such as scorpions, do not. Reptile eggs, bird eggs, and monotreme eggs are laid out of water and are surrounded by a protective shell, either flexible or inflexible. Eggs laid on land or in nests are usually kept within a warm and favorable ...
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: > Ginger: //upload.wikimedia.org/wikipedia/commons/thumb/5/54/Adolphe_Millot_oeufs-fixed.jpg/220px-Adolphe_Millot_oeufs-fixed.jpg//en.wikipedia.org/static/favicon/wikipedia.ico EggAn egg is an organic vessel grown by an animal to carry a possibly fertilized egg cell (a zygote) and to incubate from it an embryo within the egg until the embryo has become an animal fetus that can survive on its own, at which point the animal hatches.
> Most arthropods, vertebrates (excluding live-bearing mammals), and mollusks lay eggs, although some, such as scorpions, do not.
 
1 min ago, by Bbrk24
user image
 
@element("f", 1)
def deep_flatten(lhs, ctx):
    """Element f
    (any) -> flatten list completely
    """

    @lazylist_from(lhs)
    def gen():
        for item in iterable(lhs, ctx=ctx):
            if type(item) in (LazyList, list):
                yield from deep_flatten(item, ctx)
            else:
                yield item

    return gen()

@element("f", 1)
def deep_flatten(lhs, ctx):
    """Element f
    (any) -> flatten list completely
    """

    @lazylist_from(lhs)
    def gen():
 
12:59 AM
 
testing with a really long message
 
@Ginger That broke but only because SE used a relative link
@lyxal That broke because I don't handle pre
@Ginger that worked
Okay stopping this for a bit to work on oneboxes
What's the python version of JS find / Swift first(where:)?
 
list(filter(fun, stuff))[0]
 
seriously?
 
yup
 
1:05 AM
there isn't even a first? because I could write that
 
there is not
 
def first(iter):
  for el in iter:
    return el
 
alternately, if you're sure the iterator has at least one element, next(iter)
but that raises StopIteration if the iterator's empty
 
I see
if soup.has_attr('class') and 'onebox' in soup['class']:
    ob_type = list(filter(lambda c: c.startswith('ob-'), soup['class']))[0]
 
idiomaic Python right there
 
1:09 AM
I hate it
 
import vyxal.elements
return ''.join(list(vyxal.elements.deep_flatten(lst, None)))
easy :p
 
if soup.has_attr('class') and 'onebox' in soup['class']:
    ob_type = list(filter(lambda c: c.startswith('ob-'), soup['class']))[0]
    match ob_type:
        case 'ob-image':
            return soup.find('img').attrs['src']
        case 'ob-youtube' | 'ob-wikipedia' | 'ob-xkcd':
            return soup.find('a').attrs['href']
        case 'ob-message':
            return 'https://chat.stackexchange.com' + soup.find('a', {'class': 'roomname'}).attrs['href']
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: I believe that should handle every kind of onebox
try them again
 
@lyxal test message
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: that just got translated as a regular <a> tag, not a onebox
 
how about the ping
how did that show up?
 
1:20 AM
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Just the plain text "@lyxal"
 
interesting
 
but not surprising
 
because it was actually sent as @@354515
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: huh
 
(superping)
 
1:21 AM
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: ...that showed up as <code> instead of monospace
restarting it rq to check something
Okay I haven't fixed the code thing but try the xkcd again
 
soup.has_attr('class') is False
I'm checking it wrong
 
@Bbrk24 Hi checking it wrong, I'm Oak!
 
class_
 
what do I need to do?
I got the has_attr idea from SO
 
1:26 AM
it's class_
not class
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: okay, try again
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: soup.has_attr('class_') is also False
 
darn
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Do I need to check the root element and not the soup object itself 🤦
how would I even do that
keep in mind the soup is a single div and not an entire HTML document
> Since the BeautifulSoup object doesn’t correspond to an actual HTML or XML tag, it has no name and no attributes.
okay it looks like I can pass find a callback
does that work? send the xkcd again
@Ginger
 
1:41 AM
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: well I'm an idiot
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: NameError: none is not defined. Lowercase N.
try it again
 
I wanted to also try a gif
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: those both worked
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: it still uses ob-image for gifs
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: do the really long code block again
 
1:43 AM
switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
 
Oh I'm only translating divs not pres :facepalm:
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: I am now matching HTML with regex <:salpmao:530883329889927169>
do the codeblock again
 
switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
}switch (someChsr) {
case 'w':
case 'W':
    // some code for 'w' or 'W'
    break;
case 'x': // etc
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: my regex didn't work 😢
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: does . not match linebreaks or something
 
This room was placed in timeout for 10 seconds; the topic of this room is "Where you can play with chat features (except flagging) and chatbots without upsetting anyone." - conversation should be limited to that topic.
good question
no clue
how did it handle that?
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: > lyxal: <i>This room was placed in timeout for 10 seconds; the topic of this room is "Where you can play with chat features (except flagging) and chatbots without upsetting anyone." - conversation should be limited to that topic.</i>
 
1:50 AM
very interesting
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: there was an extra space in my regex
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: okay now try something with formatting (big code block, italics, anything)
 
Wilson

In the 1 month experience I've had with any programming language, I've assumed that switch case conditions would accept anything in the parenthesis as a boolean checking thingamajig, ie these:

|| && < >

Know what I mean?

something like

char someChar = 'w';
switch (someChar) {
case ('W' ||'w'):
    System.out.println ("W or w");
}

Sadly, doesn't seem to work that way. I can't have boolean checking in switch case.

Is there a way around it?

By the way, terribly sorry if I'm sounding confusing. I don't quite know the names for everything in this language yet :X
26
Q: How to do a case with multiple conditions?

AfroManIn the 1 month experience I've had with any programming language, I've assumed that switch case conditions would accept anything in the parenthesis as a boolean checking thingamajig, ie these: || && < > Know what I mean? something like char someChar = 'w'; switch (someChar) { case ('W' ||'w'...

 
oh I don't handle op-post
the code block still didn't work
what about inline formatting like italics
 
obamna SODA!!!!
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Okay I forgot about <strike> but the italics worked!\
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: okay try a codeblock again
 
1:55 AM
    if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
    if (sr == null) {
    if (sr == null) {if (sr == null) {
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: ey there we go!
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: and the post just to be sure
 
4 mins ago, by lyxal
26
Q: How to do a case with multiple conditions?

AfroManIn the 1 month experience I've had with any programming language, I've assumed that switch case conditions would accept anything in the parenthesis as a boolean checking thingamajig, ie these: || && < > Know what I mean? something like char someChar = 'w'; switch (someChar) { case ('W' ||'w'...

26
Q: How to do a case with multiple conditions?

AfroManIn the 1 month experience I've had with any programming language, I've assumed that switch case conditions would accept anything in the parenthesis as a boolean checking thingamajig, ie these: || && < > Know what I mean? something like char someChar = 'w'; switch (someChar) { case ('W' ||'w'...

 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: <:derpthink:814420575048040468> forgot the https: but the //stackoverflow.com... is fine
do the post one more time
 
26
Q: How to do a case with multiple conditions?

AfroManIn the 1 month experience I've had with any programming language, I've assumed that switch case conditions would accept anything in the parenthesis as a boolean checking thingamajig, ie these: || && < > Know what I mean? something like char someChar = 'w'; switch (someChar) { case ('W' ||'w'...

(removed)
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: that worked, awesome
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: I'm stopping for tonight
 
 
11 hours later…
12:42 PM
gjonk
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: So I have added some new features -- namely, changed the way that images work -- that I would like to test. But also comments
 
now how do you plan to test importing comments given that imported comments go to their own chat room
 
I was about to mention that :p
 
I meant the kind where you link to a comment and it gets embedded
 
oh
 
12:44 PM
ohhh
 
"boolean checking thingamajig these" are called "operators", and "tis Java" is made clear by the java tag you added. Also, the entire code snippet you posted is invalid (Java doesn't have a case), and { and } are misplaced). It's better to post real code you're having issues with; most of the time the act of making up fictional code either hides the problem or adds additional problems that aren't in the original. Perhaps a Google search would help - I tried case statement Java and the first result was helpful. — Ken White Dec 8, 2012 at 4:34
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: It worked
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: that one didn't
 
huh
no duh
 
12:44 PM
 
it's a comment ona deleted post
I wasn't sure it'd even load in the first place :p
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: ah okay
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Should I blockquote the comment like it is in SE?
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: uh
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: whatever you just did kicked me out of the sandbox
 
12:46 PM
lmao
it was a bookmark embed
 
@Ginger No this one
 
lol
pffft
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Ginger's message immediately after the bookmark embed doesn't show up here
 
check the link :b
like, click on it
 
or does it literally not show
 
12:47 PM
I directly linked ajax-loader.gif
we do a little trolling
 
like literally not even get sent on discord
 
Oh! The embed thing I did for images doesn't work for gifs, so Discord rejected it and my bot crashed
 
F
hey guys watch this
 
 
aw darn xe shut it off
 
12:48 PM
Let me restart and then test it with a png or jpeg
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: okay
 
me omw to link a webm
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: that would work I'd just have to set type='video' I think
 
except I don't think chat actually embeds webms ;-;
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: @lyxal you still have AI rydwolf?
 
oh yes
 
12:49 PM
 
bot crashed again
I forgot the scheme in the URL
se has a nasty tendency to use href="//i.stack.imgur.com/5xPDg.png"
Also it turns out the embed description field is required
 
is the bot running?
 
not currently, I'm fixing some things
 
in the meantime I've got a picutre you might like
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Okay it's back up. For some reason discord.Embed.__init__ takes both "color" and "colour" as kwargs
 
12:57 PM
how do user embeds look?
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: bad
 
 
 
𝙗𝙚𝙗𝙚𝙧𝙠𝙖: Also one message I sent was silently not translated because it exceeded the character limit for one line
I'm stopping this because the images aren't working
 

« first day (4724 days earlier)      last day (64 days later) »