- Python 100%
| assets/internal | ||
| examples | ||
| .gitignore | ||
| botclient.py | ||
| LICENSE | ||
| r2chat.py | ||
| README.md | ||
| requirements.txt | ||
r2chat
Simple and lightweight IM application for multi-user systems (e.g. Windows Server). Created by Dogo6647 with Python and Tkinter.
Usage
Place r2chat folder on C:\ on windows or inside any other location accessible by all users. Make sure you're running the script from within the folder it's in.
python r2chat.py
- Chat history is saved as
chat_CHANNEL.txtinside either "C:\Users\Public\r2chat" on Windows or "/var/tmp/r2chat/" on Unix-like. - Preferences are stored as a json in your home directory and can be changed directly from the GUI by clicking "Preferences" on the menu bar.
- You can insert color text into the chat by using the following syntax:
((#XXXXXX | yourtext)) - The "insert" menu is not functional yet.
Bot client usage
You can look at examples/botexample.py for an example working setup you can use as a template.
Unlike regular r2chat, the bot client doesn't require any dependencies and its config file
is stored as r2bot.config.json where you're running the script from, so it's important
to separate bots between directories to prevent them from overwriting each other's files.
Bot client API
Init:
bot = r2bot(channel, username)
Sending a message:
bot.send(msg)
Sending a system message:
bot.system_message(msg)
Receiving messages
messages = bot.poll()
Returns a list of new lines and triggers event callbacks, which can be used like this:
def handlemsg(msg):
print("got message:", msg)
# Register event
bot.on("on_message", handlemsg)
List of possible on-event types:
- "on_message"
- "on_mention"
- "on_system"
Statuses
bot.set_status(status)
List of standard statuses:
- "online"
- "offline"
- "inactive"
- "busy"
Leave signal
bot.leave_channel()
Parse text blocks
The bot client can split normal text and colored text into an array;
segments = bot.parse_colors(text)
Would output something like:
[
("text", "normal text"),
("color", "#ff0000", "This is red text")
]