EdupageAPI / edupage-api

A python library for accessing your Edupage account
https://edupageapi.github.io/edupage-api/
GNU General Public License v3.0
66 stars 13 forks source link

[Bug] Cannot use send_message (Edupage or Messages class - same) #62

Closed Nexusatko closed 1 year ago

Nexusatko commented 1 year ago

Describe the bug When I try to send any message to any classmate/person, it gives me an error pasted below.

Your code

from edupage_api import Edupage
from edupage_api.messages import Messages
from edupage_api.people import People
import datetime
import edupage_api
edupage = Edupage()
message = Messages(edupage)
ppl = People(edupage)
edupage.login_auto("better","not")
classmate = ppl.get_student(int(hidden-int-for-github-xd))

edupage.send_message(classmate,str("Test message"))

Error message

  File "C:\Users\nexus\AppData\Local\Programs\Python\Python311\Lib\site-packages\edupage_api\__init__.py", line 102, in send_message
    return Messages(self).send_message(recipients, body)
  File "C:\Users\nexus\AppData\Local\Programs\Python\Python311\Lib\site-packages\edupage_api\messages.py", line 47, in send_message
    raise RequestError("Failed to send message (edupage returned an empty 'changes' array)")
edupage_api.exceptions.RequestError: Failed to send message (edupage returned an empty 'changes' array)

Expected behaviour Umm, no error? :D

Version

Nexusatko commented 1 year ago

Eh, zabudol som, že to je slovenský projekt. To je asi jedno, jak to napíšem. :D

ivanhrabcak commented 1 year ago

We keep the issues in english, as there are also users that do not speak Slovak.

Does the message get sent?

Nexusatko commented 1 year ago

No, it's not showing in the history of conversation with that person.

ivanhrabcak commented 1 year ago

I think the issue is in EduAccount.get_id.

I want you to compare the numbers from your and your classmate's userId: Example: You: Student971239, your classmate Student971139

Is the positivity of both numbers the same? (Here, both numbers are positive, if one would be negative, that would be bad.) Is your number above zero? Is your classmate's number above zero?

Thank you for your cooperation.

Nexusatko commented 1 year ago

All IDs are correct and non-negative. I copied them from Edupage.get_students method. Even if I use print(classmate) it prints the correct classmate and info about him/her.

ivanhrabcak commented 1 year ago

Does it also match Edupage.get_user_id?

Nexusatko commented 1 year ago

It's Edupage.get_user_id() but yes, the ID matches. Even though it outputs as StudentID_HERE and not as ID_HERE when I use Edupage.get_user_id() but I assume that's correct.

ivanhrabcak commented 1 year ago

Could we get on discord to resolve the issue?

https://discord.gg/fg6zBu9ZAn

ivanhrabcak commented 1 year ago

The issue is in the difference in Student and StudentOnly. @Nexusatko cannot send messages to the Student user (which includes the student's parents), only to the StudentOnly one.

I will add a new account type - StudentOnly.

ivanhrabcak commented 1 year ago

Resolved in 0.10.3!

You can now send messages to students only (by default, parents also get the message), which was the issue here.

Here's some example code:

message_recipient = # ...
message_recipient.set_student_only(True) # !!!

edupage.send_message(message_recipient, "Hello World!")