Small print tool for implementing chat in the terminal.
https://pypi.org/project/print_chat/
Usage example
import print_chat as pc
pct = pc.print_chat()
sender = 'Charls'
pct.set_colors([('Charls', 'green')])
while True:
post = str(input('> '))
if post == 'exit':
break
else:
pct.up_on_occupied_rows(len(post) + len(sender) + 2)
pct.add_message('Charls', post)
pct.close()
For testing the main functionality:
import print_chat as pc
pct = pc.print_chat(time=True)
s = 0 # sender iterator
senders = ['Charls', 'Max', 'Karl']
pct.set_colors([
(senders[0], 'green'),
(senders[1], 'red'),
(senders[2], 'yellow')
])
pct.set_header('-Test chat-\n-----------') # adding a header to the dialog
while True:
post = str(input('> '))
pct.up_on_occupied_rows(len(post) + len(senders[s]) + 2)
command = post.split(' ')
if post == 'exit': break
elif command[0] == 'remove': pct.remove(int(command[1]))
elif command[0] == 'edit': pct.edit(int(command[1]), ' '.join(command[2:]))
elif command[0] == 'reload': pct.reload(int(command[1]))
elif command[0] == 'add_skip': pct.add_skip(int(command[1]), str(' '.join(command[2:])))
elif command[0] == 'edit_skip': pct.edit_skip(int(command[1]), ' '.join(command[2:]))
elif command[0] == 'remove_skip': pct.remove_skip(int(command[1]))
elif command[0] == 'add_mark': pct.add_mark(int(command[1]), str(command[2]))
elif command[0] == 'edit_mark': pct.edit_mark(int(command[1]), str(command[2]))
elif command[0] == 'remove_mark': pct.remove_mark(int(command[1]))
elif post == 'cs': s = (s+1) % len(senders) # change sender to next
else: pct.add_message(senders[s], post)
pct.close()
Important
Numbering starts at 1, at the end of the message list
This is not a bug this is a feature
Create object
default:
pct = print_chat.print_chat(time=False)
time - show message sending time
Method list
.add_message(sender, text, time=’’, skip=[], mark=[])
.add_message_top(sender, text, time=’’, skip=[], mark=[], prnt=True)
.reload(number)
.remove(number)
.edit(number, text)
.add_skip(number, text)
.edit_skip(number, text)
.remove_skip(number)
.add_mark(number, text)
.edit_mark(number, text)
.remove_mark(number)
.close(clr) - closes the dialog, with or without screen clearing
.set_header(string)
- .set_colors(colors) - takes a list [[sender, color],..]
- colors list:
grey
red
green
yellow
blue
magenta
cyan
white
.get_num_messages() - returns the number of messages
.get_messages()
.get_messages_from(sender)
.up_on_occupied_rows(len_str)
.up_on_message(number)
.up_on_rows(number)
.clear_row()
._clear_screen()
.get_senders() - returns a list of dictionaries
Installation
$ pip install print_chat
or
Repository cloning
$ git clone https://github.com/IVIGOR13/print_chat.git
Tuning
$ pip install termcolor
$ pip install colorama
Metadata
Release files for print-chat 0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| print_chat-0.4.tar.gz | 6.8 kB | Without provenance | Details for print_chat-0.4.tar.gz |
Release files / print_chat-0.4.tar.gz
| Download URL | print_chat-0.4.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15122a02a0de60727d23bc380adf5fbd0ff27d9ddf8bc6333d11b0b5b4eed139
|
|
BLAKE2b-256 checksum How to use checksums |
570a74c119b687f1f8bb5b2314767e4ef4b0ab006584c2159797ea1b5b49c3e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1
|
Security for print-chat 0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.