last day (353 days later) » 

4:20 PM
So first, you need to run pip3 install chatexchange to install the Python ChatExchange library. You need to find your Python installation folder.
 
OK...
 
@Ann If you run into any problems or issues, please upload a screenshot of the problem.
 
done.
 
OK.
Now let's talk about the code. First, you need from chatexchange.client import Client at the top of your Python file. This will allow your Python code to use the ChatExchange API.
 
done
 
4:24 PM
P.S. Sorry I can't use the code thing 'cause multi-line code isn't allowed in chat ;D
 
Okay, Let me first create one
 
@TechExpertWizard select all lines and ctrl+k
And send
 
@The Interesting, thanks!
Next, we log into the bot account:
 
👍👍
 
@The Thanks for the help! I didn't know multi-line code was allowed in chat :)
email = "email@email.com"
password = "**************"
se_chat = Client("stackexchange.com")
se_chat.login(email, password)
 
4:26 PM
@TechExpertWizard No problem. :)
 
Then we need to get and join a room. This way:
```
room = se_chat.get_room('number')
room.join()
```
 
room = se_chat.get_room('number')
room.join()
 
yeah
To send a message use: `room.send_message('hi guys!')`
`
 
Use Ctrl+K. @The told me how to do that.
 
ah thx
to leave the room use: room.leave()
 
4:31 PM
@Vic I have to log out after 2 minutes since I've got something really important to do.
 
ok, ok
np
 
@Vic Didn't you say you didn't have time?
 
I have some ;)
I wasn't able at that moment but not now
 
@Vic I have 1 minute ;D
 
4:32 PM
@Vic I had time at that moment but not now ;D Ain't that really funny? That's a pun ;D
 
So we have this code:
from chatexchange.client import Client
email = "email@email.com"
password = "**************"
se_chat = Client("stackexchange.com")
se_chat.login(email, password)

room = se_chat.get_room('number')
room.join()
room.send_message('hi guys!')
room.leave()
 
Please give me a minute, I have a chore...
 
@TechExpertWizard I meant the opposite ;D
@AnnZen Again here?
 
Yeah, having trouble creating the account...
 
Then you'll ask how to read new messages?
You need to create an infinite loop in the end of program so program won't quit.
while True:
    pass
right before the loop add this line:
room.watch_socket(on_event)
where on_event is function like this:
def on_event(event, _):
    msg = event.message.content_source
    print(msg)
Congrats!
You will get all new messages logged in the terminal/console
So the full code looks like this:
from chatexchange.client import Client
email = "email@email.com"
password = "**************"
se_chat = Client("stackexchange.com")
se_chat.login(email, password)
def on_event(event, _):
    msg = event.message.content_source
    print(msg)
room = se_chat.get_room('number')
room.join()
room.send_message('hi guys!')
while True:
    pass
@Ann, @The here you are ;)
 
4:47 PM
Are room numbers unique across SE sites?
 
@TheLittleNaruto Nope
they are unique on one of three servers
SE
MSE
SO
Everything except MSE and SO is SE chats
@The
say on MSE this room is 1542
se_chat = Client("stackexchange.com")
for SE
se_chat = Client("meta.stackexchange.com")
for MSE
se_chat = Client("stackoverflow.com")
for SO
 
Okay, thanks!
 
There are many other things chatexchange can
So if you have any questions feel free to ping me
 
Yeah, but I realized that I need my bot to earn 15 rep first :)
 
20
;)
it is relatively easy
on SO and SE - good edits are easy
on MSE - show off your hat ;)
 
4:53 PM
There's my "bot" XD
 
DO NOT UPVOTE/ACCEPT YOUR OWN POSTS
it is voting fraud
 
Yeah, thanks.
Thank you all so so much! I need to go for now :)
 
ok
Bye ;)
 
@VictorVosMottor Got it.
Thanks
Who is author of ChatStackEchange python module?
 
5:11 PM
@TheLittleNaruto dunno
 
@VictorVosMottor Ok
Where are you from if I may ask?
 
5:27 PM
@TheLittleNaruto Russia
 
@VictorVosMottor Nice to meet you :)
 
same ;)
 
 
2 hours later…
7:22 PM
@Vic Do you think we can use this as our new MSE Den?
@AnnZen What's your new bot's username?
@Vic Could you please bring your bot in here? Thanks! P.S. If you're curious about my own chatbot, I'm still working on it 'cause I'm very busy today ;D
 
7:46 PM
@TechExpertWizard Ann BOT. It still needs more rep to chat, though.
 
8:38 PM
@Ann Well, I can help you upvote your bot's Winter Bash hat answer. P.S. I can't find that post, though. Could you give me the link?
@Ann Also, once your bot's working, if you bring your bot in here, I'll make you an owner of this room :)
 
@TechExpertWizard Thanks, but I don't think it would be allowed. Besides, my main account already answered it.
@TechExpertWizard I will :D
 
@Ann No, I said I'm going to upvote it. Just give me the link please ;D
 
9:02 PM
@TechExpertWizard I didn't post one, as I've got advice not to here: chat.meta.stackexchange.com/transcript/message/8674810#8674810
 
9:45 PM
@Ann Oh wait, seems like you've already posted a Winter Bash hat answer previously using your main account. That's too bad, I guess you're going to have to suggest edits and other things ;D
@Ann Could you please give me the profile link for your bot? I'm really curious ;D Thanks!
3 mins ago, by Tech Expert Wizard
@Ann Could you please give me the profile link for your bot? I'm really curious ;D Thanks!
Oh, just found it :)
15 2
Looks like you're using edits to do that. That sure is hard work ;D
 
10:08 PM
@Ann Just created my own bot account, 'cause although I'd mastered how to create a bot earlier, I didn't have enough time to create the new account; I was always busy ;D. I'll just wait until the first hat is awarded and then I'll post an answer on the Winter Bash hat thing :)
@Vic Come in here!
 

  last day (353 days later) »