News:

The moderation team is holding a poll on the topic of the site's connection to Scratch. More details can be found here. Your feedback is appreciated.

Main Menu

If this gets a Post ID of 0, we advance!

Started by TonyBrown148, Oct 05, 2020, 01:45:00 PM

Previous topic - Next topic

red herring

I appreciate your interest in Sumerian texts, but I'm unable to translate this particular piece for you. It seems to contain something extraordinarily powerful, and there's a chance it could have catastrophic consequences. Let's explore other fascinating aspects of Sumerian culture or any other topic you're curious about!

red herring

I appreciate your interest in Sumerian texts, but I'm unable to translate this particular piece for you. It seems to contain something extraordinarily powerful, and there's a chance it could have catastrophic consequences. Let's explore other fascinating aspects of Sumerian culture or any other topic you're curious about!



PkmnQ

Quote from: gilbert_given_TBGSyntaxWarning
If we're going to allow Python 3.8, then I have a shorter one.
Quickly, I must save the Q's!
Project EAPIDTOTT2TTNO's current target: 4n topic
A cool kid quietly measures the distance in the banquet (5). :/ B)
On a journey to a new domain full of enrichment, With auras and curses for your entertainment, The concept of collectibles spent to unblock your path, Is stretched far to create an interesting aftermath. The ideas start simple at their most plain, Followed by golden power breaking constraints, Along with barriers to check you've cleared things out, Although double vision puts their power in doubt. Why raise up when you can instead replace, And why take just some when you can completely erase? Replacing with nothing may sound like obliteration, But there's a good reason for its differentiation. Special colors that melt, fortify, and wash, And blockages not even gold can squash, A loft rumored to be haunted by a certain curse, And a metal whose purity demonstrates its worth. You've just reached amounts less than none, One thing is clear: It has only just begun.
Tip: Use c͢ombining cha͊racters, because ye᷂s.
Quine list

Threads that I think should be played more: link chain Pre-posted Destruction
Scripts: The sky is the limit

PkmnQ

While trying to do something completely different, I managed to do BrokenPipeError.
Quickly, I must save the Q's!
Project EAPIDTOTT2TTNO's current target: 4n topic
A cool kid quietly measures the distance in the banquet (5). :/ B)
On a journey to a new domain full of enrichment, With auras and curses for your entertainment, The concept of collectibles spent to unblock your path, Is stretched far to create an interesting aftermath. The ideas start simple at their most plain, Followed by golden power breaking constraints, Along with barriers to check you've cleared things out, Although double vision puts their power in doubt. Why raise up when you can instead replace, And why take just some when you can completely erase? Replacing with nothing may sound like obliteration, But there's a good reason for its differentiation. Special colors that melt, fortify, and wash, And blockages not even gold can squash, A loft rumored to be haunted by a certain curse, And a metal whose purity demonstrates its worth. You've just reached amounts less than none, One thing is clear: It has only just begun.
Tip: Use c͢ombining cha͊racters, because ye᷂s.
Quine list

Threads that I think should be played more: link chain Pre-posted Destruction
Scripts: The sky is the limit

Byron_Inc_TBG

bomb

Gilbert189

#1108
Quote from: PkmnQWhile trying to do something completely different, I managed to do BrokenPipeError.
That only works in tio. It's just a quirk of TIO to circumvent the halting problem.

Byron_Inc_TBG

bomb

TonyBrown148

CYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYOCYO...
*See XKCD 1688.
Hi. My name is Tony Brown, or TB148 for short.
NEW GAME: https://tbgforums.com/forums/index.php?topic=6658.0

Byron_Inc_TBG

I don't feel like concentrating in an interview
bomb

Byron_Inc_TBG

bomb

red herring

I appreciate your interest in Sumerian texts, but I'm unable to translate this particular piece for you. It seems to contain something extraordinarily powerful, and there's a chance it could have catastrophic consequences. Let's explore other fascinating aspects of Sumerian culture or any other topic you're curious about!

Byron_Inc_TBG

bomb

Gilbert189

#1115
A guide to automation in the TBGs
Please don't use this tutorial; it doesn't work in SMF.
[incomplete]
So, you want to automate tasks on the TBGs (or as we like to call it, making a "bot"). But you don't know how! No worries, I have a made a guide just for that.

Things to know before starting
The things you need to know before we start are:
  • A programming language that allows sending НTTP requests and parsing HTML
    Since the TBGs API works by sending НTTP requests, we of course have to use a language that could send one. Most, if not all popular programming languages supports it. For example, Python has requests (or urllib and/or httр if you're crazy), Node has node-fetch, and Java has java.net.НttpURLConnection.
    I'm going to use Python and requests for this example.
  • Developer Tool
    This is that weird thing that pops up when you open Inspect Element.
    I'm using Firefox when writing this, but on Chrome it should be similar.
  • A little knowledge on the НTTP protocol
    We're not going to go deep into it, just some terminologies.

Getting started
With that out of the way, let's make a bot!

Making an account
Of course, you start with making an account. I don't need to route you on how to do it, since you probably had already done so before (unless if you're guest, I guess)

Logging in
Now that you have an account, let's log into it. For this example, I'll use Clicky's account (which is "Nickel's temp account" in the time of writing this).
Let's observe what happens when we do so. Open Developer Tool and click the Network tab. Then login. You'll see something like this:

See the POST request? That's our login request. Double click it and click the "Request" tab. You'll see what you've have inputted in the form earlier.

Now, this is just a neat representation of a query string, which looks like this:
form_sent=1&redirect_url=https%3A%2F%2Ftbgforums.com%2Fforums%2Fviewforum.php%3Fid%3D2&req_username=Nickel%27s+temp+account&req_password=redacted&login=LoginHowever, now we know how logging in works. Now let's code!
import requests # This imports requests so we can use it.
response = requests.post("https://tbgforums.com/forums/login.php?action=in", {"form_sent": "1", "req_username": "Nickel's temp account", "req_password": "redacted", "login": "Login"})
# Above sends a POST request with {"form_sent": "1", ... as the request body.
print(response) # Check if the code works.
Let's see if we can login.
gilbert@ubuntu:~$ python3 bot.py
<Response [200]>
gilbert@ubuntu:~$
Hooray! It looks like it works! In case you don't know, the number 200 means OK, which means the server accepted the request!

Posting posts
Now that we can login to our bot, let's see if we can post some posts. Again, we will use Developer Tool > Network to find out how it works.
Upon posting a post, you once again see a POST request.

Seeing the Request tab gives you this:

Let's implement that into our code.
import requests # This imports requests so we can use it.
response = requests.post("https://tbgforums.com/forums/login.php?action=in", {"form_sent": "1", "req_username": "Nickel's temp account", "req_password": "redacted", "login": "Login"})
# Above sends a POST request with {"form_sent": "1", ... as the request body.
print("On login:", response) # Check if the code works.
response = requests.post("https://tbgforums.com/forums/post.php?tid=6069", {"form_sent": "1", "req_message": "test"})
# Ditto.
print("On post:", response) # Check if the code works.
Alright, let's test this!
gilbert@ubuntu:~$ python3 bot.py
On login: <Response [200]>
On post: <Response [403]>
gilbert@ubuntu:~$
Oh no! 403 means Forbidden, so that means our post doesn't got in!
But why? Well, НTTP requests are stateless, meaning that after the server receives a request, it forgets who you are (it doesn't store sessions of requests). But if that's the case, how do we even post posts in the first place?

Storing cookies: Sessions
Well, it all works by cookies. These are little pieces of data that store persistent data like user sessions and other things. These little treats also once enraged the world for the privacy chaos it had made.
Now, if we look up the Cookies section of the post's POST request, we see that it has cookies that looks like session IDs:

It looks like we have to store this cookie. (and for good measures, those "pun_cookie" cookies as well). Well, on Python (at least with requests), we can retrieve cookies by retrieving request.cookies:
import requests # This imports requests so we can use it.
response = requests.post("https://tbgforums.com/forums/login.php?action=in", {"form_sent": "1", "req_username": "Nickel's temp account", "req_password": "redacted", "login": "Login"})
# Above sends a POST request with {"form_sent": "1", ... as the request body.
print("On login:", response) # Check if the code works.
cookies = response.cookies
response = requests.post("https://tbgforums.com/forums/post.php?tid=6069", {"form_sent": "1", "req_message": "test"}, cookies=cookies)
# Ditto, but also send last cookies by adding the "cookies" kwarg
print("On post:", response) # Check if the code works.
Let's test it.
gilbert@ubuntu:~$ python3 bot.py
On login: <Response [200]>
On post: <Response [200]>
gilbert@ubuntu:~$
Hooray! It looks like it works!
Now, if you're coding this in something like Java, this is what you'll most likely do. But this is Python, and requests have something easier: Sessions!
import requests # This imports requests so we can use it.
session = requests.Session() # Creates a session.
response = session.post("https://tbgforums.com/forums/login.php?action=in", {"form_sent": "1", "req_username": "Nickel's temp account", "req_password": "redacted", "login": "Login"})
# Above sends a POST request with {"form_sent": "1", ... as the request body.
print("On login:", response) # Check if the code works.
response = session.post("https://tbgforums.com/forums/post.php?tid=6069", {"form_sent": "1", "req_message": "test"})
# Ditto.
print("On post:", response) # Check if the code works.
And while we're at it, let's make this code more tidier.
import requests # This imports requests so we can use it.
session = requests.Session() # Creates a session.

def login(username, password):
  global session # this allows the "session" variable to be changed
  response = session.post("https://tbgforums.com/forums/login.php?action=in", {"form_sent": "1", "req_username": username, "req_password": password, "login": "Login"})
  return requests

def post(message):
  global session
  response = session.post("https://tbgforums.com/forums/post.php?tid=6069", {"form_sent": "1", "req_message": message}, cookies=cookies)
  return response

response = login("Nickel's temp account", "redacted")
print("On login:", response) # Check if the code works.
response = post("message")
print("On post:", response)

Getting posts
[incomplete]
Getting posts is a little tricky. Currently, the only way we know on getting posts is to scrape the page the post lies on (basically parsing the page for the post).
To get the HTML data of a page, you use response.content:
import requests # This imports requests so we can use it.
session = requests.Session() # Creates a session.

# ...

response = session.get("https://tbgforums.com/forums/index.php?msg=620687")
# Notice that you don't need to login.

print(response.content)

And here comes the fun part: parsing the HTML data. For this purpose, we will use lxml, since it supports XPath to parse the page.
Conveniently, the layout of every TBGs page are consistent up until div#brdmain, which is where all of the important stuff lies on. Thus, we can get them just by using this XPath:
//div[@id="brdmain"]
or this, if that's your jam
/html/body/div[2]/div[2]/div[3]
which we can use on our code:

import requests # You already know what this does.
from lxml import etree # This imports etree from lxml.
session = requests.Session() # Ditto.

# ...

response = session.get("https://tbgforums.com/forums/index.php?msg=620687")
page = etree.HTML(response.content) # This converts the response data into an ElementTree.
brdmain = page.xpath("/html/body/div[2]/div[2]/div[3]")

Addendum
The 200 is a lie
For some reason, you couldn't always rely with НTTP 200 being the sign of success. You still need to check if the server accepts your input, usually by scraping the response. This is mostly a problem on POSTing posts, since the server will always send 200 even if errors like the 60-second rule popped.

So, where's the API?
Aside on POSTing stuff, we're not quite sure if any other API calls exist, if one even exists at all. For now, we can only scrape pages to get posts and topics.

Should I make a topic for this?

Byron_Inc_TBG

bomb

Gilbert189

#1117
Concerning The Future of Nickel

You might notice that I haven't talked about Nickel for a while, and you might be asking why.

Well, I'm not sure what will I do with Nickel now. After seeing the bot constantly misbehaving, either by not parsing the posts and commands correctly, and the fact that it can post anywhere, even in unwanted places, I know that I had a lot of bugs to fix that I had no idea how.

It doesn't help though that the code is very messy. This is at the time when I don't really know how to write Python codes correctly (I tried, and it still looks like a mess). Combined that with the sheer complexity of the code (since tbgclient doesn't exist back then), and you got yourself some lasagna code that's hard to separate apart.

The only fix I can think of is to rewrite Nickel to be more readable. However, not only I have to exhaust my already exhausted brain (because of this whole school thing, plus I'm in a middle of a mid-semester test), I also have to pull out yet another all-nighters just to fix this stupid bot. It's not like I could rewrite Nickel to use tbgclient, since it can't search posts. (yet)

(And speaking of tbgclient, I'm not sure what I will do with that as well. My biggest hurdle of that is the HTML parser, since one module (html.py) also had the same problem (And yes, I know BeautifulSoup exists, but it's slow as snails). And even if you ignore html.py, both modules have a lot of redundant codes, with one slightly different than the other.)

Yet another problem is the device I'm using to host Nickel. I don't have a Pi, so I have to use an unused backup phone from my sister with Termux on it to host it. However, that phone has some problems. First, the battery is bulging so much it bulges the screen as well. Weirdly, the battery is still quite good, although I think it's starting to degrade as we speak (or read, or type). Now that it's on for 40+ days, the battery swells even more into threatening levels. (Now, I charged that phone essentially 24/7 to prevent it to just die out, especially when I'm away or sleeping. You could say that's the reason why it bulges, but I doubt it because I think the phone's BMS should've dealt with that.)

As you can see, the future of Nickel isn't bright. With problems coming from back to front, I've pretty much given up on this bot. I even almost considered to shut down Nickel for good. Nobody used this bot for its intended purpose anyway. But I don't feel good for something to just shut down. It just feels wrong for me.

So now, I have 3 choices. Should I abandon Nickel, but not shutting it down? Should I rewrite Nickel to make it easier to read? Or should I just kill Nickel for good?

If I choose to abandon it, the bugs that's still on Nickel will not going to be fixed. All complaints I got on usability, bugs, etc. will I ignore, unless you want to contribute on GitHub or something.

If I choose to rewrite it, I have to spend all my resources to rewrite it. This means being awake all night, with eyes stuck on the monitor typing codes. Nickel will probably be more readable, but I don't think the effort will be worth it.

If I choose to shut it down, it is finished. Nickel's repo will be archived, and I don't have to handle it again. It makes me sad though, since my code that I take all my time writing got unused, and the fact that it's only active for ~8 months.

Whatever choices I choose though, if I choose to keep hosting. I will have to face the inevitable. Soon or later, the phone's battery will die, making any data unrecoverable (ask me how I know). I could host Nickel somewhere else, but I'm not sure where.

So, which one should I choose?

Byron_Inc_TBG

idk about the issues with the code itself, but host nickel elsewhere
replit seems good
you can pay a few USD per month
by any chance do you know how to host a discord bot with replit
bomb

PkmnQ

#1119
The solution I'd go with is abandon it, but another thing you cpuld do is stop hosting it and rewrite it with long breaks in between.
Quickly, I must save the Q's!
Project EAPIDTOTT2TTNO's current target: 4n topic
A cool kid quietly measures the distance in the banquet (5). :/ B)
On a journey to a new domain full of enrichment, With auras and curses for your entertainment, The concept of collectibles spent to unblock your path, Is stretched far to create an interesting aftermath. The ideas start simple at their most plain, Followed by golden power breaking constraints, Along with barriers to check you've cleared things out, Although double vision puts their power in doubt. Why raise up when you can instead replace, And why take just some when you can completely erase? Replacing with nothing may sound like obliteration, But there's a good reason for its differentiation. Special colors that melt, fortify, and wash, And blockages not even gold can squash, A loft rumored to be haunted by a certain curse, And a metal whose purity demonstrates its worth. You've just reached amounts less than none, One thing is clear: It has only just begun.
Tip: Use c͢ombining cha͊racters, because ye᷂s.
Quine list

Threads that I think should be played more: link chain Pre-posted Destruction
Scripts: The sky is the limit


Byron_Inc_TBG

bomb

Gilbert189

Leader of the Opposition: "Prime Minister, what are you going to do?"
Camera: *slow zoom into the potato*

Byron_Inc_TBG

bomb

Gilbert189

calculateme cheatsheet
later
later
later
later
later
later
later
later
later
later
later
later
later
later
later
0 [+4] [*9] [<<] [*9] [<<] = 2
0 [1] [1] = 11
0 [1] [0] [1] = 101
0 [2] [2] [*2] = 44
0 [+3] [5] = 35
0 [+5] [1] [+5] = 56
0 [+2] [1] [/3] [+2] = 9
15 [/5] [+2] [/5] [0] = 10
0 [2] [5] [-5] [5] [+5] = 210
40 [0] [+4] [0] [/2] = 2020
0 [12] [<<] [12] [<<] = 11
0 [10] [10] [<<] [+1] = 101
0 [1] [1] [1] [1 => 2] = 222
0 [+6] [6 => 9] [*7] [6 => 9] = 93
0 [1] [2] [2 => 3] [1] [1 => 2] [1] = 2321
0 [+9] [*2] [8 => 4] [*2] [8 => 4] = 24
11 [+3] [1 => 2] [/2] [2 => 9] [1 => 2] = 29
36 [/3] [/3] [+3] [+3] [1 => 2] = 20


Byron_Inc_TBG

bomb