weechat

- me personal weechat setup 🔵🟢
git clone git://git.acid.vegas/weechat.git
Log | Files | Refs | Archive | README

greentext.py (1019B)

      1 # -*- coding: utf-8 -*-
      2 # greentext script for weechat - developed by acidvegas in python (https://git.acid.vegas/weechat)
      3 
      4 '''
      5 Todo: this can be turned into a trigger
      6 '''
      7 
      8 import re,weechat
      9 
     10 def between(source, start, stop):
     11 	data = re.compile(start + '(.*?)' + stop, re.IGNORECASE|re.MULTILINE).search(source)
     12 	if data:
     13 		return data.group(1)
     14 	else:
     15 		return False
     16 
     17 def cb_greentext(data,buffer,command):
     18 	if command=='/input return':
     19 		data=weechat.buffer_get_string(buffer,'input')
     20 		if data:
     21 			if data[0]=='>':
     22 				data='\x0303'+data
     23 			elif '!!' in data or '__' in data or '**' in data:
     24 				for word in data.split():
     25 					if word[:2] == '!!':
     26 						data = data.replace(word, '\x1F\x02\x0304 ' + word[2:].upper() + ' \x0f', 1)
     27 					elif word[:2] == '__':
     28 						data = data.replace(word, '\x1F\x02' + word[2:].upper() + '\x0f', 1)
     29 		weechat.buffer_set(buffer,'input',data)
     30 	return weechat.WEECHAT_RC_OK
     31 
     32 if weechat.register('greentext','','','','','',''):weechat.hook_command_run('/input return','cb_greentext','')