« 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) »