- 
                Notifications
    
You must be signed in to change notification settings  - Fork 38
 
Improved handling of mode changes in buffextras.lua #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            someperson
  wants to merge
  8
  commits into
  TingPing:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
someperson:master
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 7 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      d005b8d
              
                Improved handling of mode changes in buffextras.lua
              
              
                someperson efe1b1e
              
                Restored "Raw Modes" format when appropriate in buffextras.lua
              
              
                someperson ec3d9f7
              
                Implemented splitting modes and support for specific modes in buffext…
              
              
                someperson 341652a
              
                Cleanup, minor fix, and added commented-out use of hexchat.props['cha…
              
              
                someperson 5fb1897
              
                Updated script to use chanmodes property and to account for changes i…
              
              
                someperson dddadb9
              
                Merge branch 'master' into master
              
              
                someperson 5d8a60f
              
                Re-added missing license indicator
              
              
                someperson 8f4707c
              
                Made nickmodes and chanmodes variables local and removed erroneous dash
              
              
                someperson File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,10 +1,6 @@ | ||
| -- SPDX-License-Identifier: MIT | ||
| --- SPDX-License-Identifier: MIT | ||
| hexchat.register('Buffextras', '1', "Format messages from ZNC's buffextras module") | ||
| 
     | 
||
| local function strip_brackets (str) | ||
| return str:sub(2, #str - 1) | ||
| end | ||
| 
     | 
||
| hexchat.hook_server_attrs('PRIVMSG', function (word, word_eol, attrs) | ||
| if not word[1]:match('^:%*buffextras!') then | ||
| return | ||
| 
        
          
        
         | 
    @@ -23,20 +19,11 @@ hexchat.hook_server_attrs('PRIVMSG', function (word, word_eol, attrs) | |
| 
     | 
||
| if is_event('joined') then | ||
| emit('Join', nick, channel, host) | ||
| elseif is_event('quit with message') then | ||
| emit('Quit', nick, strip_brackets(word_eol[8]), host) | ||
| elseif is_event('quit:') then | ||
| elseif is_event('quit') then | ||
| emit('Quit', nick, word_eol[6], host) | ||
| elseif is_event('parted with message') then | ||
| local reason = strip_brackets(word_eol[8]) | ||
| if reason ~= '' then | ||
| emit('Part with Reason', nick, host, channel, reason) | ||
| else | ||
| emit('Part', nick, host, channel) | ||
| end | ||
| elseif is_event('parted:') then | ||
| elseif is_event('parted') then | ||
| local reason = word_eol[6] | ||
| if reason ~= '' then | ||
| if reason and reason ~= '' then | ||
| emit('Part with Reason', nick, host, channel, reason) | ||
| else | ||
| emit('Part', nick, host, channel) | ||
| 
        
          
        
         | 
    @@ -46,13 +33,125 @@ hexchat.hook_server_attrs('PRIVMSG', function (word, word_eol, attrs) | |
| elseif is_event('changed the topic to') then | ||
| emit('Topic Change', nick, word_eol[9], channel) | ||
| elseif is_event('kicked') then | ||
| if word[7] == "Reason:" then | ||
| emit('Kick', nick, word[6], channel, strip_brackets(word_eol[8])) | ||
| emit('Kick', nick, word[6], channel, word_eol[9]) | ||
| elseif is_event('set mode') then | ||
| modes = word_eol[7]:match('^(.*%S)') | ||
| name = nick | ||
| if name == nil then | ||
| name = word[4]:match('^:([^!]+)$') | ||
| end | ||
| if hexchat.prefs['irc_raw_modes'] == true then | ||
| emit('Raw Modes', name, string.format('%s %s', channel, modes)) | ||
| else | ||
| emit('Kick', nick, word[6], channel, word_eol[9]) | ||
| nickmodes = hexchat.props['nickmodes'] | ||
                
       | 
||
| chanmodes = hexchat.props['chanmodes'] | ||
| 
     | 
||
| server = hexchat.get_info('server') | ||
| local chanmodes = chanmodes[server] | ||
| if chanmodes == nil then | ||
| chanmodes = 'beI,k,l' | ||
| end | ||
| 
     | 
||
| modes_for_lists, modes_with_param, modes_with_param_when_set, modes_without_param = chanmodes:match('^([^,]*),?([^,]*),?([^,]*),?([^,]*)$') | ||
| 
     | 
||
| local sign | ||
| local param_pos = 8 | ||
| local flags = word[7] | ||
| for i = 1, #flags do | ||
| flag = flags:sub(i,i) | ||
| if flag == '+' then | ||
| sign = '+' | ||
| elseif flag == '-' then | ||
| sign = '-' | ||
| elseif flag == 'k' then | ||
| if sign == '+' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| emit('Channel Set Key', name, param) | ||
| else | ||
| emit('Channel Remove Keyword', name) | ||
| end | ||
| elseif flag == 'l' then | ||
| if sign == '+' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| emit('Channel Set Limit', name, param) | ||
| else | ||
| emit('Channel Remove Limit', name) | ||
| end | ||
| elseif flag == 'o' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| if sign == '+' then | ||
| emit('Channel Operator', name, param) | ||
| else | ||
| emit('Channel DeOp', name, param) | ||
| end | ||
| elseif flag == 'h' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| if sign == '+' then | ||
| emit('Channel Half-Operator', name, param) | ||
| else | ||
| emit('Channel DeHalfOp', name, param) | ||
| end | ||
| elseif flag == 'v' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| if sign == '+' then | ||
| emit('Channel Voice', name, param) | ||
| else | ||
| emit('Channel DeVoice', name, param) | ||
| end | ||
| elseif flag == 'b' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| if sign == '+' then | ||
| emit('Channel Ban', name, param) | ||
| else | ||
| emit('Channel UnBan', name, param) | ||
| end | ||
| elseif flag == 'e' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| if sign == '+' then | ||
| emit('Channel Exempt', name, param) | ||
| else | ||
| emit('Channel Remove Exempt', name, param) | ||
| end | ||
| elseif flag == 'I' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| if sign == '+' then | ||
| emit('Channel INVITE', name, param) | ||
| else | ||
| emit('Channel Remove Invite', name, param) | ||
| end | ||
| elseif flag == 'q' and string.find(modes_for_lists, 'q') then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| if sign == '+' then | ||
| emit('Channel Quiet', name, param) | ||
| else | ||
| emit('Channel UnQuiet', name, param) | ||
| end | ||
| elseif string.find(nickmodes, flag) or string.find(modes_for_lists, flag) or string.find(modes_with_param, flag) then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| emit('Channel Mode Generic', name, sign, flag, string.format('%s %s', channel, param)) | ||
| elseif string.find(modes_with_param_when_set, flag) then | ||
| if sign == '+' then | ||
| param = word[param_pos] | ||
| param_pos = param_pos + 1 | ||
| emit('Channel Mode Generic', name, sign, flag, string.format('%s %s', channel, param)) | ||
| else | ||
| emit('Channel Mode Generic', name, sign, flag, channel) | ||
| end | ||
| else | ||
| emit('Channel Mode Generic', name, sign, flag, channel) | ||
| end | ||
| end | ||
| end | ||
| elseif is_event('set mode') then | ||
| emit('Raw Modes', nick, string.format('%s %s', channel, word_eol[7])) | ||
| else | ||
| return -- Unknown event | ||
| end | ||
| 
          
            
          
           | 
    ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this change? :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Will fix.