Slack API - Generates: invalid_arg_name for SOME posts - slack-api

I have code that generates the following strings which are messaged to slack.
I have XXXd my token and Channel name. Other than that - these are exact as they are sent to slack.
The code executes about 50 of these - and only SOME of them fail
Item 5 returns the error:invalid_arg_name
https://slack.com/api/chat.postMessage?token=xxx&pretty=0&username=CNS&channel=mychannel&text=List
Updated: 7/26/2020 12:28 PM
https://slack.com/api/chat.postMessage?token=xxx&pretty=0&username=CNS&channel=mychannel&text=
(Pops and Beverages ): |1000| Diet Cola - 2 Liter: Order: 7 to 8 - 2-Liter"
https://slack.com/api/chat.postMessage?token=xxx&pretty=0&username=CNS&channel=mychannel&text=
(Pops and Beverages ): |0999| Diet Cola - Pepsi - Cans: Order: 3
to 4 case
https://slack.com/api/chat.postMessage?token=xxx&pretty=0&username=CNS&channel=mychannel&text=
(Seasoning ): |0997| Spices - Italian: Order: 1 to 1 each
https://slack.com/api/chat.postMessage?token=xxx&pretty=0&username=CNS&channel=mychannel&text=
(Breads & Cereal ): |0974| Bread - White Meijer Split Top:
Order: 1 to 1 each

You should encode your text before sending it to the API. In example 5, you are sending an unencoded ampersand ("Breads & Cereal"), causing the API to interpret everything after the ampersand as a query parameter name (thus the error, "invalid_arg_name").
Try sending it like that:
https://slack.com/api/chat.postMessage?token=xxx&pretty=0&username=CNS&channel=mychannel&text=%20%28Breads%20%26%20Cereal%20%29%3A%20%7C0974%7C%20Bread%20-%20White%20Meijer%20Split%20Top%3A%20Order%3A%201%20to%201%20each.
I recommend you to search for how to do percent encoding or url encoding in the programming language you are using.

Related

Regular Expression seperate groups before a line of special characters

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
This PM was sent by [ helloworld ] hellworld#gmail.com,
Membership Status : YES
http://gg.com.zz/US?id=gg#1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
Title : Testing is testing
Quantity : 44
Price : 55.00
Item Location : United States
*******************************************************************
I want this message right here, hello there, you help is deeply
**
appreciated :)
*** This email was sent using gg.gg.com ***
Above would be my output string, I wish to get groups between the long ^^^^^^- and ****** divider,
End result would be:
This PM was sent by [ helloworld ] hellworld#gmail.com,
Membership Status : YES
http://gg.com.zz/US?id=gg#1
Title : Testing is testing
Quantity : 44
Price : 55.00
Item Location : United States
I want this message right here, hello there, you help is deeply
**^
appreciated :)
I had try (?<=^)[^\^]*|[^\^-]*(?<=\*\*) but just couldn't match the whole long ^^^^^^^ divider, can anybody help me with this?
You can use this regex to capture your intended data,
(?s)^(?:\^+-|\*{3,})\s*(.+?)(?=\s*(?:\^+|\*{3,}))
Explanation:
(?s) - Enables . to match newline character which is required here as the data to be captured spans across multiple lines
^ - Matches start of text
(?:\^+-|\*{3,})\s* - Matches one or more ^ characters ending with - or three (why three so the last line doesn't match as it has 2 stars) or more * characters followed by optional whitespace
(.+?) - Matches the intended text and captures it in first grouping pattern
(?=\s*(?:\^+|\*{3,})) - Look ahead to ensure it stops capturing the data followed by optional whitespace and above pattern like ^^^^^- or *****
Although my previous answer also worked, but this is even better as it neatly captures data.
Demo

Lithuanian noun translation in conjunction with numerals in iOS

An important question came up when I tried to translate an existing iOS application into Lithuanian. I know how the Apple translation system works, especially for languages like English or Hungarian. But how I have to translate Lithuanian nouns in combination with numerals I don’t know.
The Lithuanian grammar in conjunction with numerals works like this for the word "įvykis" (event):
Lithuanian English
0 įvykių 0 events
1 įvykis 1 event
2 - 9 įvykiai 2 - 9 events
10 - 20 įvykių 10 - 20 events
21 įvykis 21 events
22 -29 įvykiai 22 - 29 events
30 įvykių 30 events
the same logic continuous
as of 21
More information about Lithuanian noun declension by numerals can be found in this Wikipedia article.
My question is, what key values have to be filled into the "Localizable.stringsdict" for Lithuanian? For English this file looks like this:
and for Lithuanian the same file looks this:
Those entries in the last table just partly correct. Does anyone know which keys I have to use in order to map my table into the stringsdict table? Which keys/keywords are necessary?
In the stringsdict file you can only have the keys zero, one, two, few, many, and other. That is all you actually need. iOS has its own data (based on information from the Unicode standard) that tells it which of those keys to use based on the actual number.
This is covered in the (now archived) Internationalization and Localization Guide, specifically the Handling Noun Plurals and Units Of Measure chapter with specifics about the stringsdict file in Appendix C.
You may also find language specific rules from Unicode. Scroll down to Lithianian and you will see the built in rules on how the category is used with a given number.
In short, you want the following for your "events" in Lithuanian:
one - %d įvykis
few - %d įvykiai
other - %d įvykių
iOS will know to use one for 1, 21, 31, 41, etc. It will know to use few for 2~9, 22~29, etc. It will know to use other for 0, 10~20, 30, etc.

how can i get pdf 417 boarding pass qr code details with decoding?

i am implemented this https://github.com/PDF417/pdf417-ios github for qr code scanning . i am getting response like this
example i scanned two tickets,
i am getting two different response bellow
M1SOLLE/JOSUHUA EQHSLJX ATLMEMDL 0254 003Y28C 10C3JIJI7O4M28C,
M1DEY/CHIRANJIB MR EPAELYA CCUBOM9W 0628 225Y018B0029 100.
how can i pick the:
1.flight number,
2.seatNumber,
3.date of journey
4.origin and destination.
is any available for direct library for parsing in ios??
Thank you for advance
For an explanation of the format, see page 28 of the IATA barcode standard. I'm not aware of any existing libraries to parse this, but search on GitHub. It should not be difficult to parse yourself, given the format.
I can help decipher the string.
M1SOLLE/JOSUHUA EQHSLJX ATLMEMDL 0254 003Y28C 10C3JIJI7O4M28C
The origin, destination, and airline can be found in the 8-character string, "ATLMEMDL". In this case Atlanta to Memphis on Delta Airlines" The first three letters are the origin airport code, the next three are the destination airport code, the last two are the airline code.
Airline codes can be found here.
Airport codes can be found here.
The next set of four digits is the flight number, "0254", or flight 254.
The next chunk begins with a 3-digit sequence number for the date (January 3), the ticket class ("Y") and seat ("28C").
Similarly, the second example decodes as follows:
M1DEY/CHIRANJIB MR EPAELYA CCUBOM9W 0628 225Y018B0029 100
Origin: (CCU) Netaji Subhash Chandra Bose International Airport
Destination: (BOM) Chatrapati Shivaji International Airport
Airline: (9W) Jet Airways (India)
Date: (225) August 13
Flight: 628
Seat: 18B
I am not aware of an open source library for parsing this.=

Ruby Regex for repeated numbers in a string

If i have a string like "123123123" - Here 123 is repeated 3 times.
1. So how can i get only "123" in ruby?
2. So if the string is "12312312" - Here 123 is repeated 2 times and then just 12, so here still i need to get "123".
3. Even if string is 99123123123, still i need to get 123.
Is this possible in Ruby Regex?
EDIT: I want this to solve Project Euler Problem 26 . So here 123 can be anything. All i want is to extract 1 number of at-least 2 repeated numbers.
This regex will detect all repeating groups.
(\d+)(?=.*\1)
Demo
Works great with ruby too.
result = '9912341234123'.scan(/(\d+)(?=.*\1)/)
#gets group with largest length
longestRepeatingGroup = result.max_by{|arr| arr[0].length}
puts longestRepeatingGroup
puts longestRepeatingGroup[0].length
Try this
99123123123.scan(/123/).count
12312312.scan(/123/).count

Plain-text formatted report into Crystal Reports

I have these plain-text reports. Can I please have some suggestions on what general approach to use to get these into crystal reports? Can I parse the file within CR? Do I need to script outside CR and re-write to a different format? I'm new to CR, and if there's a different software that would be better for this I'm open to that. The end-goal is to transform these reports into a nicely formated pdf with company logo, a few graphics, styled table, etc.
You can see the file contains data fields that I would need to capture such as account number, name etc. But then also a variable length table with headers.
Example report: (This is the exact format, with just identifying information changed)
MY REPORT Page: #
10/18/17 09:44 AM
ACCOUNT NUMBER : 456789
COMPANY NAME : JOHN DOE
ADDRESS : 8001 ANYWHERE DR
SOME PLACE, USA
SYSTEM TYPE : MAXMODEL9000
ID EVENT TYPE DESCRIPTION
---------- ---------------------- --------------------------------
3 TYPE 1 BLAH BLAH
4 TYPE 1 BLAH
5 TYPE 1 BLAH BLAH BLAH
6 TYPE 2 DR
7 TYPE 3 KITCHEN
11 TYPE 3 SOMETHING
12 TYPE 4 SOME DESCRIPTION
13 TYPE1 TEST

Resources