Add hooks for muting and spamming mails
This commit is contained in:
		
							parent
							
								
									423d9b4952
								
							
						
					
					
						commit
						b9bbc9d1ae
					
				
					 3 changed files with 57 additions and 0 deletions
				
			
		|  | @ -87,6 +87,16 @@ theme = "mutt" | ||||||
|         x = toggletags spam,inbox |         x = toggletags spam,inbox | ||||||
|         a = untag inbox |         a = untag inbox | ||||||
|         A = tag inbox |         A = tag inbox | ||||||
|  |         1 = call hooks.mute(ui,1) | ||||||
|  |         2 = call hooks.mute(ui,2) | ||||||
|  |         3 = call hooks.mute(ui,3) | ||||||
|  |         4 = call hooks.mute(ui,4) | ||||||
|  |         5 = call hooks.mute(ui,5) | ||||||
|  |         6 = call hooks.mute(ui,6) | ||||||
|  |         7 = call hooks.mute(ui,7) | ||||||
|  |         8 = call hooks.mute(ui,8) | ||||||
|  |         9 = call hooks.mute(ui,9) | ||||||
|  |         i = call hooks.spam(ui) | ||||||
| 
 | 
 | ||||||
|     [[thread]] |     [[thread]] | ||||||
|         a = untag inbox ; fold |         a = untag inbox ; fold | ||||||
|  | @ -94,6 +104,16 @@ theme = "mutt" | ||||||
|         n = nextpart |         n = nextpart | ||||||
|         p = prevpart |         p = prevpart | ||||||
|         u = pipeto --background selecturl |         u = pipeto --background selecturl | ||||||
|  |         1 = call hooks.mute(ui,1) | ||||||
|  |         2 = call hooks.mute(ui,2) | ||||||
|  |         3 = call hooks.mute(ui,3) | ||||||
|  |         4 = call hooks.mute(ui,4) | ||||||
|  |         5 = call hooks.mute(ui,5) | ||||||
|  |         6 = call hooks.mute(ui,6) | ||||||
|  |         7 = call hooks.mute(ui,7) | ||||||
|  |         8 = call hooks.mute(ui,8) | ||||||
|  |         9 = call hooks.mute(ui,9) | ||||||
|  |         i = call hooks.spam(ui) | ||||||
| 
 | 
 | ||||||
| [tags] | [tags] | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,23 @@ | ||||||
|  | #!/usr/bin/env python3 | ||||||
|  | 
 | ||||||
|  | async def mute(ui, days): | ||||||
|  | 	from datetime import date, timedelta | ||||||
|  | 	datestr = str(date.today() + timedelta(days=days)) | ||||||
|  | 	await ui.apply_commandline(f'toggletags inbox,muted,muted/{datestr}') | ||||||
|  | 
 | ||||||
|  | async def spam(ui): | ||||||
|  | 	from alot.buffers import EnvelopeBuffer | ||||||
|  | 	from alot.db.envelope import Envelope | ||||||
|  | 	message = ui.current_buffer.get_selected_message() | ||||||
|  | 	message.add_tags(['spam']) | ||||||
|  | 	message.remove_tags(['unread']) | ||||||
|  | 	envelope = Envelope( | ||||||
|  | 		headers=dict( | ||||||
|  | 			From=['Felix Van der Jeugt <felix.vanderjeugt@ugent.be>'], | ||||||
|  | 			To=['spam@ugent.be'], | ||||||
|  | 			Subject=['spam'], | ||||||
|  | 			References=['<' + message.get_message_id() + '>']), | ||||||
|  | 		bodytext='spam', | ||||||
|  | 		tags=['spam']) | ||||||
|  | 	envelope.attach(message.get_filename()) | ||||||
|  | 	ui.buffer_open(EnvelopeBuffer(ui, envelope)) | ||||||
|  | @ -50,6 +50,11 @@ for mid in $(notmuch search --output=messages tag:new); do | ||||||
| 	done | 	done | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
|  | # Unmute threads with new messages | ||||||
|  | for mutetag in $(notmuch search --output=tags -- tag:muted and thread:{tag:new} | grep 'muted/'); do | ||||||
|  | 	notmuch tag -muted -"$mutetag" +inbox -- tag:"$mutetag" and thread:{tag:new} | ||||||
|  | done | ||||||
|  | 
 | ||||||
| # Github notifications | # Github notifications | ||||||
| addtag github "from:notifications@github.com" | addtag github "from:notifications@github.com" | ||||||
| 
 | 
 | ||||||
|  | @ -66,3 +71,12 @@ notmuch search tag:new | cut -d' ' --complement -f1 | xargs -0 --no-run-if-empty | ||||||
| # Inbox remaining not-spam | # Inbox remaining not-spam | ||||||
| addtag inbox "not tag:spam" | addtag inbox "not tag:spam" | ||||||
| notmuch tag -new -- tag:new | notmuch tag -new -- tag:new | ||||||
|  | 
 | ||||||
|  | # Unmute threads on their day of unmuting | ||||||
|  | today="$(date +'%s')" | ||||||
|  | for mutetag in $(notmuch search --output=tags tag:muted | grep 'muted/'); do | ||||||
|  | 	until="$(date -d "${mutetag#*/}" +'%s')" | ||||||
|  | 	if [ "$today" -gt "$until"  ]; then | ||||||
|  | 		notmuch tag -muted -"$mutetag" +inbox -- tag:"$mutetag" | ||||||
|  | 	fi | ||||||
|  | done | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Felix Van der Jeugt
						Felix Van der Jeugt