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

Error when trying to call Client.getme #125

Closed
ghost opened this issue Sep 12, 2016 · 3 comments
Closed

Error when trying to call Client.getme #125

ghost opened this issue Sep 12, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 12, 2016

When I try to call Client.getme, I get this error:

Traceback (most recent call last):
  File "zalgo.py", line 14, in <module>
    me = client.get_me()
  File "build\bdist.win32\egg\chatexchange\client.py", line 125, in get_me
  File "build\bdist.win32\egg\chatexchange\_utils.py", line 78, in __get__
  File "build\bdist.win32\egg\chatexchange\browser.py", line 235, in _update_chat_fkey_and_user
  File "build\bdist.win32\egg\chatexchange\browser.py", line 218, in _load_user
  File "build\bdist.win32\egg\chatexchange\browser.py", line 226, in user_id_and_name_from_link
ValueError: invalid literal for int() with base 10: 'stackexchange.com'

The code:

import logging
import time

import chatexchange

#logging.basicConfig(level=logging.DEBUG)

with open("D:/CREDENTIALS") as f: # Change the path to link your credential file looking like `<email> <password>`
    s = f.read().split()

email, password = s

client = chatexchange.Client('stackexchange.com', email, password)
me = client.get_me()
sandbox = client.get_room(1)
sandbox.send_message("test from chatexchange")

time.sleep(2)

The credentials are correct, and posting from main account works.

@ByteCommander
Copy link
Contributor

I suspect this has something to do with the privilege level of the bot account (http://chat.stackexchange.com/users/227130/zalgo) which has currently only 30 chat rep points.

@ByteCommander
Copy link
Contributor

Modifying browser.py around line 230 to look like this:

    @staticmethod
    def user_id_and_name_from_link(link_soup):
        print(link_soup)  # <-- added this print line
        user_name = link_soup.text
        user_id = int(link_soup['href'].split('/')[2])
        return user_id, user_name

returns the following output for user Zalgo:

<a href="http://stackexchange.com/users/login?returnurl=http%3a%2f%2fchat.stackexch‌​ange.com%2fchats%2fjoin%2ffavorite">log in</a>

If I test it with my working ByteBot account, the result is this:

<a href="/users/146720/bytebot" title="ByteBOT">ByteBOT</a>

@ghost
Copy link
Author

ghost commented Sep 12, 2016

Modifying the password of the bot fixed the problem.

@ghost ghost closed this as completed Sep 12, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant