# This script is inspired by "im_typing_notice" for irssi.# It creates a new bar item displaying when contacts are typing on supported protocol in minbif# It sends a notice to your contacts when you're typing a message.## Author: CissWit cisswit at 6-8 dot fr# Version 1.0.1## Changelog :## * 1.0.1# Ignore the user "request" (no need to tell it we are typing)## * 1.0# Original version## Licence GPL3$h_typing=Hash.new$h_sending=Hash.newdefweechat_initWeechat.register("minbif_typing_notice","CissWit","1.0.1","GPL3","For minbif - displays when someone is typing a message to you, and notice them when you do.","","")Weechat.bar_item_new("typing_notice","draw_typing","")Weechat.hook_modifier("irc_in_privmsg","modifier_ctcp","")Weechat.hook_signal("input_text_changed","input_changed","")ifWeechat.config_is_set_plugin("minbif_server")==0Weechat.config_set_plugin("minbif_server","minbif")endWeechat.print("","typing_notice: minbif typing notice")Weechat.print("","typing_notice: Put [typing_notice] in your status bar (or the one you prefer) to show when contacts are typing message to you.")returnWeechat::WEECHAT_RC_OKenddefinput_changed(data,signal,type_data)buffer=Weechat.current_bufferbuffer_name=Weechat.buffer_get_stringbuffer,"name"ifbuffer_name=~/^#{Weechat.config_get_plugin("minbif_server")}\.(.*)/nick=$1ifnick=="request"returnWeechat::WEECHAT_RC_OKendbuffer_text=Weechat.buffer_get_string(buffer,"input")if(buffer_text==""orbuffer_text=~/^\//)if$h_sending.key?(buffer)Weechat.command(buffer,"/mute all ctcp #{nick} TYPING 0")Weechat.unhook($h_sending[buffer]["timer"])$h_sending.delete(buffer)endreturnWeechat::WEECHAT_RC_OKendreturnWeechat::WEECHAT_RC_OKunless!$h_sending.key?(buffer)Weechat.command(buffer,"/mute -all ctcp #{nick} TYPING 1")if$h_sending.key?(buffer)Weechat.unhook($h_sending[buffer]["timer"])else$h_sending[buffer]=Hash.newend$h_sending[buffer]["timer"]=Weechat.hook_timer(7000,0,1,"sending_timeout",buffer)$h_sending[buffer]["time"]=Time.newendreturnWeechat::WEECHAT_RC_OKenddefsending_timeout(buffer,n)if$h_sending.key?(buffer)buffer_name=Weechat.buffer_get_stringbuffer,"name"ifbuffer_name=~/^#{Weechat.config_get_plugin("minbif_server")}\.(.*)/Weechat.command(buffer,"/mute -all ctcp #{$1} TYPING 0")Weechat.unhook($h_sending[buffer]["timer"])$h_sending.delete(buffer)endendreturnWeechat::WEECHAT_RC_OKenddefdraw_typing(osefa,osefb,osefc)buffer=Weechat.current_bufferif$h_typing.key?(buffer)return"TYPING"endreturn""enddeftyping_timeout(buffer,n)if$h_typing.key?(buffer)Weechat.unhook($h_typing[buffer])$h_typing.delete(buffer)endWeechat.bar_item_update("typing_notice")enddefmodifier_ctcp(data,modifier,modifier_data,string)ifstring=~/:([^!]*)!([^\s]*)\sPRIVMSG\s([^\s]*)\s:\01TYPING\s([0-9])\01/buffer=Weechat.buffer_search("irc",modifier_data+"."+$1)if$h_typing.key?(buffer)Weechat.unhook($h_typing[buffer])endif$4=="1"$h_typing[buffer]=Weechat.hook_timer(7000,0,1,"typing_timeout",buffer)elsif$4=="0"if$h_typing.key?(buffer)$h_typing.delete(buffer)endelsif$4=="2"Weechat.print("","- #{$4} - #{$1} - #{buffer} - is typing")endWeechat.bar_item_update("typing_notice")return""endreturnstringend