Losing words

Rhodri James rhodri at kynesim.co.uk
Mon Apr 1 13:04:24 EDT 2019


On 01/04/2019 16:14, John Doe wrote:
> On 2019-04-01, Chris Angelico <rosuav at gmail.com> wrote:
>>>
>>> I'm learning SOCKETS and working with Irc.
>>>   -----------------------
>>>   s.send(bytes("PRIVMSG " + channel +" "+ message + "\n", "UTF-8"))
>>>   ----------------------------------------
>>>   When more than one word ( for example: This is a message)
>>>   in *message* it sends the FIRST word only "This" and skips the rest.
>>>   Any ideas how to solve the problem? I was seating on it on the night
>>>   but nothing came up.
>>
>> Does your message begin with a colon?
>>
>> You may need a lot more context here. I have no idea what you're
>> running into because one line of code is vastly insufficient.
>>
> 
> Nah mate,
> 
> def text():
>      mess = input("> ")
>      s.send(bytes("PRIVMSG " + " "+ channel + " " +  mess  + "\n", "UTF-8"))
> 
>      text()
> 
>     ---------------------
>    
>     > This is a message
> 
>     and it sends just first word in this example: "This".

I'm not an expert, but looking at RFC-1459 it looks like your final 
parameter (the message) needs to be preceded by a colon.  In other words 
you want:

s.send(bytes("PRIVMSG " + channel + " :" + mess + "\n", "UTF-8"))

(Try printing out the line you want to send before sending it, and 
compare it with the example commands in the RFC.)

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list