File: autoquery

package info (click to toggle)
ircii 20190117-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,788 kB
  • sloc: ansic: 44,172; makefile: 863; sh: 524; perl: 291
file content (129 lines) | stat: -rwxr-xr-x 2,605 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# $eterna: autoquery,v 1.2 2014/03/14 20:59:19 mrg Exp $
#
# mirc-like automatic query windows for ircii
# Time-stamp: <01/01/17 18:06:40 friedel>
# by friedel <friedel@nomaden.org>

# WARNING: I assume you have the "screen" script, which comes with
# vanilla ircii loaded before this. It would be useful :)

# WARNING2: This script *replaces* ALL /on msg and /on send_msg hooks.

# I use "aqw." as in "Auto Query Windows" as a prefix.

# One slight modification of a wellknown alias:
alias talkto {
	window new
	window lev non log on hide_others name $0
	query $0
}

#alias talkto {
#	window new
#	window lev non log on name $0
#	query $0
#}

# This one is from the bigcheese script
alias reply talkto $* $,

# Stolen from "columns":
# columnate some output
alias aqw.format {
        assign aqw.IRCII.word $1
        if ( @aqw.IRCII.word < [$0] )
                { assign function_return $([-$0]1) }
                { assign function_return $1 }
}

alias aqw.encode {
	^assign aqw.nick $(encode($0))
	@ function_return = aqw.nick
}

# A field to remember wether we have a query: aqw.nicks
alias aqw.storenick {
	^assign aqw.nicks.$(aqw.encode($0)) true
}

alias aqw.retrievenick {
	^assign function_return $(aqw.nicks[${aqw.encode($0)}])
}

alias aqw.delnick {
	^assign -aqw.nicks[${aqw.encode($0)}]
}
#-----

alias aqw.newchat {
	aqw.storenick $0
	talkto $0
	on ^window_kill $0 aqw.delnick $0
}

# DAMMIT! Can anybody explain, why i have to remove the "." in aqw.nicks.$0 ?
# Answer: That is the stupid ircii Array Syntax, as explained in
# http://www.irchelp.org/irchelp/ircii/commands/expressions
alias aqw.chatexists {
	@ exists = aqw.retrievenick($0)
	if (exists==[true]) {
		^assign function_return 1
	} {
		^assign function_return 0
	}
}

alias aqw.lock {
	^assign aqw.locked 1
}

alias aqw.unlock {
	^assign aqw.locked 0
}

alias aqw.msg {
	^assign aqw.who *$0*
	^assign aqw.who.len ${@aqw.who + 3}
	xecho -window $0 -level msg ${aqw.format($aqw.who.len $aqw.who)} $1-
}

alias aqw.sendmsg {
	xecho -window $0 -level msg => *$0* $1-
}

# This function is bound to on msg
alias aqw.check.from {
	if (!aqw.locked) {
		aqw.lock
		if (! aqw.chatexists($0)) {
			aqw.newchat $0 $1-
			aqw.msg $0 $1-
		} {
			aqw.msg $0 $1-
		}
		aqw.unlock
	} {
		aqw.msg $0 $1-
	}
}

# This function is bound to on send_msg
alias aqw.check.to {
	if (!aqw.locked) {
		aqw.lock
		if (! aqw.chatexists($0)) {
			aqw.newchat $0
			aqw.sendmsg $0 $1-
		} {
			aqw.sendmsg $0 $1-
		}
		aqw.unlock
	} {
		aqw.sendmsg $0 $1-
	}
}

on ^msg -
on ^send_msg -
on ^msg * aqw.check.from $0 $1-
on ^send_msg * aqw.check.to $0 $1-