Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pronoun extension #2319

Closed
eduardrich opened this issue Dec 27, 2020 · 10 comments
Closed

Pronoun extension #2319

eduardrich opened this issue Dec 27, 2020 · 10 comments

Comments

@eduardrich
Copy link

There is an extension of pronouns that they created, where several people use it, but the chatterino doesn’t appear, would you like to add this extension to the chatterino to appear?

https://twitter.com/Marielitai/status/1331778028012232704

Thank you very much from now,

@leon-richardt
Copy link
Collaborator

leon-richardt commented Dec 27, 2020

In my opinion, a similar reasoning as with #2289 is applicable here. The extension is "too niche" to spent time on implementing and maintaining it over an indefinite amount of time.

Also, as mentioned in #2289 (comment), adding support for one niche extension makes it harder to argue against supporting other niche extensions. Now, if the pronoun extension gained popularity on the levels of BTTV and FFZ, it would make sense to reconsider this at a later point in time.

(Note that this is just my personal opinion and may not reflect the views of the project maintainers.)

@ALazyMeme
Copy link
Collaborator

Chatterino was designed as an enhanced twitch chat experience. Pronouns are not apart of twitch chat and I certainly don't think they should be added to chatterino.

Related: #2227

@JxnBld
Copy link

JxnBld commented Mar 5, 2021

Chatterino was designed as an enhanced twitch chat experience. Pronouns are not apart of twitch chat and I certainly don't think they should be added to chatterino.

Related: #2227

okay well there IS a chrome extension where people can view each other's pronouns. and i would also like to see that on chatterino. so i don't think you stating how you haven't seen pronouns in your personal twitch bubble would help the forward development of chatterino.

@ALazyMeme
Copy link
Collaborator

ALazyMeme commented Mar 5, 2021

I don't understand why I have to clarify this when I was extremely clear in my last message.

If there IS a chrome extension, then USE the chrome extension. I (and about 99% of the people who contribute to Chatterino) don't care about someone's pronouns. When I am speaking to them I am referring to their username (you know, the unique alias people set online for themselves?).

@zneix
Copy link
Collaborator

zneix commented Apr 15, 2021

Duplicate of #2227

@zneix zneix marked this as a duplicate of #2227 Apr 15, 2021
@zneix zneix closed this as completed Apr 15, 2021
@Sinistral2099
Copy link

In my opinion, a similar reasoning as with #2289 is applicable here. The extension is "too niche" to spent time on implementing and maintaining it over an indefinite amount of time.

Also, as mentioned in #2289 (comment), adding support for one niche extension makes it harder to argue against supporting other niche extensions. Now, if the pronoun extension gained popularity on the levels of BTTV and FFZ, it would make sense to reconsider this at a later point in time.

(Note that this is just my personal opinion and may not reflect the views of the project maintainers.)

Pronoun support has been added into FFZ. So now that it has "gained popularity on the levels of BTTV and FFZ" please add it into Chatterino. It's also in Chatty.

@Felanbird
Copy link
Collaborator

#3346

@pajlada
Copy link
Member

pajlada commented Jun 25, 2022

@shirizaan While we appreciate your enthusiasm for the issue, it's not a technically simple feature to implement, at least not for us. The comment Felanbird linked to contains some of the information that holds us back.

I'm happy to discuss the feature if anyone has implementation ideas, but as it stands in its current state the only implementations discussed/contributed have been subpar.

@emi-rose
Copy link

emi-rose commented Oct 15, 2024

@pajlada @Felanbird

@shirizaan While we appreciate your enthusiasm for the issue, it's not a technically simple feature to implement, at least not for us. The comment Felanbird linked to contains some of the information that holds us back.

I'm happy to discuss the feature if anyone has implementation ideas, but as it stands in its current state the only implementations discussed/contributed have been subpar.

If I or someone else were wanting to build a test version with this capability where within the source would be the first place to look for username values and where would it be possible to append a text badge to the end of them. I already tested some code that can curl the https://pr.alejo.io/ api and return a user's pronoun_id as well as cache recent results within a matrix to prevent spamming them.

I don't have a lot of experience contributing to projects so any assistance or tips would be appreciated.

As far as the speed of the responses... basically instant when used in a simple CLI and since it caches results it only needs to poll a user once per session.

#include <curl/curl.h>
#include <glib.h>
#include <map>
#include <stdlib.h>
#include <string>

// Helper function to write data from curl
static size_t write_callback(void *contents, size_t size, size_t nmemb,
                             std::string *userp) {
  size_t realsize = size * nmemb;
  userp->append(static_cast<char *>(contents), realsize);
  return realsize;
}

// Function to get pronouns for a given username
bool get_user_pronouns(const gchar *username, std::string &response) {
  CURL *curl;
  CURLcode res;
  bool success = false;

  gchar *url =
      g_strdup_printf("https://pronouns.alejo.io/api/users/%s", username);
  curl = curl_easy_init();

  if (curl) {
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
    res = curl_easy_perform(curl);
    if (res == CURLE_OK) {
      success = true;
    }

    curl_easy_cleanup(curl);
  }

  g_free(url);
  return success;
}

// Function to extract the pronoun_id from the JSON response
const gchar *extract_pronoun_id(const std::string &json_response) {
  const gchar *key = "\"pronoun_id\":";
  const gchar *start = g_strstr_len(json_response.c_str(), -1, key);
  if (start) {
    start += strlen(key);
    while (*start == ' ' || *start == '"')
      start++;
    const gchar *end = g_strstr_len(start, -1, "\"");
    if (end) {
      gsize length = end - start;
      gchar *pronoun_id = g_strndup(start, length);
      return pronoun_id;
    }
  }
  return NULL;
}

// Function to check pronoun_id, caching results
const gchar *
check_pronoun_id(const gchar *username,
                 std::map<std::string, std::string> &pronoun_cache) {
  // Check if the username is in the cache
  auto it = pronoun_cache.find(username);
  if (it != pronoun_cache.end()) {
    return it->second.empty() ? NULL
                              : it->second.c_str(); // Return cached ID or NULL
  }

  // If not in cache, fetch from API
  std::string response;
  if (get_user_pronouns(username, response)) {
    const gchar *pronoun_id = extract_pronoun_id(response);
    if (pronoun_id) {
      pronoun_cache[username] = pronoun_id; // Cache the result
      g_free((gchar *)pronoun_id);          // Free allocated memory
    } else {
      pronoun_cache[username] = ""; // Cache empty ID if not found
    }
  }
  return pronoun_cache[username].empty() ? NULL
                                         : pronoun_cache[username].c_str();
}

@iProdigy
Copy link
Contributor

@emi-rose initial pronoun support has already been implemented in #5442 - you can run a nightly build to get access to the feature before the upcoming release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants