On Text while in private query? - irc

i was wondering how to get my remotes scripts to work in private queries rather than a channel, thank you!
example:
on $*:text:*abc*:"username": { msg "username" you whispered, $2 . }

From here: http://en.wikichip.org/wiki/mirc/on_event#Target
The target parameter of the event defines the locations of where the
event can be triggered from. For example, the on text event can be
triggered by a channel message or by a query.
? - defines query location
# - defines channel location
* - defines both query and channel locations
%var - A variable containing a channel or a list of channels is also
acceptable
In your example you would do:
on *:text:*abc*:?: { if ($nick == NAME) { msg $nick you whispered, $2 . } }

Related

Mirc script to find exact match in customer list

I am using this to find customer name in text file. Names are each on a separate line. I need to find exact name. If searching for Nick specifically it should find Nick only but my code will say found even if only Nickolson is in te list.
On*:text:*!Customer*:#: {
if ($read(system\Customer.txt,$2)) {
.msg $chan $2 Customer found in list! | halt }
else { .msg $chan 4 $2 Customer not found in list. | halt }
}
You have to loop through every matching line and see if the line is an exact match
Something like this
On*:text:*!Custodsddmer*:#: {
var %nick
; loop over all lines that contains nick
while ($read(customer.txt, nw, *nick*, $calc($readn + 1))) {
; check if the line is an exact match
if ($v1 == nick) {
%nick = $v1
; stop the loop because a result is found
break;
}
}
if (%nick == $null) {
.msg $chan 4 $2 Customer not found in list.
}
else{
.msg $chan $2 Customer found in list!
}
You can find more here: https://en.wikichip.org/wiki/mirc/text_files#Iterating_Over_Matches
If you're looking for exact match in a new line separate list, then you can use the 'w' switch without using wildcard '*' character.
From mIRC documentation
$read(filename, [ntswrp], [matchtext], [N])
Scans the file info.txt for a line beginning with the word mirc and
returns the text following the match value. //echo $read(help.txt, w,
*help*)
Because we don't want the wildcard matching, but a exact match, we would use:
$read(customers.txt, w, Nick)
Complete Code:
ON *:TEXT:!Customer *:#: {
var %foundInTheList = $read(system\Customer.txt, w, $2)
if (%foundInTheList) {
.msg # $2 Customer found in list!
}
else {
.msg 4 # $2 Customer not found in list.
}
}
Few remarks on Original code
Halting
halt should only use when you forcibly want to stop any future processing to take place. In most cases, you can avoid it, by writing you code flow in a way it will behave like that without explicitly using halting.
It will also resolve new problems that may arise, in case you will want to add new code, but you will wonder why it isn't executing.. because of the darn now forgotten halt command.
This will also improve you debugging, in the case it will not make you wonder on another flow exit, without you knowing.
Readability
if (..) {
.... }
else { .. }
When considering many lines of codes inside the first { } it will make it hard to notice the else (or elseif) because mIRC remote parser will put on the same identification as the else line also the line above it, which contains the closing } code. You should almost always few extra code in case of readability, especially which it costs new nothing!, as i remember new lines are free of charge.
So be sure the to have the rule of thump of every command in a new line. (that includes the closing bracket)
Matching Text
On*:text:*!Customer*:#: {
The above code has critical problem, and bug.
Critical: Will not work, because on*:text contains no space between on and *:text
Bug: !Customer will match EVERYTHING-BEFORE!customerANDAFTER <NICK>, which is clearly not desired behavior. What you want is :!Customer *: will only match if the first word was !customer and you must enter at least another text, because I've used [SPACE]*.

Stuck trying to write script to register username with tilte

Working on a bot script to lookup a username on join and see if it's be regiester with a title for the channel I run. Like if my name is Ravenna. I want the bot to check if I've registered the title Mistress with the username Ravenna.
I'm extremely stuck on how to go about this, researching things haven't brought me closer to a solution
so far all I've figured out I want is
on *:JOIN:#channel {
.msg $chan $nick take time to register with me; a pm will be sent to you soon
}
Any help or a source where I can figure out how to write and read files or the snippet code I need would be appericated
I think it's the best to use ini files for this. You should have a look at this: http://en.wikichip.org/wiki/mirc/ini_files and for more on http://en.wikichip.org/wiki/mirc.
For example you have a title called Mistress, your titles.ini file would look like this:
[mistress]
Ravenna=true
[mister]
Denny=true
To read a value you can use: $readini(titles.ini,n,mistress,$nick)
And to check the value you can do:
on *:join:#channel: {
if ($readini(titles.ini,n,mistress,$nick)) {
; code here for mistress
}
elseif ($readini(titles.ini,n,mister,$nick)) {
; code here for mister
}
elseif ($readini(titles.ini,n,TITLE,$nick)) {
; code here for another title
}
else {
; code here when no title
}
}
This way you must manually add a title in your titles.ini file. So if you want to add another title you should add [TITLE] on a new line in your ini file. If you have more questions you can ask here.
If you want to register someone with a title you could make a simple on text event and add a name to the ini file with writeini titles.ini TITLE $nick true
on *:join:#Tristram_Halls: {
if ($readini(titles.ini,n,mistress,$nick)) {
.describe $chan looks up and sees Mistress $nick. "Greetings Mistress."
}
else {
.msg $chan Greetings $nick I have no record of what you are. Please take the time to register that info with me
.msg $chan $nick Please choose from one of the following titles: !Mistress
}
}
on *:text:!Mistress:#:{
/writeini [-n] titles.ini mistress $nick true
}
just testing a short code for mirc title registration. At this point nobody is in the ini file, and I've add the title [mistress] but when anybody joins the channel the bot does this rather than c
Testbot looks up and sees Mistress "Greetings Mistress."

CQ Workflow- Comment not transferring between participant with a process step in between

When there is a process step between two participant steps, the comments is not passing between participants. My Workflow is like this-
ParticipantA ---> Process step X (ecma script) ----> Process step Y (ecma script) -----> ParticipantB
When I add some comment at ParticipantA step it does not carry forward to ParticipantB. Seems OOB functionality has limitations on this.
As a workaround, I am trying to get it at "Process step X" and passing on to Process step Y. I am able to get it but not able to set it for next step.
Below is my code-
log.info("Noop process called for: " + workItem.getWorkflowData().getPayload());
var comment = workItem.getMetaDataMap().get("comment");
log.info("Comment in approval process-----------" + comment);
var workflowData = workItem.getWorkflowData();
if (workflowData.getPayloadType() == "JCR_PATH") {
log.info("setting comment in meta data----------------");
workflowData.getMetaDataMap().put("comment", comment);
}
Can you help on how to set comment for next step?
Thanks in advance.
Regards,
Vivek
You would need to actually store your comment within a workflow Metadata Map. This
should help.
Once you have successfully stored your comment, you can access it later.
Hope this helps
I guess it is a session change within the workflow. The WorkflowData instance will be newly set. You can easily check it in the debugger of your ide. You have to iterate over the HistoryItems as illustrated here:
final List<HistoryItem> history = workflowSession.getHistory(workItem.getWorkflow());
final List<String> comments = new ArrayList<>();
if (history.size() > 0) {
HistoryItem current = history.get(history.size() - 1);
do {
comments.add(current.getComment());
current = current.getPreviousHistoryItem();
} while (current != null);
}
Comments are empty strings, if not set - if i'm not mistaken.

Is there an easy way to add/remove/modify query parameters of a URL in Tritium?

I saw a very manual way of doing this in another post: How do I add a query parameter to a URL?
This doesn't seem very intuitive, but someone there mentioned an easier way to accomplish this using the upcoming "URL scope". Is this feature out yet, and how would I use it?
If you're using the stdlib mixer, you should be able to use the URL scope which provides helper functions for adding, viewing, editing, and removing URL params. Here's a quick example:
$original_url = "http://cuteoverload.com/2013/08/01/buttless-monkey-jams?hi=there"
$new_url = url($original_url) {
log(param("hi"))
param("hello", "world")
remove_param("hi")
}
log($new_url)
Tritium Tester example here: http://tester.tritium.io/9fcda48fa81b6e0b8700ccdda9f85612a5d7442f
Almost forgot, link to docs: http://tritium.io/current (You'll want to click on the URL category).
AFAIK, there's no built-in way of doing so.
I'll post here how I did to append a query param, making sure that it does not get duplicated if already on the url:
Inside your functions/main.ts file, you can declare:
# Adds a query parameter to the URL string in scope.
# The parameter is added as the last parameter in
# the query string.
#
# Sample use:
# $("//a[#id='my_link]") {
# attribute("href") {
# value() {
# appendQueryParameter('MVWomen', '1')
# }
# }
# }
#
# That will add MVwomen=1 to the end of the query string,
# but before any hash arguments.
# It also takes care of deciding if a ? or a #
# should be used.
#func Text.appendQueryParameter(Text %param_name, Text %param_value) {
# this beautiful regex is divided in three parts:
# 1. Get anything until a ? or # is found (or we reach the end)
# 2. Get anything until a # is found (or we reach the end - can be empty)
# 3. Get the remainder (can be empty)
replace(/^([^#\?]*)(\?[^#]*)?(#.*)?$/) {
var('query_symbol', '?')
match(%2, /^\?/) {
$query_symbol = '&'
}
# first, it checks if the %param_name with this %param_value already exists
# if so, we don't do anything
match_not(%2, concat(%param_name, '=', %param_value)) {
# We concatenate the URL until ? or # (%1),
# then the query string (%2), which can be empty or not,
# then the query symbol (either ? or &),
# then the name of the parameter we are appending,
# then an equals sign,
# then the value of the parameter we are appending
# and finally the hash fragment, which can be empty or not
set(concat(%1, %2, $query_symbol, %param_name, '=', %param_value, %3))
}
}
}
The other features you want (remove, modify) can be achieved similarly (by creating a function inside functions/main.ts and leveraging some regex magic).
Hope it helps.

ClearQuest Perl API -- Adding a Child Record to another record

I have a ClearQuest database with a record type called "BuildSheet". On a BuildSheet record, you can attach tasks which are another record type.
I thought I could create a task record type, via the BuildEntity Session method, then do a EditEntity Session method on the BuildSheet record, and add the Task Id field via the AddFieldValue Entity method.
Unfortunately, my attempt to create the Type record fails. It gets tripped by the eval statement:
#
# Now Create the Record Type and Fill in the Fields
#
my $record;
eval { $record = $cq->BuildEntity(TASK_RECORD_TYPE); };
if ($#) {
croak qq(Error when attempting to create record type ")
. TASK_RECORD_TYPE . qq("\n$#\n);
}
if (not $record) {
die qq(Cannot create entity ") . TASK_RECORD_TYPE . qq("\n);
}
The eval is failing when I attempt to create the TASK_RECORD_TYPE record. I get the following error message:
Error when attempting to create record type "Task"
Permission denied for user WeintraubH to perform action Create (of type SUBMIT)
at D:/Program Files/Rational/Common/lib/perl5/site_perl/5.8.6/CQPerlExt.pm line 43.
at H:\svn\addTask.cqpl line 340
main::createTask('TASK', 'cm', 'HEADLINE',
'FMS-CWA_APP_B35_HF276', 'DESCRIPTION', 'FMS-CWA_APP_B35_HF276',
'PRIORITY', 2, 'EFFORT', ...) called at H:\svn\addTask.cqpl line 236
Now, I can bring up a BuildSheet record, go into the Child Record tag, click Create and build my task record that way, so apparently I do have permission.
What it seems is that I must somehow associate the "Task" record with a "BuildSheet" before I try to create it, but how?
I found the culprit. They have a hook on the BuildEntity method in order to ensure that the Task record I'm trying to create is connected to a parent record. Stupid *###*$&#.
Anyway I found the hook script (written in VB) and found where they were trying to trip me up:
Set oSession = GetSession
pRequestIDValue = oSession.NameValue("ParentRequestID")
pTaskIDValue = oSession.NameValue("ParentTaskID")
pBuildSheetIDValue = oSession.NameValue("ParentBuildSheetID")
NewTaskPermittedValue = oSession.NameValue("NewTaskPermitted")
curUser = oSession.GetUserLoginName
if (pBuildSheetIDValue <> "") or (pTaskIDValue <> "") _
or ((pRequestIDValue <> "") and (NewTaskPermittedValue = "Yes")) then
task_AccessControl = TRUE
else
task_AccessControl = FALSE
end if
To get around this, I set ParentBuildSheetID with the SetNameValue method before I attempted to create the record:
$cq->SetNameValue("ParentBuildSheetID", $buildsheetId);
my $record;
eval { $record = $cq->BuildEntity(TASK_RECORD_TYPE); };
if ($#) {
croak qq(Error when attempting to create record type ")
. TASK_RECORD_TYPE . qq("\n$#\n);
}
if (not $record) {
die qq(Cannot create entity ") . TASK_RECORD_TYPE . qq("\n);
}
Now, that worked!
No, I don't think you have to associate the Task record with the BuildSheet as you call BuildEntity.
Can you call GetSubmitEntityDefNames and verify that "Task" is in its results?
http://www.ibm.com/developerworks/forums/thread.jspa?threadID=179429 has the closest example I see to what you are trying to do. If so, once you get past the BuildEntity problem, rather than:
then do a EditEntity Session method on the BuildSheet record, and add the Task Id field via the AddFieldValue Entity method.
you want to set the correct relation field on your new Task to the BuildSheet Id before Commit rather than set the Task Id on the BuildSheet record.
I hope this helps; I haven't had to use ClearQuest in more than a decade, so I'm just going by what the (way too scant) documentation says.