IT |
気になる、記になる… |
「iMac 27インチ」の後継モデルとみられる「iMac (Pro)」の情報が明らかに − 来年前半に発売か |
https://taisy0.com/2021/10/31/148197.html
|
apple |
2021-10-30 23:49:47 |
IT |
気になる、記になる… |
「HomePod mini」の新色、やはり来週早々に発売か − 著名記者も報告 |
https://taisy0.com/2021/10/31/148195.html
|
bloomberg |
2021-10-30 23:27:39 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
pythonのfunctoolsについてまとめてみた |
https://qiita.com/keishi04hrikzira/items/dd6ef7fcd67092c9baba
|
今回はfunctoolswrapsを理解する上で必要になった箇所をまとめただけですが、functoolsには他にもたくさんの関数がありますので、機会があればそちらについてもまとめたいと思います。 |
2021-10-31 08:27:55 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
ランダムなダミーの温湿度の値で急激な変動がない値を生成する(Node.js で simplex-noise を利用) |
https://qiita.com/youtoy/items/e6ce8fb0f7c6f06b67e9
|
ランダムなダミーの温湿度の値で急激な変動がない値を生成するNodejsでsimplexnoiseを利用「デバイスセンサー」がMQTTクライアントになった構成の開発をしている中で、MQTTの値を受信するMQTTブローカーの部分や別クライアント側に手を加える開発をするのに、以下のような物理部分をセットしなくても開発できるようにしたくて、今回の内容を進めました。 |
2021-10-31 08:26:59 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
swift segment controlの使用方法 |
https://teratail.com/questions/367037?rss=all
|
swiftsegmentcontrolの使用方法swiftのsegmentnbspcontrolの使用方法をお聞きしたいです。 |
2021-10-31 08:59:55 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
VBA メールの送り方について |
https://teratail.com/questions/367036?rss=all
|
|
2021-10-31 08:56:45 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
batファイルで個別ファイル圧縮 |
https://teratail.com/questions/367035?rss=all
|
該当 |
2021-10-31 08:49:37 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
firebaseでのアカウント消去とデータ消去 |
https://teratail.com/questions/367034?rss=all
|
firebaseでのアカウント消去とデータ消去firebaseでアカウントを消去するときはAuthauthcurrentUserdeleteこれによって消去できると思いますが、これと同時にuidと同様のドキュメントidで保存されているユーザーのデータを消去する方法はありますでしょうか。 |
2021-10-31 08:20:37 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
VBSでコマンドプロンプトにコマンドを入力したい。 |
https://teratail.com/questions/367033?rss=all
|
VBSでコマンドプロンプトにコマンドを入力したい。 |
2021-10-31 08:08:36 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
【Ruby】条件分岐 備忘録 |
https://qiita.com/ryotsumi/items/00e3a2956d307075f173
|
【Ruby】条件分岐備忘録目的条件分岐備忘録結論とりあえず種類あった。 |
2021-10-31 08:22:28 |
海外TECH |
DEV Community |
tsParticles 1.37.1 Released |
https://dev.to/matteobruni/tsparticles-1371-released-2gl6
|
tsParticles Released tsParticles Changelog Bug FixesFixed issue with dynamic imports and async loadingAdded browserslist to fix some issues with older browsers should fix matteobruni tsparticles tsParticles Easily create highly customizable particles animations and use them as animated backgrounds for your website Ready to use components available for React js Vue js x and x Angular Svelte jQuery Preact Inferno Solid Riot and Web Components tsParticles TypeScript ParticlesA lightweight TypeScript library for creating particles Dependency free browser ready and compatible withReact js Vue js x and x Angular Svelte jQuery Preact Inferno Riot js Solid js and Web Components Table of ContentsUse for your websiteLibrary installationOfficial components for some of the most used frameworksAngularInfernojQueryPreactReactJSSvelteVueJS xVueJS xWordPressTemplates and ResourcesDemo GeneratorCharacters as particlesMouse hover connectionsPolygon maskAnimated starsNyan cat flying on scrolling starsBackground Mask particlesMigrating from Particles jsPlugins CustomizationsDo you want to use it on your website Documentation and Development references here This library is available on the two most popular CDNs and it s easy and ready to use if you were using particles jsit s even easier You ll find theinstructions below with all thelinks you need and don t be scared by … View on GitHub |
2021-10-30 23:41:02 |
海外TECH |
DEV Community |
Deploy .NET 6 API to AWS App Runner using AWS Copilot CLI |
https://dev.to/aws-builders/deploy-net-6-api-to-aws-app-runner-using-aws-copilot-cli-4hnl
|
Deploy NET API to AWS App Runner using AWS Copilot CLIIn this tutorial blog post we are going to see how to deploy NET API to AWS App Runner using AWS Copilot CLI What is App Runner AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs at scale and with no prior infrastructure experience required Start with your source code or a container image App Runner automatically builds and deploys the web application and load balances traffic with encryption App Runner also scales up or down automatically to meet your traffic needs With App Runner you have more time to focus on your applications rather than thinking about servers or scaling App Runner FeaturesThe features of App Runner areAutoscaling starting and stopping as demand changes between configurable min and max limits Load balancing the service includes a transparent non configurable load balancer The URL can be pointed to the custom domain SSL amp Certificates the deployed services will have HTTPS endpoints for applications with AWS managed certificates The certificates will be renewed when it s about to expire Build service you can push your own images or let AWS build them for you from code AWS Copilot CLIThe AWS Copilot CLI is a tool for developers to build release and operate production ready containerized applications on AWS App Runner Amazon ECS and AWS Fargate From getting started pushing to staging and releasing to production Copilot can help manage the entire lifecycle of your application development aws copilot cli The AWS Copilot CLI is a tool for developers to build release and operate production ready containerized applications on AWS App Runner Amazon ECS and AWS Fargate Setup a NET Minimal APILet s get started This section will create minimal API services using NET and dockerize the application to deploy in AWS AppRunner using Copilot CLI Create a new web API project using dotnetdotnet new web n CoffeeServiceThe API code is like below that s by default generated by the template var builder WebApplication CreateBuilder args var app builder Build app MapGet gt Hello World app Run That s cool on seeing this minimal API like how it s easy as developing Node js code Let s run locally and see whether we are getting this Hello World response Run the codecd CoffeeService amp amp dotnet run Execute the URL and check the response➜ curl http localhost Hello World Containerize the APICreate a file named Dockerfile in the directory containing the csproj and open it in a text editor Copy the contents below in the Dockerfile In this Dockerfile we are building the project and running it in the aspnet runtime image FROM mcr microsoft com dotnet sdk AS buildWORKDIR srcCOPY CoffeeService csproj RUN dotnet restore CoffeeService csproj COPY WORKDIR src RUN dotnet build CoffeeService csproj c Release o app buildFROM build AS publishRUN dotnet publish CoffeeService csproj c Release o app publishFROM mcr microsoft com dotnet aspnet AS baseWORKDIR appEXPOSE ENV ASPNETCORE URLS http WORKDIR appCOPY from publish app publish ENTRYPOINT dotnet CoffeeService dll Build the docker imagedocker build t coffee service latestRun the docker imagedocker run p coffee service latestExecute the URL and check the response➜ curl http localhost Hello World Great The NET minimal API is created and run from local and in the docker container Now let s deploy into the AWS AppRunner using AWS Copilot CLI Deploy into AWS AppRunner using AWS Copilot CLIRun copilot init to set up the AWS AppRunner application for this service The initialization tool is going to ask you the questions Use existing application or create a new applicationApplication nameWorkload typeYou can choose one of the workload types In this demo we are setting up the AWS App Runner Request Driven Web Service App Runner Load Balanced Web Service Internet to ECS on Fargate Backend Service ECS on Fargate Worker Service Events to SQS to ECS on Fargate Scheduled Job Scheduled event to State Machine to Fargate Service name and path of the Dockerfile to buildOnce the ECR is set up you can set up the environment to deploy Welcome to the Copilot CLI We re going to walk you through some questionsto help you get set up with a containerized application on AWS An application is a collection ofcontainerized services that operate together Use existing application NoApplication name coffee shopWorkload type Request Driven Web ServiceService name coffee serviceDockerfile CoffeeService DockerfileOk great we ll set up a Request Driven Web Service named coffee service in application coffee shop listening on port Created the infrastructure to manage services and jobs under application coffee shop The directory copilot will hold service manifests for application coffee shop Wrote the manifest for service coffee service at copilot coffee service manifest ymlYour manifest contains configurations like your container size and port Created ECR repositories for service coffee service All right you re all set for local development Deploy YesLinked account and region us east to application coffee shop Proposing infrastructure changes for the coffee shop test environment Creating the infrastructure for the coffee shop test environment create complete s An IAM Role for AWS CloudFormation to manage resources create complete s An ECS cluster to group your services create complete s Enable long ARN formats for the authenticated AWS principal create complete s An IAM Role to describe resources in your environment create complete s A security group to allow your containers to talk to each other create complete s An Internet Gateway to connect to the public internet create complete s Private subnet for resources with no internet access create complete s Private subnet for resources with no internet access create complete s Public subnet for resources that can access the internet create complete s Public subnet for resources that can access the internet create complete s A Virtual Private Cloud to control networking of your AWS resources create complete s Created environment test in region us east under application coffee shop Environment test is already on the latest version v skip upgrade Building s FINISHED gt internal load build definition from Dockerfile s gt gt transferring dockerfile B s gt internal load dockerignore s gt gt transferring context B s gt internal load metadata for mcr microsoft com dotnet aspnet s gt internal load metadata for mcr microsoft com dotnet sdk s gt internal load build context s gt gt transferring context kB s gt build FROM mcr microsoft com dotnet sdk sha cebebfeaddaffddabfccafeac s gt base FROM mcr microsoft com dotnet aspnet sha edbdceabebeefdafedcdaf s gt CACHED base WORKDIR app s gt CACHED base WORKDIR app s gt CACHED build WORKDIR src s gt CACHED build COPY CoffeeService csproj s gt CACHED build RUN dotnet restore CoffeeService csproj s gt CACHED build COPY s gt CACHED build WORKDIR src s gt CACHED build RUN dotnet build CoffeeService csproj c Release o app build s gt CACHED publish RUN dotnet publish CoffeeService csproj c Release o app publish s gt CACHED base COPY from publish app publish s gt exporting to image s gt gt exporting layers s gt gt writing image sha baccffceadcddfadaafaee s gt gt naming to dkr ecr us east amazonaws com coffee shop coffee service sUse docker scan to run Snyk tests against images to find vulnerabilities and learn how to fix themLogin SucceededUsing default tag latestThe push refers to repository dkr ecr us east amazonaws com coffee shop coffee service cbc Pushed ebf Pushedlatest digest sha daeeaedbecacfdbbebcccedacca size Proposing infrastructure changes for stack coffee shop test coffee service Creating the infrastructure for stack coffee shop test coffee service create complete s An IAM Role for App Runner to use on your behalf to pull your image from ECR create complete s An IAM role to control permissions for the containers in your service create in progress s An App Runner service to run and manage your containers create complete s Deployed service coffee service Recommended follow up action You can access your service at over the internet Access the service at the URL ➜curl Hello World Copilot is doing the heavy lifting for us the developers So we can focus on the application Copilot will build push and launch your container on AWS to ECS Fargate and AppRunner Setting up Automated PipelineThe key principle of the devops process is Ship small Ship often The process of deploying small features on a regular cadence is crucial to DevOps As the team becomes more agile we need to automate application releases as multiple developers multiple services teams push the code into the source code repository AWS Copilot tool can help you in setting up the pipeline to automate application releases You can run these commands to create an automated pipeline that builds and deploys the application on git push aws apprunner dotnet demo git main copilot pipeline initst stage testRepository URL git github com ksivamuthu aws apprunner coffee shopWrote the pipeline manifest for aws apprunner coffee shop at copilot pipeline yml The manifest contains configurations for your CodePipeline resources such as your pipeline stages and build steps Update the file to add additional stages change the branch to be tracked or add test commands or manual approval actions Wrote the buildspec for the pipeline s build stage at copilot buildspec yml The buildspec contains the commands to build and push your container images to your ECR repositories Update the build phase to unit test your services before pushing the images Required follow up actions Commit and push the buildspec yml pipeline yml and workspace files of your copilot directory to your repository Run copilot pipeline update to create your pipeline The copilot buildspec pipeline yaml files are committed and pushed The code build pipelines are set up to deploy automatically in the test environment Now it s ready to bring more developers to start rocking They don t need to install a copilot to deploy the machine s service as they are developing The deployment steps are automated Let s push more code to see changes that get automatically deployed var builder WebApplication CreateBuilder args var app builder Build app MapGet gt Hello AWS AppRunner app MapGet api coffee gt new List lt dynamic gt new CoffeeId cappucino CoffeeName Cappucino new CoffeeId latte CoffeeName Latte new CoffeeId mocha CoffeeName Mocha new CoffeeId americano CoffeeName Americano new CoffeeId macchiato CoffeeName Macchiato new CoffeeId frappe CoffeeName Frappe new CoffeeId corretto CoffeeName Corretto new CoffeeId affogato CoffeeName Affogato new CoffeeId filtercoffee CoffeeName Filter Coffee app Run ➜aws apprunner dotnet demo git main curl Hello AWS AppRunner ➜aws apprunner dotnet demo git main curl s jq coffeeId cappucino coffeeName Cappucino Test the AutoscalingAWS App Runner automatically scales compute resources instances up or down for your App Runner application Automatic scaling provides adequate request handling when incoming traffic is high and reduces your cost when traffic slows down You can configure a few parameters to adjust autoscaling behavior for your service Settings Here s what you can configure Max concurrency The maximum number of concurrent requests that an instance processes When the number of concurrent requests exceeds this quota App Runner scales up the service Max size The maximum number of instances that your service scales up to At most this number of instances are actively serving traffic for your service Min size The minimum number of instances that App Runner provisions for your service The service always has at least this number of provisioned instances Some of them actively serve traffic The rest of them provisioned and inactive instances stand by as a cost effective compute capacity reserve which is ready to be quickly activated You pay for the memory usage of all provisioned instances You pay for the CPU usage of only the active subset App Runner temporarily doubles the number of provisioned instances during deployments to maintain the same old and new code capacity Let s create load testing with concurrent requests and check the number of instances hey z m c You can see the active instances count get increased based on the concurrent requests for autoscaling The source code repo of this demo ksivamuthu aws apprunner coffee shop What is App Runner AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs at scale and with no prior infrastructure experience required Start with your source code or a container image App Runner automatically builds and deploys the web application and load balances traffic with encryption App Runner also scales up or down automatically to meet your traffic needs With App Runner you have more time to focus on your applications rather than thinking about servers or scaling App Runner FeaturesThe features of App Runner areAutoscaling starting and stopping as demand changes between configurable min and max limits Load balancing the service includes a transparent non configurable load balancer The URL can be pointed to the custom domain SSL amp Certificates the deployed services will have HTTPS endpoints for applications with AWS managed certificates The… View on GitHub ConclusionAWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs at scale It provides seamless code to deploy workflow for Node js and Python runtime today and other runtimes using Dockerfile Copilot also helps you to have your own customizable pipelines with just a few commands for your apps running AWS AppRunner I presented a talk on AWS App Runners in IndyAWS meetup This session covers AWS App Runner s features The key challenges AWS App Runner solves How to configure and integrate AWS App Runner with your source control to deploy your code in secondsLive demo using AWS Copilot CLI a tool that supports AWS App Runner Want a deeper dive Download the presentation slides and youtube video of the talk I m Siva working as Sr Software Architect at Computer Enterprises Inc from Orlando I m an AWS Community builder Auth Ambassador and I am going to write a lot about Cloud Containers IoT and Devops If you are interested in any of that make sure to follow me if you haven t already Please follow me ksivamuthu Twitter or check out my blogs at blog sivamuthukumar com |
2021-10-30 23:19:07 |
海外TECH |
DEV Community |
Python in Appwrite |
https://dev.to/robimez/python-in-appwrite-378h
|
Python in Appwrite IntroAppwrite is a Self hosted Back end as a Service BaaS that allows developers to make apps easier and faster It is designed to be run on any operating system or platform and an Appwrite app can be written in most programming languages frameworks Trust me they have lots of SDKs It is still in its pre release stage first pre release on sep of or years ago as of time of writing but it has seen substantial work k commits across branches by contributors put into it and a large and active community engagement I will be making an Anime list bot with Appwrite and Telegram to show you the ropes Project set up Step Installing dockerWe will be using docker to install Appwrite docker is an open source containerization platform that is it allows developers to package their applications into little virtual spaces isolated from the rest of the system in what it calls containers install docker from here Step Installing Appwrite on Docker Linux Mac Any Unix system docker run it rm volume var run docker sock var run docker sock volume pwd appwrite usr src code appwrite rw entrypoint install appwrite appwrite Windows CMD Command Prompt docker run it rm volume var run docker sock var run docker sock volume cd appwrite usr src code appwrite rw entrypoint install appwrite appwrite Windows PS Power Shell docker run it rm volume var run docker sock var run docker sock volume pwd appwrite usr src code appwrite rw entrypoint install appwrite appwrite Official installation DocsSystem requirementsAppwrite requires at least CPU core and MB GB Recommended of RAM Or If ClamAV is installed GB of RAM is required since ClamAV uses at least GB on its own Let the program do its thing which will take quite a bit of time if you have a lower than average internet connection If you see this message you can proceed to the next step Errors you may encounterdocker Error response from daemon status code not OK but This means that docker does not have permissions to access the directory you want to install on and can be easily fixed by doing the following Go to Settings gt Resources gt File Sharing Then add the directory to the list Source Step Accessing the dashboard After installing Appwrite you go to localhost or in your preferred browser to access the Appwrite Dashboard For its first run you have to Create a Root user by Providing it your preferred name Adding in an Email address Creating a strong password and Finally accepting the terms and conditions All pretty standard sign up procedures that should land you here when done correctly Step Creating a Project Just click on Create project or the sign on the dashboard and name it however you desire Then grab the Project id and Api Endpoint from the settings tab for later use in the SDK After noting them down go to the API keys tab Create a new key with all the Scopes you need Step Server setup Python Install the python Sdk using pippip install appwriteinstall python telegram bot withpip install python telegram botinstall jikanPy withpip install jikanpyinstall dotenv withpip install python dotenvWe first need to Create a telegram bot by using botfather on telegram and obtain a bot token Then create a new directory and place some boilerplate code to control the bot main py import dotenv from os import getenv from telegram ext import Updater from telegram ext import CommandHandler token dotenv get key env TOKEN or getenv TOKEN updater Updater token token use context True dispatcher updater dispatcher def start update context context bot send message chat id update effective chat id text Hi there im alive def main Main Execution start handler CommandHandler start start dispatcher add handler start handler updater start polling if name main main then add your token in a env file as follows env TOKEN lt YOUR TOKEN HERE KSDFJAKSDJFHKSJDHF gt Next up lets set up the appwrite boiler plate code as follows import dotenv from os import getenv from telegram ext import Updater from telegram ext import CommandHandler from appwrite client import Client token dotenv get key env TOKEN or getenv TOKEN ENDPOINT dotenv get key env ENDPOINT or getenv ENDPOINT PROJECTID dotenv get key env PROJECTID or getenv PROJECTID APIKEY dotenv get key env APIKEY or getenv APIKEY updater Updater token token use context True dispatcher updater dispatcher client Client client set endpoint F http ENDPOINT v Your API Endpoint set project PROJECTID Your project ID set key APIKEY Your secret API key def start update context context bot send message chat id update effective chat id text Hi there im alive def main Main Execution start handler CommandHandler start start dispatcher add handler start handler updater start polling if name main main dont forget to add the respective values to the env fileTOKEN lt YOUR TOKEN HERE KSDFJAKSDJFHKSJDHF gt ENDPOINT localhost PROJECTID bf f d APIKEY e acfbffffaebcbabdfddfdccdda cbe adebcadccddfeacdeadfaf bcebbd faacf fdfecebeeaabaebccceabadfdcddfdc daNext up add a collection with the following rules key datatype in the Appwrite dashboard Make sure not to include special chars in your keynameuserID numeric MalList numeric array like state text array like then add that to the code as follows envTOKEN lt YOUR TOKEN HERE KSDFJAKSDJFHKSJDHF gt ENDPOINT localhostPROJECTID bf f dAPIKEY e acfbffffaebcbabdfddfdccdda cbe adebcadccddfeacdeadfaf bcebbd faacf fdfecebeeaabaebccceabadfdcddfdc da COLLECTIONID cceabmain pyTOKEN dotenv get key env TOKEN or getenv TOKEN ENDPOINT dotenv get key env ENDPOINT or getenv ENDPOINT PROJECTID dotenv get key env PROJECTID or getenv PROJECTID APIKEY dotenv get key env APIKEY or getenv APIKEY COLLECTIONID dotenv get key env COLLECTIONID or getenv COLLECTIONID Database CRUD Intro Create Read Update Delete Appwrite offers the database API for storing persistent data I will first explain the basics of creating reading from updating and deleting with the api And then explain how i ve used it in an actual demo app Initial setup the following code allows access to the database variable which is an instance of Database class from appwrite client import Clientfrom appwrite services database import Databaseclient Client client set endpoint https HOSTNAME OR IP v Your API Endpoint set project dfacddc Your project ID set key cdfbd aaedaad Your secret API key database Database client CollectionsCollections are the sql equivalent of tables for appwrite The API methods to access them are as follows Create collection Parameters name string required read array of strings with read perms required write array of strings with write perms required rules array of rule objects required Returns collection objectCode database create collection NAME List collection Gets a list of a users collections Parameters search string term to search for max chars limit integer default max offset integer default used for pagination orderType string ASC for ascending order and DESC for descending Returns Collection list object Code database list collections Get collection Gets a collection via its unique id Parameters collectionid string required Returns Collection object Code database get collection COLLECTION ID Update collection Updates a collection via its unique id Parameters collectionid string required name string required collection name read array of strings with read perms required write array of strings with write perms required rules array of rule objects required Returns Collection object Code database update collection COLLECTION ID NAME Delete collection Deletes a collection via its unique id Parameters collectionid string required Returns HTTP code Code database delete collection COLLECTION ID DocumentsDocuments are the sql equivalent of records or entries and the api methods to access them are as follows Create Document Parameters collectionId string required data json object required read array of strings with Read perms write array of strings with write permsparentDocument string parentProperty string parentPropertyType string Returns Document objectCode database create document COLLECTION ID List Document Gets a list of a users documents Parameters collectionId string required filters array of filter strings limit integer default max offset integer default used for pagination orderField string field to sort by orderType string ASC for ascending and DESC for decending orderCast string int string date time or datetime search string Returns Documeents list object Code database list documents COLLECTION ID Get Document Gets a document via its unique id Parameters collectionid string required documentId string required Returns Document object Code database get document COLLECTION ID DOCUMENT ID Update Document Updates a Document via its unique id Parameters collectionid string required documentId string required data Json object required read array of strings with read perms write array of strings with write perms Returns Document object Code database update document COLLECTION ID DOCUMENT ID Delete Document Deletes a Document via its unique id Parameters collectionid string required documentId string required Returns HTTP code Code database delete document COLLECTION ID DOCUMENT ID Implementation in codeAfter you have completed the project initialization steps and gotten yourself familiar with the methods you can fork the project repo and follow along Creating a document def set state update context Updates the database state and id generally handles the insert and update side of things user id update effective user id cqd update callback query data state str cqd split mal id int cqd split exists database list documents COLLECTIONID filters f userID user id if exists sum print Data not found create been deleted or never existed payload userID user id MalList mal id state state database create document COLLECTIONID payload context bot send message chat id update effective chat id text f Successfully added mal id to list else data exists update print Data exists update doc id exists documents id print exists if mal id in exists documents MalList context bot send message chat id update effective chat id text f mal id is already on your list n use update id to update its state n else malist list exists documents MalList new state list exists documents state new state append str state malist append int mal id payload userID user id MalList malist state new state updated database update document COLLECTIONID doc id payload context bot send message chat id update effective chat id text f Added mal id to list In the set state function of the app in the repo you will find that we use database create document specifically here payload userID user id MalList mal id state state database create document COLLECTIONID payload context bot send message chat id update effective chat id text f Successfully added mal id to list We pass it a payload of key value pairs that conform to the rules we set during the initialization phase and have it add our anime shows to the collection we created and here payload userID user id MalList malist state new state updated database update document COLLECTIONID doc id payload we see database update document in use to update the document in case it exists instead of creating a new one it uses one more parameter called doc id i e the document id that is parsed from the existing documentdoc id exists documents id which was fetched by using database list documents and passing in a filter where the userID attribute is equal to the current user of the bot update effective user id exists database list documents COLLECTIONID filters f userID user id we can see delete actions used in delete itemdef delete item update context deletes entry user id update effective user id if not len context args context bot send message chat id update effective chat id text Usage delete id else id of anime in question try mal id int context args if doesnt exist ignore docs database list documents COLLECTIONID filters f userID user id print docs if len docs documents context bot send message chat id update effective chat id text Nothing in your list to delete start adding more via anime parse mode ParseMode HTML else docs docs documents there should only be one doc doc id docs id print docs mal ids docs MalList statuses docs state print mal ids print statuses last items len mal ids and len statuses correct item mal id mal ids if last items and correct item delete the whole document as its the last item database delete document COLLECTIONID doc id context bot send message chat id update effective chat id text f Removed mal id From your list List is now empty parse mode ParseMode HTML elif not correct item context bot send message chat id update effective chat id text f mal id isnt in your list parse mode ParseMode HTML else index mal ids index mal id del mal ids del statuses payload userID user id MalList mal ids state statuses database update document COLLECTIONID doc id payload context bot send message chat id update effective chat id text f Deleted mal id from list except ValueError context bot send message chat id update effective chat id text Usage delete id Specifically at this part where we delete the document if the item is the last in the list we pass it the collection id and the doc id and then send a confirmation message to the userif last items and correct item delete the whole document as its the last item database delete document COLLECTIONID doc id context bot send message chat id update effective chat id text f Removed mal id From your list List is now empty parse mode ParseMode HTML We use database list documents in the list list function to generate a pretty formatted list like this docs database list documents COLLECTIONID filters f userID user id if len docs documents context bot send message chat id update effective chat id text No items in your list start adding them via anime parse mode ParseMode HTML else docs docs documents there should only be one doc print docs mal ids docs MalList statuses docs state anime list lt i gt lt b gt Your list lt b gt lt i gt n n i for id in mal ids anime jikan anime int id anime list anime list f lt code gt anime mal id lt code gt anime list anime list f lt b gt anime title lt b gt n anime list anime list f State statuses i n n anime list anime list f Status anime status n anime list anime list f Episodes anime episodes n genres genre name for genre in anime genres genre string for genre in genres genre string genre string f genre anime list anime list f Genres genre string n anime list anime list n print anime i context bot send message chat id update effective chat id text anime list parse mode ParseMode HTML We basically iterate over all documents returned by docs database list documents COLLECTIONID filters f userID user id Then for each one we fecth that anime from the my anime list api using jikanPy then we do a bit of templates and string manipulation to get the nice list for id in mal ids anime jikan anime int id anime list anime list f lt code gt anime mal id lt code gt anime list anime list f lt b gt anime title lt b gt n anime list anime list f State statuses i n n anime list anime list f Status anime status n anime list anime list f Episodes anime episodes n genres genre name for genre in anime genres genre string for genre in genres genre string genre string f genre anime list anime list f Genres genre string n anime list anime list n print anime i context bot send message chat id update effective chat id text anime list parse mode ParseMode HTML Thats allHit me up on github or telegram robi mez if you have any suggestions comments or questions I would also like feedback on this blog as its my first time writing one lt |
2021-10-30 23:15:01 |
LifeHuck |
ライフハッカー[日本版] |
隠れた感情を引き出し、人生を豊かにする方法 |
https://www.lifehacker.jp/2021/10/how-to-identify-your-shadow-emotions-and-why-you-shou.html
|
豊か |
2021-10-31 08:30:00 |
北海道 |
北海道新聞 |
南野拓実、今季リーグ戦初出場 イングランド・プレミア |
https://www.hokkaido-np.co.jp/article/606230/
|
南野拓実 |
2021-10-31 08:11:00 |
コメント
コメントを投稿