Skip to content

Instantly share code, notes, and snippets.

View isdaviddong's full-sized avatar

David Tung isdaviddong

View GitHub Profile
public class Answer
{
public string answer { get; set; }
public List<string> questions { get; set; }
public decimal score { get; set; }
}
public class QnAresponse
{
public List<Answer> answers { get; set; }
@isdaviddong
isdaviddong / upload.cs
Created December 26, 2018 15:56
上傳檔案到 建立Imgur
//建立ImgurClient(其中的"CLIENT_ID", "CLIENT_SECRET"要換成你自己的)
var client = new ImgurClient(CLIENT_ID, CLIENT_SECRET);
var endpoint = new ImageEndpoint(client);
IImage image;
//取得圖片檔案FileStream
using (var fs = new FileStream(FilePath, FileMode.Open))
{
image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult();
}
//顯示圖檔位置
//回覆tempalte
var actions = new List<isRock.LineBot.TemplateActionBase>();
actions.Add(new isRock.LineBot.MessageAction() { label = "標題-文字回覆", text = "回覆文字" });
actions.Add(new isRock.LineBot.UriAction() { label = "標題-Google", uri = new Uri("http://www.google.com") });
actions.Add(new isRock.LineBot.PostbackAction() { label = "標題-發生postack", data = "abc=aaa&def=111" });
var tmp = new isRock.LineBot.ButtonsTemplate()
{
text = "ButtonsTemplate文字訊息",
title = "ButtonsTemplate標題",
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\在此開啟CmdLine]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\在此開啟CmdLine\command]
@="\"C:\\Windows\\System32\\cmd.exe\" /k \"cd %L\""
rem 讓用戶輸入 port變數
set /p port="input port: "
rem 切換到你的ngrok資料夾(請自行調整)
path "C:\ngrok"
rem 直接將port NO.帶入執行ngrok
ngrok http %port% -host-header="localhost:%port%"
@isdaviddong
isdaviddong / quickreply.cs
Last active September 17, 2018 07:55
quickreply.cs
isRock.LineBot.TextMessage msg =
new isRock.LineBot.TextMessage("請問你要請什麼假別?");
msg.quickReply.items.Add(
new isRock.LineBot.QuickReplyMessageAction(
"特休", "特休", new Uri("https://arock.blob.core.windows.net/blogdata201809/if_resolutions-25_897228.png")));
msg.quickReply.items.Add(
new isRock.LineBot.QuickReplyMessageAction(
"事假", "事假", new Uri("https://arock.blob.core.windows.net/blogdata201809/if_busy_83242.png")));
msg.quickReply.items.Add(
@isdaviddong
isdaviddong / issue token.cs
Created August 25, 2018 01:44
重新issue一個 short-lived token
//重新issue一個 short-lived token
var token = isRock.LineBot.Utility.IssueChannelAccessToken(Channel_ID, Channel_Secret);
//顯示在TextBox1中
this.TextBox1.Text = token.access_token;
@isdaviddong
isdaviddong / sample.json
Created August 1, 2018 03:13
sample.json
{
"firstName": "John",
"lastName": "Smith",
"sex": "male",
"age": 25,
"address":
{
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
//取得特定ChannelAccessToken名下所有的Liff Apps
var Liff = isRock.LIFF.Utility.GetAllLiffApps(ChannelAccessToken);
//列舉所有Liff Apps
foreach (var item in Liff.apps)
{
Response.Write($"<br>liffId : {item.liffId}");
}
await context.PostAsync($"{this.count++}: 親愛的,你說了 '{message.Text}' , 我有聽到......");