|
@@ -360,7 +360,7 @@ def main
|
|
|
|
|
|
if check_allow_processing(inputmessage, $user)
|
|
if check_allow_processing(inputmessage, $user)
|
|
|
|
|
|
- if inputmessage =~ /^([!]?to):([a-zA-Z_]+): (.+)/
|
|
|
|
|
|
+ if inputmessage =~ /^([!]?to):([a-zA-Z_\.]+): (.+)/
|
|
sendmode = $1
|
|
sendmode = $1
|
|
to_user = $2
|
|
to_user = $2
|
|
inputmessage = $3
|
|
inputmessage = $3
|
|
@@ -371,28 +371,25 @@ def main
|
|
if inputmessage =~ /^([A-Z_]+)/
|
|
if inputmessage =~ /^([A-Z_]+)/
|
|
cmd = $1
|
|
cmd = $1
|
|
end
|
|
end
|
|
|
|
+ # now we have the cmd .. or not ;)
|
|
|
|
+
|
|
|
|
+ if inputmessage =~ /^[a-zA-Z_]+ (.+)/
|
|
|
|
+ payload = $1
|
|
|
|
+ end
|
|
|
|
+ # now we can use payload
|
|
|
|
|
|
if allowed_cmd(cmd)
|
|
if allowed_cmd(cmd)
|
|
-
|
|
|
|
-
|
|
|
|
- if inputmessage =~ /^[a-zA-Z_]+ (.+)/
|
|
|
|
- payload = $1
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
if cmd == "PING"
|
|
if cmd == "PING"
|
|
put_log "PONG"
|
|
put_log "PONG"
|
|
|
|
|
|
- elsif inputmessage =~ /^(REQ_BC)/
|
|
|
|
|
|
+ elsif cmd == "REQ_BC"
|
|
|
|
|
|
- inputmessage =~ /^(REQ_BC) (.+),(.+),(.+),'(.+)','(.+)'$/
|
|
|
|
- # n f s ni txt
|
|
|
|
- error = 0
|
|
|
|
- # $&
|
|
|
|
- # The string matched by the last successful pattern match in this scope, or nil if the last pattern match failed. (Mnemonic: like & in some editors.) This variable is read-only.
|
|
|
|
- if $& == nil
|
|
|
|
- put_log "SYS Command format is REQ_BC <network>,<frequency>,<source/channel>,'<nickname>','<message>'"
|
|
|
|
- error = 1
|
|
|
|
- else
|
|
|
|
|
|
+ # help with format .. but send the raw payload
|
|
|
|
+ if payload =~ /^(.+),(.+),(.+),'(.+)','(.+)'$/
|
|
|
|
+ # n f s ni txt
|
|
|
|
+ error = 0
|
|
|
|
+ # $&
|
|
|
|
+ # The string matched by the last successful pattern match in this scope, or nil if the last pattern match failed. (Mnemonic: like & in some editors.) This variable is r
|
|
command = "BC"
|
|
command = "BC"
|
|
network = $2
|
|
network = $2
|
|
freqname = $3
|
|
freqname = $3
|
|
@@ -400,51 +397,45 @@ def main
|
|
nickname = $5
|
|
nickname = $5
|
|
text = $6
|
|
text = $6
|
|
|
|
|
|
- if network =~ /^(QWalt)|(QDEV)/
|
|
|
|
- else
|
|
|
|
|
|
+ if not network =~ /^(QWalt)|(QDEV)/
|
|
put_log "SYS Network name #{network} is unknown: QWalt or QDEV allowed."
|
|
put_log "SYS Network name #{network} is unknown: QWalt or QDEV allowed."
|
|
error = 1
|
|
error = 1
|
|
end
|
|
end
|
|
|
|
|
|
- if freqname =~ /^(-qw-)|(-spam-)|(-dev-)/
|
|
|
|
- else
|
|
|
|
|
|
+ if not freqname =~ /^(-qw-)|(-spam-)|(-dev-)/
|
|
put_log "SYS Frequency name is unknown #{freqname}"
|
|
put_log "SYS Frequency name is unknown #{freqname}"
|
|
error = 1
|
|
error = 1
|
|
end
|
|
end
|
|
|
|
|
|
- if source =~ /^(#.+)|(qw:\/\/)|(http:\/\/)/
|
|
|
|
- else
|
|
|
|
|
|
+ if not source =~ /^(#.+)|(qw:\/\/)|(http:\/\/)/
|
|
put_log "SYS Source string is not in the form ^(#.+)|(qw:\/\/)|(http:\/\/) was: #{source}"
|
|
put_log "SYS Source string is not in the form ^(#.+)|(qw:\/\/)|(http:\/\/) was: #{source}"
|
|
error = 1
|
|
error = 1
|
|
end
|
|
end
|
|
|
|
|
|
- if nickname =~ /^.+/
|
|
|
|
- else
|
|
|
|
|
|
+ if not nickname =~ /^.+/
|
|
put_log "SYS Nickname string is not in the form ^.+ #{nickname}"
|
|
put_log "SYS Nickname string is not in the form ^.+ #{nickname}"
|
|
error = 1
|
|
error = 1
|
|
end
|
|
end
|
|
|
|
|
|
- if text =~ /^.+/
|
|
|
|
- else
|
|
|
|
|
|
+ if not text =~ /^.+/
|
|
put_log "SYS Message string is not in the form ^.+ #{text}"
|
|
put_log "SYS Message string is not in the form ^.+ #{text}"
|
|
error = 1
|
|
error = 1
|
|
end
|
|
end
|
|
|
|
+
|
|
|
|
+ else # of check syntax
|
|
|
|
+ put_log "SYS Command format is REQ_BC <network>,<frequency>,<source/channel>,'<nickname>','<message>'"
|
|
|
|
+ error = 1
|
|
end
|
|
end
|
|
|
|
|
|
if error == 0
|
|
if error == 0
|
|
- # building hash here (bcid)
|
|
|
|
- #bcid = Digest::MD5.hexdigest("%d %s %s %s %s %s" % [Time.now.utc.to_i, network, freqname, source, nickname, text])
|
|
|
|
-
|
|
|
|
- #finalmessage = "%s %s %s,%s,%s,'%s','%s'" % [command, bcid, network, freqname, source, nickname, text]
|
|
|
|
- #send("/topic/messages", finalmessage)
|
|
|
|
- #put_log "BC_ID #{bcid} for: #{network},#{freqname},#{source}"
|
|
|
|
|
|
|
|
- finalmessage = "%s,%s,%s,'%s','%s'" % [network, freqname, source, nickname, text]
|
|
|
|
- send_cmd("REQ_BC", finalmessage)
|
|
|
|
-
|
|
|
|
|
|
+ payload = "%s,%s,%s,'%s','%s'" % [network, freqname, source, nickname, text]
|
|
|
|
+ send_cmd(cmd, payload)
|
|
|
|
+ # send REQ_BC to the corresponding role.
|
|
|
|
+
|
|
end
|
|
end
|
|
|
|
|
|
- elsif inputmessage =~ /^(BC_RE)/
|
|
|
|
|
|
+ elsif cmd == "BC_RE"
|
|
|
|
|
|
inputmessage =~ /^(BC_RE) (.+) (.+)=(\d+),(.+)=(\d+)$/
|
|
inputmessage =~ /^(BC_RE) (.+) (.+)=(\d+),(.+)=(\d+)$/
|
|
if $& == nil
|
|
if $& == nil
|
|
@@ -472,7 +463,7 @@ def main
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
- elsif inputmessage =~ /^(C)/
|
|
|
|
|
|
+ elsif cmd == "C"
|
|
|
|
|
|
inputmessage =~ /^(C) (.+)$/
|
|
inputmessage =~ /^(C) (.+)$/
|
|
error = 0
|
|
error = 0
|
|
@@ -504,7 +495,7 @@ def main
|
|
|
|
|
|
end
|
|
end
|
|
|
|
|
|
- end
|
|
|
|
|
|
+ end # of if command == xyz
|
|
|
|
|
|
|
|
|
|
else # of if allowed command
|
|
else # of if allowed command
|