poezio/plugins/rstrip.py

16 lines
496 B
Python
Raw Normal View History

2017-06-19 22:04:18 +00:00
"""
Once loaded, every line of your messages will be stripped of their trailing spaces.
"""
from poezio.plugin import BasePlugin
2018-08-15 11:13:17 +00:00
2017-06-19 22:04:18 +00:00
class Plugin(BasePlugin):
def init(self):
self.api.add_event_handler('muc_say', self.rstrip)
self.api.add_event_handler('conversation_say', self.rstrip)
self.api.add_event_handler('private_say', self.rstrip)
def rstrip(self, msg, tab):
2018-08-15 11:13:17 +00:00
msg['body'] = '\n'.join(
line.rstrip() for line in msg['body'].split('\n'))