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

Replying to myself #80

Open
jamesoncollins opened this issue Dec 27, 2024 · 4 comments
Open

Replying to myself #80

jamesoncollins opened this issue Dec 27, 2024 · 4 comments

Comments

@jamesoncollins
Copy link

When my bot replies to a message in a group chat everything works fine. The other members of the group see the bot's messages regardless of whether I asked the bot a question or if someone else did.

But, in a 1 on 1 conversation, the other member of the conversation can only see the bot's messages if the bot is replying to them as opposed to me. Otherwise it goes to "Notes to Self".

Is this expected?

@Era-Dorta
Copy link
Collaborator

Can you please give a code example? I'm not sure I understand the problem.

@jamesoncollins
Copy link
Author

Sorry, I realize I left out a VERY important detail.

I am currently using the same phone number for myself, and for the bot.

So in a one-on-one chat if I manually query the bot then the message is received in python as BOT_NUMBER being both the source and destination of the message. That means that a c.reply will get sent to BOT_NUMBER. Which in my case appears in "notes to self" as opposed to the one on one convo. I've done some experiments to work around this. I think that the code below works, but it has limited testing:

async def my_reply(
    c,
    text: str,
    base64_attachments: list = [],
    mentions: list = None,
    text_mode: str = None,
):

    source = c.message.source
            
    #fixme: dont use OS var here, get it from the bot
    if c.message.group or source != os.environ["BOT_NUMBER"]:
        # this was a group message
        # do a normal reply
        return await c.reply(str, base64_attachments)    
    else:
        # this was a 1on1 message that we sent ourselves  
        
        # some 1v1 messages are dataMesages, not syncMessages, and they dont have dest info
        try:
            desintation = c.message.raw_message["envelope"]["syncMessage"]["sentMessage"]["destination"]
        except Exception as e:
            print(f"Failed to get desintation info, using NOT_NUMBER: {e}")
            desintation = os.environ["BOT_NUMBER"]
          
        return await c.bot.send(
            desintation,
            text,
            base64_attachments=base64_attachments,
            quote_author=c.message.source,
            quote_mentions=c.message.mentions,
            quote_message=c.message.text,
            quote_timestamp=c.message.timestamp,
            mentions=mentions,
            text_mode=text_mode,
            )

@Era-Dorta
Copy link
Collaborator

I see, then I would say the current behavior is expected. I don't even know how you were able to create a 1:1 conversation with the bot, given that it is your phone number. Do you mean you created a group with only yourself in it?

I'm not sure if we can have a nice generic way to solve this. As far as I know most people use a second number for the bot.

@jamesoncollins
Copy link
Author

I will probably eventually switch to using a second number, but I was having trouble with the registration site the other day.

Using the "notes to self" feature in the signal app I'm able to have a conversation with myself. I'm not sure if that feature is considered a group or not. I don't think that it is.

But the situation I was actually talking about was a conversation between myself and another person. The other person is able to interact with the bot just fine.

I think you are probably right that the behavior is expected and that there isn't a good generic way to deal with this.

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

2 participants