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

Groups showing up as users, not channels, when first connecting to telegramircd #6

Closed
rodneyrod opened this issue Feb 8, 2017 · 35 comments

Comments

@rodneyrod
Copy link
Contributor

After updating to the latest build, I'm getting an issue where every time I reset the daemon and connect to it for the first time again, it adds a list of my groups, but it adds them as users instead of channels, and when it starts fetching messages from those groups, it just creates new channels leaving the ones created at the initialisation and it fills up my room list with duplicates.

@rodneyrod
Copy link
Contributor Author

rodneyrod commented Feb 9, 2017

The only message that shows up in those 'users with groups names' is along the lines of:

Topic for &[CHAT NAME] is "channel#5555555 [CHAT NAME]"

Or

Topic for &[CHAT NAME] is "chat#5555555 [CHAT NAME]"

@MaskRay
Copy link
Owner

MaskRay commented Feb 9, 2017

Strange. Can you run telegramircd with --password a and type eval a client.peer_id2special_room to diagnose? It is a dict from peer_id to SpecialChannel (representation of a Telegram chat/group)

I have just added __repr__ methods to some classes to make the output brief.

@rodneyrod
Copy link
Contributor Author

Here's that dump, hope it helps.
https://gist.github.com/rodneyrod/232dd547e0e533c6ab84472fefb62a34

@MaskRay
Copy link
Owner

MaskRay commented Feb 10, 2017 via email

@rodneyrod
Copy link
Contributor Author

Just checked out the info, if you were wondering if the issue occurs in chats and channels, it is.

@MaskRay
Copy link
Owner

MaskRay commented Feb 10, 2017

Sorry for you inconvenience... But I have 'git push -f' a lot...

@rodneyrod
Copy link
Contributor Author

Just rm'd and cloned the repo again (git pull throwing ident errors) but still have the same issue.

@MaskRay
Copy link
Owner

MaskRay commented Feb 10, 2017

If I were you, I would log the output of telegram-cli --json and insert a line print(data) before line 71 if isinstance(data, dict) and data.get('result') == 'FAIL': and line 135 buf = decoded[j:].encode() to see the discrepancy... It is very difficult to diagnose without this information.

@MaskRay
Copy link
Owner

MaskRay commented Feb 10, 2017

chat/channel/contacts are initialized in the call site of channel_list contact_list dialog_list (around line 1444). You can type these commands to telegram-cli --json to see whether they are different from the "to" field in incoming messages.

{"event": "message", "id": "050000007aa8613f5395000000000000653848c956b2b8f8", "flags": 256, "reply_id": "050000007aa8613f4e95000000000000653848c956b2b8f8", "from": {"id": "$010000009f187b0ca76f4af5a7c4db7f", "peer_type": "user", "peer_id": ......, "print_name": "....", "flags": 1, "first_name": "...", "when": "2017-02-09 20:47:06", "last_name": "", "username": "....."}, "to": {"id": "$050000007aa8613f653848c956b2b8f8", "peer_type": "channel", "peer_id": 1063364730, "print_name": "🌊TUNA_Bot_污水群", "flags": 524289, "title": "🌊TUNA Bot 污水群", "participants_count": 0, "admins_count": 0, "kicked_count": 0}, "out": false, "unread": false, "service": false, "date": 1486701137, "text": "可怜的喵呜"}

telegramircd chooses peer_id as the primary key to differentiate chats/channels.

@MaskRay
Copy link
Owner

MaskRay commented Feb 10, 2017

As I mentioned in https://github.com/MaskRay/telegramircd#known-issues, channels are not well supported by telegram-cli. There is a mysterious issue that messages do not arrive for some supergroups ( vysheng/tg#1135 ). I work around that by executing the history command periodically to pull messages from the server.

It is unfortunate that all telegram libraries known to me are overly complex so I have to depend on telegram-cli which in my opinion is easy to hack... I once tried webogram but the logic is mingled with UI interactions and I find it difficult to understand the code..., so I abandoned it recently...

@rodneyrod
Copy link
Contributor Author

I've checked the behaviour after the latest update, the issue persists, but I think I might know the issue.
I've noticed that these 'ghost users' with the same names as rooms will only appear once someone starts posting to the actual telegram room, so it happens the same time as the room channel becomes active.

I think that the room ident is somehow being pushed as a direct message over IRC then showing in the actual room as it should be.

@MaskRay
Copy link
Owner

MaskRay commented Feb 17, 2017

Do you mean an IRC message like :&archlinux-cn MODE &archlinux-cn +o cuihao which is displayed as Mode &archlinux-cn [+o cuihao] by &archlinux-cn?

@rodneyrod
Copy link
Contributor Author

Yes, similar to that. It's a bit more like:

Topic for &archlinux-cn is "channel#5555555 &archlinux-cn~!"

@MaskRay
Copy link
Owner

MaskRay commented Feb 17, 2017

Topic for &archlinux-cn is "channel#5555555 &archlinux-cn~!"

Where does this message mention the actor?

@rodneyrod
Copy link
Contributor Author

rodneyrod commented Feb 17, 2017

It doesn't, it shows up in my IRC client (Quassel) as a direct message from a user, and the name of the user is just the name of the room without the '&' at the start.

@MaskRay
Copy link
Owner

MaskRay commented Feb 17, 2017

Can you connect to telegramircd with WeeChat (my favorite IRC client) and press A-j A-r (https://weechat.org/files/doc/stable/weechat_user.en.html
/server raw) and dump the relevant raw IRC message?

@rodneyrod
Copy link
Contributor Author

The issue doesn't appear to be occurring in Weechat, every group shows up normally. I use Quassel normally so that could be why I've noticed the issue.

@rodneyrod
Copy link
Contributor Author

The only line that I can see that would look closest to the one that I get in Quassel is this:

05:57:11 --> telegram | :telegramircd.maskray.me 332 [SYSTEM USER NAME]&[CHANNEL_NAME]:chat#55555555 [CHANNEL_NAME]

@MaskRay
Copy link
Owner

MaskRay commented Feb 17, 2017

:telegramircd.maskray.me 332 [SYSTEM USER NAME]&[CHANNEL_NAME]:chat#55555555 [CHANNEL_NAME]

According to https://tools.ietf.org/html/rfc2812#section-3.2.4 , this raw message can be explained as &channel itself sets its topic to blahblah.

For WeeChat, a channel name &channel can be the event source. Quassel may have a different idea on what can be an event source.

@rodneyrod
Copy link
Contributor Author

This is odd, since it was working fine in Quassel before the big refactor you did when I first submitted this issue.

@MaskRay
Copy link
Owner

MaskRay commented Feb 17, 2017

I fixed another issue. JOIN messages (https://tools.ietf.org/html/rfc2812#section-3.2.1) can take one or two arguments. But I was too lazy to handle the 2-argument case. Quassel seems to send a JOIN &a \r\n (notice the space before \r) to the IRC server.

@MaskRay
Copy link
Owner

MaskRay commented Feb 17, 2017

Will you see chats/channels shown as users if you do not use the LIST command?

I cannot reproduce the issue if I comment out either client.reply('322 {} {} {} :{}', client.nick, channel.name, or client.reply('332 {} {} :{}', client.nick, self.name, self.topic) .
I think this may be a bug of Quassel.

@rodneyrod
Copy link
Contributor Author

Issue looks to be resolved now, whatever you did it worked.

@rodneyrod
Copy link
Contributor Author

I just cloned the repo again and the issue appears to have come back. Have you reverted your changes?

@rodneyrod rodneyrod reopened this Feb 19, 2017
@MaskRay
Copy link
Owner

MaskRay commented Feb 19, 2017

No, I have not reverted my changes. I think the issue may be caused by the way Quassel handles 322 332 response codes. Can you comment out one of the two statements I mentioned before?

I cannot reproduce the issue if I comment out either client.reply('322 {} {} {} :{}', client.nick, channel.name, or client.reply('332 {} {} :{}', client.nick, self.name, self.topic) .
I think this may be a bug of Quassel.

@rodneyrod
Copy link
Contributor Author

rodneyrod commented Feb 20, 2017

I tried to apply those comments, if I just commented out the lines you mentioned and only those lines it does not run, it says there are syntax errors and doesn't run. If I comment out the surrounding arguments it runs but throws up errors and it still has the same issue.

How did you comment out those lines? It doesn't seem to like removing one of the arguments in an if statement by the looks of things.

@rodneyrod
Copy link
Contributor Author

Checked again, I've noticed that Quassel automatically sends a /JOIN request for all channels on startup, that wouldn't have an effect on the logs would it?

@MaskRay
Copy link
Owner

MaskRay commented Feb 26, 2017

JOIN commands have no effect on the log. You can search for call sites of the irc_log function, currently only messages are recorded.

@rodneyrod
Copy link
Contributor Author

All good then, so what are the exact lines that I need to comment out to prevent this issue from occurring, without Python syntax errors?

@MaskRay
Copy link
Owner

MaskRay commented Feb 26, 2017

These lines

        #for channel in channels:
        #  client.reply('322 {} {} {} :{}', client.nick, channel.name,
        #                channel.n_members(client), channel.topic)
        client.reply('323 {} :End of LIST', client.nick)

or

        if self.topic != topic:
            self.topic = topic
        #    for client in server.auth_clients():
        #       client.reply('332 {} {} :{}', client.nick, self.name, self.topic)

@rodneyrod
Copy link
Contributor Author

First option fixed it, thank you so much for your patience.

@MaskRay
Copy link
Owner

MaskRay commented Mar 10, 2017

Quassel does not seem to support channel names with prefixes &. I have added an option --special-channel-prefix '##' as a workaround.

@rodneyrod
Copy link
Contributor Author

All good, I'll ping the Quassel team about this, hopefully get this all fixed up on that end.
In the meantime, I updated and ran with the new command, but my groups and channels don't load. When Quassel tries to auto join, it errors 'No such channel', and even when people post in the groups and channels I'm part of nothing comes through on IRC.

@rodneyrod
Copy link
Contributor Author

@MaskRay I pinged the Quassel devs over at #quassel at Freenode and they're looking into this issue, but they're having problems with getting the setup working. I've already tried to help them out, but if you could have a quick word over there I think that would be best.

@MaskRay
Copy link
Owner

MaskRay commented Mar 31, 2017

@rodneyrod I added 005 RPL_ISUPPORT in HEAD

            self.reply('005 {} PREFIX=(ohv)@%+ CHANTYPES=!#& CHANMODES=,,,m SAFELIST :are supported by this server', self.nick)
<genius3000> Cool, if that doesn't fix the Quassel client issue for your users, best would be for them to open an issue on the Quassel bug tracker, as detailed as possible.

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