• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "python.3". Back to normal view
    1. I'm not going to post a topic or comment every time I update this silly thing, but this was a pretty big change that I felt necessitated a new topic. Link to the script Tildes Automated Posting...

      I'm not going to post a topic or comment every time I update this silly thing, but this was a pretty big change that I felt necessitated a new topic.

      Link to the script

      Tildes Automated Posting Script, or TAPS, is a Python script that posts topics to Tildes. Using the script's configuration file, you can define which account you want the topic to be posted under, the group the topic should be posted to, the link for that topic (if any), the comment or text for that topic (if any), as well as what tags the topic should have (if any, but highly encouraged).

      It also now works with accounts that use two-factor authentication.

      I wrote this because every Monday and Friday I post topics to ~talk at 11:00 AM. However, I'm a forgetful person, sometimes wake up late, and will be starting classes soon, so I thought it would be nice to have a script that I can schedule, using something like cron, to post those topics for me.

      The documentation should explain everything that can be done with the script, but anyone with questions or issues can message me for help.

      With these recent changes, the script no longer requires a web browser or Selenium. It should be able to run on pretty much anything. I'll be using the script on a Raspberry Pi Zero W to post my recurring topics.

      I wanted to have this update posted Sunday night, but at the last minute I decided to use @deing's tildee.py library, which made things a lot easier. I finsihed rewriting the script's code last night and updated the documentation today.

      25 votes
    2. Update! After a few hours of struggling I managed to set up Read the docs for Tildee, it should help using the library significantly. After getting some inspiration from TAPS I thought that maybe...

      Update! After a few hours of struggling I managed to set up Read the docs for Tildee, it should help using the library significantly.

      After getting some inspiration from TAPS I thought that maybe I try to work on something vaguely similar on my own. And after… some? hours of coding today I came up with this: tildee.py (source)
      It's a wrapper for the Tildes Public/Web API that is already used by the site internally to make it work. The obvious problem with that is that it will at one point break when this unstable API is changed. It can do basically all things a normal user can do with the notable exception of applying comment labels (because I haven't gotten around to that yet).

      Example of usage for a DM reply bot (result):

      import sys
      from tildee import TildesClient
      import time
      
      # Initialize client and log in, 2FA isn't supported yet and will probably break in horrible ways
      t = TildesClient("username", "password", base_url="https://localhost:4443", verify_ssl=False)
      
      while True:
          # Retrieve the "unread messages" page and get a list of the conversations there
          unread_message_ids = t.fetch_unread_message_ids()
          for mid in unread_message_ids:
              # Access the conversation history page; this also clears the "unread" flag 
              conversation = t.fetch_conversation(mid)
              # Get the text of the last message
              text = conversation.entries[-1].content_html
              # Abort if it's from the current user (I don't think this could actually happen)
              if conversation.entries[-1].author == t.username:
                  break
              print(f"Found a message by {conversation.entries[-1].author}")
              # If the message contains a reference, reply in kind
              if "hello there" in text.lower():
                  print("Replying…")
                  t.create_message(mid, f"General {conversation.entries[-1].author}! You are a bold one.")
              # Delay before processing next unread message
              time.sleep(3)
          # Delay before next unread check
          time.sleep(60)
      

      This has a lot of potential. Haven't yet figured out potential for what, but I'll take what I can get.
      I'd be really grateful if someone with a little more experience than me (that's not exactly a high bar :P) could give me some pointers on the project's structure and the "API design", hence the ask tag. Other creative ideas for what to use this for are appreciated, too.

      48 votes