public static bool Pin(long chatid, int messageid, bool disableNotification = true) { var t = Api.PinChatMessageAsync(chatid, messageid, disableNotification); t.Wait(); return(t.Result); }
/// <summary> /// Immediately save data. /// </summary> /// <returns></returns> public async Task ForceSave() { using (await _saveLock.LockAsync()) { var chat = await _botClient.GetChatAsync(_saveResChatId); var prevPinnedMessage = chat.PinnedMessage; SaveStorageStateToFile(); Message savedMsg = null; using (var readStream = File.OpenRead(_storageFilePath)) { savedMsg = await _botClient.SendDocumentAsync( _saveResChatId, new InputOnlineFile(readStream, FileResName), caption : FileResName ); } await _botClient.PinChatMessageAsync(_saveResChatId, savedMsg.MessageId); if (_deletePreviousMessages) { await _botClient.DeleteMessageAsync(_saveResChatId, prevPinnedMessage.MessageId); } } }
public static bool Pin(long chatid, int messageid, bool disableNotification = true) { try { return(Api.PinChatMessageAsync(chatid, messageid, disableNotification).Result); } catch { //... return(false); } }