Telegram bot dynamic keyboard in c# every button on one row - dynamic

Hi i new in stackoverflow...
I want to make a keyboard(replykeyboardmarkup) that read data from the database and every button on every row of the keyboard to show .
I read this link:
create dynamic Keyboard telegram bot in c# , MrRoundRobin API
But all button show in one row...
What i can do?
Tnx!
like this image

try this
private static InlineKeyboardButton[][] GetInlineKeyboard(string[] stringArray)
{
var keyboardInline = new InlineKeyboardButton[stringArray.Length][];
var keyboardButtons = new InlineKeyboardButton[stringArray.Length];
for (var i = 0; i < stringArray.Length; i++)
{
keyboardButtons[i] = new InlineKeyboardButton
{
Text = stringArray[i],
CallbackData = stringArray[i],
};
}
for (var j = 1; j <= stringArray.Length;j++)
{
keyboardInline[j-1] = keyboardButtons.Take(1).ToArray();
keyboardButtons = keyboardButtons.Skip(1).ToArray();
}
return keyboardInline;
}

Related

how do I change this google app script to hide sheets columns instead of rows based on column dates

so I'm a long way form a competent programmer, but I do dabble in google sheets scripts.
I previously had a script running on a timer trigger to hide rows based on dates found in column A.
function min() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("OLD");
var v = s.getRange("A:A").getValues();
var today = new Date().getTime() - 86400000‬
for (var i = s.getLastRow(); i > 1; i--) {
var t = v[i - 1];
if (t != "") {
var u = new Date(t);
if (u < today) {
s.hideRows(i);
}
}
}
}
function max() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("OLD");
var v = s.getRange("A:A").getValues();
var today = new Date().getTime() + 86400000
for (var i = s.getLastRow(); i > 1; i--) {
var t = v[i - 1];
if (t != "") {
var u = new Date(t);
if (u > today) {
s.hideRows(i);
}
}
}
}
function SHOWROWS() {
// set up spreadsheet and sheet
var ss = SpreadsheetApp.getActiveSpreadsheet(), sheets = ss.getSheets();
for(var i = 0, iLen = sheets.length; i < iLen; i++) {
// get sheet
var sh = sheets[i];
// unhide rows
var rRows = sh.getRange("A:A");
sh.unhideRow(rRows);
}
}
this would be set to run at midnight every night so as to hide all rows not +-1 day from the current date.
I have now switched to using this document primarily through the android app I need to swap the input layout Moving dates from rows and values in columns to the inverse, values are now in rows and the dates are in columns, inputing vertical values would be much quicker....but honestly its more about understanding what im doing wrong thats really motivating my search for a answer.
can anyone help me modify my old script to work on this changed sheet.
my attempts fall flat..eg:
function min() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("OLD");
var v = s.getRange("1:1").getValues();
var today = new Date().getTime() - 86400000‬
for (var i = s.getLastColumn(); i > 1; i--) {
var t = v[i - 1];
if (t != "") {
var u = new Date(t);
if (u < today) {
s.hidecolumns(i);
}
}
}
}
example spreadsheet:
https://docs.google.com/spreadsheets/d/1EjRIeDPrG_qp1S9QhInl9r3G0cZx_16OvnTXORgA3n4/edit?usp=sharing
there is two sheets one with the old version of my layout called "OLD" and my new desired layout called "NEW"
thanks in advance to anyone able to help
This function hides a column whose top row date is less yesterday.
function hideColumnWhenTopRowDateIsBeforeYesterday() {
var ss=SpreadsheetApp.getActiveSpreadsheet();
var sh=ss.getSheetByName("Sheet1");
var rg=sh.getRange(1,1,1,sh.getLastColumn());
var vA=rg.getValues()[0];
var yesterday=new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()-1).valueOf();
vA.forEach(function(e,i){
if(new Date(e).valueOf()<yesterday) {
sh.hideColumns(i+1);
}
});
}
My Spreadsheet before hiding columns:
My Spreadsheet after hiding columns:

How to curve the navtitle along the path using wheelnav js

How can I make the navtitle curve along the path of the slice and wrap the text if it's long.
Image of the wheel above
In long text, use '\n' in the title for wrap.
wheel.createWheel(["Long\ntext"]);
Currently, the navtitle curve along the path is an RC feature, so please use the source code instead of the last release.
You can find the new properties in this CodePen: https://codepen.io/softwaretailoring/pen/RQYzWm
var piemenu = new wheelnav("wheelDiv");
// New properties in wheelnav.js v1.8.0
piemenu.titleCurved = true;
piemenu.titleCurvedClockwise = false;
piemenu.titleCurvedByRotateAngle = false;
Unfortunately, the two above properties don't work together. :(
UPDATE: There is a way to achieve your needs. You can use two wheels on each other.
var piemenu = new wheelnav("wheelDiv");
setMenu(piemenu); // Set common properties
piemenu.titleRadiusPercent = 0.65; // Positioning first title
piemenu.markerEnable = true;
piemenu.slicePathFunction = slicePath().DonutSlice;
piemenu.sliceClickablePathFunction = slicePath().DonutSlice;
piemenu.titleHoverAttr = { fill: "#333" };
piemenu.createWheel(["Hello", "world!", "-------"]);
var piemenu2 = new wheelnav("wheelDiv2", piemenu.raphael);
setMenu(piemenu2); // Set common properties
piemenu2.wheelRadius = 520; // Positioning second title
piemenu2.slicePathFunction = slicePath().NullSlice; // There is no slice, only title
piemenu2.createWheel(["Bello", "space!", "*******"]);
// Link navigateFunctions to each other
for (var i = 0; i < piemenu.navItems.length; i++) {
piemenu.navItems[i].navigateFunction = function () {
piemenu2.navigateWheel(Math.abs(this.itemIndex));
}
}
for (var i = 0; i < piemenu2.navItems.length; i++) {
piemenu2.navItems[i].navigateFunction = function () {
piemenu.navigateWheel(Math.abs(this.itemIndex));
}
}
Here is a new CodePen for wrapped and curved text: https://codepen.io/softwaretailoring/pen/eLNBYz

Google Apps Script Sheet Looping Issue

I'm having issues with the GAS code below. The purpose is to iterate through all available sheets and create the drop-down boxes/ validation rules I would need to make an easy-to-edit form.
The main issue is that the code only runs once per sheet and it never applies itself to any other sheet except the active one; ie. it won't cycle to the next available sheet.
function FailureSauce() {
var ss = SpreadsheetApp.getActive();
for(var n in ss.getSheets()) { // loop over all tabs in the spreadsheet
var sheet = ss.getSheets()[n]; // look at every sheet in spreadsheet
var option = new Array();
option[0]="☐";
option[1]="☑";
//var dv = sheet.getRange(myRange.getRow(),myRange.getColumn()+1).getValidation();
var dv = SpreadsheetApp.getActiveSheet().getRange(SpreadsheetApp.getActiveRange().getRow(),SpreadsheetApp.getActiveRange().getColumn()).getDataValidation();
var dv = SpreadsheetApp.newDataValidation();
//dv.setAllowInvalidData(false);
dv.setAllowInvalid(false);
dv.setHelpText("Please choose of the options given in the drop down box");
dv.requireValueInList(option, true);
for (var i = 9; i <= SpreadsheetApp.getActiveSpreadsheet().getLastRow(); i++) {
for (var y = 1; y < 4; y++) {
SpreadsheetApp.getActiveSheet().getRange(i,y).setFontFamily("Arial")
SpreadsheetApp.getActiveSheet().getRange(i,y).setFontSize(10)
if (SpreadsheetApp.getActiveSheet().getRange(i,y).isBlank()) {
//SpreadsheetApp.getActiveSheet().getRange(i,y).setValue('=if(A2=1,image("http://i.stack.imgur.com/GChKZ.jpg"),image("http://i.stack.imgur.com/yQalm.jpg"))');
//sheet.getRange(SpreadsheetApp.getActiveSheet().getRow(),SpreadsheetApp.getActiveSheet().getColumn()).setDataValidation(dv.build());
SpreadsheetApp.getActiveSheet().getRange(i,y).setDataValidation(dv.build());
}
if (SpreadsheetApp.getActiveSheet().getRange(i,y).getValues() == "a") {
//SpreadsheetApp.getActiveSheet().getRange(i,y).setValue('=image("http://i.stack.imgur.com/GChKZ.jpg")');
SpreadsheetApp.getActiveSheet().getRange(i,y).setDataValidation(dv.build());
SpreadsheetApp.getActiveSheet().getRange(i,y).setValue("☑")
}
}
}
}
}
You should probably replace SpreadsheetApp.getActiveSheet() with your variable sheet.
function FailureSauce() {
var dv,option,ss,sheet;
ss = SpreadsheetApp.getActiveSpreadsheet();
for(var n in ss.getSheets()){// loop over all tabs in the spreadsheet
sheet = ss.getSheets()[n];// look at every sheet in spreadsheet
Logger.log('name: ' + sheet.getName());
option = new Array();
option[0]="☐";
option[1]="☑";
// var dv = sheet.getRange(myRange.getRow(),myRange.getColumn()+1).getValidation();
dv = sheet.getRange(SpreadsheetApp.getActiveRange().getRow(),SpreadsheetApp.getActiveRange().getColumn()).getDataValidation();
dv = SpreadsheetApp.newDataValidation();
// dv.setAllowInvalidData(false);
dv.setAllowInvalid(false);
dv.setHelpText("Please choose of the options given in the drop down box");
dv.requireValueInList(option, true);
for (var i = 9; i <= SpreadsheetApp.getActiveSpreadsheet().getLastRow(); i++) {
for (var y = 1; y < 4; y++) {
sheet.getRange(i,y).setFontFamily("Arial")
sheet.getRange(i,y).setFontSize(10)
if (sheet.getRange(i,y).isBlank()){
// sheet.getRange(i,y).setValue('=if(A2=1,image("http://i.stack.imgur.com/GChKZ.jpg"),image("http://i.stack.imgur.com/yQalm.jpg"))');
// sheet.getRange(sheet.getRow(),sheet.getColumn()).setDataValidation(dv.build());
sheet.getRange(i,y).setDataValidation(dv.build());
}
if (sheet.getRange(i,y).getValues() == "a"){
// sheet.getRange(i,y).setValue('=image("http://i.stack.imgur.com/GChKZ.jpg")');
sheet.getRange(i,y).setDataValidation(dv.build());
sheet.getRange(i,y).setValue("☑")
}
}
}
}
}

Phonegap - How to add collapasible-set in for loop?

I'm stuck. How do I add collapsible-set into for loop? I have tried this code below, but it only shows the h3 and p field. The collapsible-set doesn't work. Please help.
function querySuccess(tx, results) {
var len = results.rows.length;
var display ="";
display +="<div data-role='collapsible-set'>";
for (var i=0; i<len; i++){
display +="<div data-role='collapsible' data-collapsed='true'>";
display += "<h3>"+ results.rows.item(i).title +"</h3>";
display += "<p>"+ results.rows.item(i).line1 +"</p>";
display +="</div>";
}
display +="</div>";
document.getElementById("news_DB").innerHTML = display;
}
try this
$.each(results.rows,function(index){
var row = results.rows.item(index);
$('<div data-role="collapsible"><h3>'+row['col_name']+'</h3><p>Content</p></div>').appendTo('[data-role="content"]');
$('div[data-role=collapsible]').collapsible({theme:'c',refresh:true});
});
}

How do I programmatically capture and replicate Ai path shape?

I'm using ExtendScript for scripting Adobe Illustrator. I was wondering if there was a sneaky way or a script available to programmatically capture and then replicate a path shape, sort of JavaScript's .toSource() equivalent.
Thanks
Try this:
main();
function main(){
var doc = app.activeDocument; // get the active doc
var coords = new Array(); // make a new array for the coords of the path
var directions = new Array();
var sel = doc.selection[0];// get first object in selection
if(sel == null) {
// check if something is slected
alert ("You need to sevlect a path");
return;
}
var points = sel.pathPoints;// isolate pathpoints
// loop points
for (var i = 0; i < points.length; i++) {
// this could be done in one lines
// just to see whats going on line like
//~ coords.push(new Array(points[i].anchor[0],points[i].anchor[1]));
var p = points[i]; // the point
var a = p.anchor; // his anchor
var px = a[0];// x
var py = a[1]; // y
var ldir = p.leftDirection;
var rdir = p.rightDirection;
directions.push(new Array(ldir,rdir));
coords.push(new Array(px,py));// push into new array of array
}
var new_path = doc.pathItems.add(); // add a new pathitem
new_path.setEntirePath(coords);// now build the path
// check if path was closed
if(sel.closed){
new_path.closed = true;
}
// set the left and right directions
for(var j = 0; j < new_path.pathPoints.length;j++){
new_path.pathPoints[j].leftDirection = directions[j][0];
new_path.pathPoints[j].rightDirection = directions[j][1];
}
}