text
stringlengths
2
104M
meta
dict
<a class="site-title fixed bg-blue p1 no-line-height top-0 left-0 z4" href="{{ site.baseurl }}/"> {% include chowdown-logo-white.svg %} <h1 class="hide">{{ site.title }}</h1> </a>
{ "repo_name": "clarklab/chowdown", "stars": "585", "repo_language": "HTML", "file_name": "nutrients.yml", "mime_type": "text/plain" }
# See https://schema.org/NutritionInformation servingSize: name: serving size type: Text description: The serving size, in terms of the number of volume or mass. unit: calories: name: calories type: Energy description: The number of calories. unit: kcal carbohydrateContent: name: carbs type: Mass description: The number of grams of carbohydrates. unit: g cholesterolContent: name: cholesterol type: Mass description: The number of milligrams of cholesterol. unit: g fatContent: name: fat type: Mass description: The number of grams of fat. unit: g fiberContent: name: fiber type: Mass description: The number of grams of fiber. unit: g proteinContent: name: protein type: Mass description: The number of grams of protein. unit: g saturatedFatContent: name: saturates type: Mass description: The number of grams of saturated fat. unit: g sodiumContent: name: sodium type: Mass description: The number of milligrams of sodium. unit: mg sugarContent: name: sugar type: Mass description: The number of grams of sugar. unit: g transFatContent: name: trans fat type: Mass description: The number of grams of trans fat. unit: g unsaturatedFatContent: name: unsaturated fat type: Mass description: The number of grams of unsaturated fat. unit: g
{ "repo_name": "clarklab/chowdown", "stars": "585", "repo_language": "HTML", "file_name": "nutrients.yml", "mime_type": "text/plain" }
# 关于运行 DOS 游戏的常见问题和解答 ## 《仙剑》开始时要求输入颜色密码 参考目录 `/faq` 下的图片 `仙剑DOS版密码图.webp`。 ## 《水浒传》开始时要求输入数字密码 只需输入任意4个数字,然后按 tab 键即可。
{ "repo_name": "skywind3000/preserve-cd", "stars": "3238", "repo_language": "None", "file_name": "README.md", "mime_type": "text/plain" }
# 绝版游戏保护工程 今天互联网上的内容,由于各种原因,正在以越来越快的速度消失,而新一代网民们,却并没有备份和记录的习惯及意识。不远的将来,会有一天,当你特别想找一个东西却搜尽互联网都找不到时就来麻烦了,本项目立足于将这样的损失最小化。 ## CD1:DOS 经典游戏 本光碟收录了 64 款几近绝版的精品 DOS 游戏,大部分游戏现在网上都很难找到,或者找到也是捆版了病毒和流氓软件。虽然 DOSBOX 可以模拟 DOS 游戏,但是不同的游戏设置不同,有的需要加载光碟,有的需要配置好声卡参数,有的游戏还需要特定的 DOSBOX 版本才能运行。 现在有很多什么 1800 个 dos 游戏之类的合集,说实话,30GB 的内容下载下来你不知道怎么玩,你不知道玩啥。这个光碟只有 650MB 的 CD-R 容量,却为你精选了 64 款最值得玩的 DOS 游戏,每个游戏配上截图和文字介绍,包括制作方,发行方,游戏类型,简介等,怀旧就是要有个气氛,才能有更高的娱乐和收藏价值。 光碟介绍: - [CD1 光盘介绍](docs/preserve-cd-1.pdf) 光碟下载: - 谷歌:[绝版游戏保护工程1.iso](https://drive.google.com/file/d/11FafOmfw7OqrEx14DPh2rhqRHO_j70KB/view?usp=sharing) - 度盘:地址 `s/10uTA5L5Nay1aKpqkvACM-A`,口令 `f08f` - 115:地址 `s/sw3u78i3ze9` ,口令 `p254` - 天翼云网盘:地址`https://cloud.189.cn/t/Ef2IjyuuemIn`,口令:`jj8t` - BT: [磁力链接](https://tinyurl.com/y2ba4dxs) ## CD2:绝版经典小游戏 Epic/Steam 上游戏买了一大堆,从第一页看到最后一页,没有一个想玩?免费手游试了好几个,不氪金就打不过小学生?想玩会游戏发现不是玩不动就是自取其辱?欢迎尝试《绝版经典小游戏》,本光碟包含一百个简单又耐玩的小游戏(Windows + Flash),上手容易,无需充值,百玩不腻。 光碟介绍: - [CD2 光碟介绍](docs/preserve-cd-2.pdf) 光碟下载: - 谷歌:[绝版游戏保护工程2.iso](https://drive.google.com/file/d/1qSRYgoaL3AR8ixqp1AP4gKW1zX9wZENe/view?usp=sharing) - 度盘:地址 `s/1V8oN-2GyX6ku3yA247IURw`, 口令 `kpor` - 115:地址 `s/sw30ctq3ze9` ,口令 `vb46` - 天翼云网盘:地址`https://cloud.189.cn/t/B7jiUzIn63aa`,口令:`8xrr` - BT: [磁力链接](https://tinyurl.com/y38tsslf) #### BT:[磁力链接(CD1+CD2)](https://tinyurl.com/yxk4np5n) ## 增刊:老游戏攻略合集 雷锋珍藏的一些得来不易的老游戏攻略,包含:DOS游戏,红白机,SFC/MD 等主机游戏机: - 谷歌:[老游戏攻略合集.iso](https://drive.google.com/file/d/12G-go9FSBwaE0o9JdNaoiTGrddX1kfwM/view?usp=sharing) - 度盘:地址 `s/1ZyOI2Phv6nWR_18l1uWLLg` ,口令 `8869` - 115:地址 `s/sw6n61k3ze9` ,口令 `8866` ## Credit - 兄弟项目:[绝版软件保护工程](https://github.com/skywind3000/preserve-iso) TODO
{ "repo_name": "skywind3000/preserve-cd", "stars": "3238", "repo_language": "None", "file_name": "README.md", "mime_type": "text/plain" }
# Contribution Guidelines Please ensure your pull request adheres to the following guidelines: * Please search previous suggestions before making a new one, as yours may be a duplicate. * Enter a meaningful pull request description. * Please make an individual commit for each suggestion in a pull request. * Use the following format for application: \[APPLICATION\]\(LINK\) - DESCRIPTION. * New categories, or improvements to the existing categorisation, are always welcome. * Keep descriptions short and simple. * End all descriptions with a full stop/period. * Check your spelling and grammar. * Make sure your text editor is set to remove trailing whitespace. Thank you for your suggestions!
{ "repo_name": "xyNNN/awesome-mac", "stars": "129", "repo_language": "None", "file_name": "README.md", "mime_type": "text/plain" }
# Awesome Mac [![Software License](https://img.shields.io/badge/license-CC0%201.0%20Universal-brightgreen.svg?style=flat-square)](LICENSE) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) ![repository header](https://raw.githubusercontent.com/xyNNN/awesome-mac/master/files/header.jpg?token=AB1yFog9AH79ucAQKrB5YYfkLRMabc5Mks5V3ignwA%3D%3D) A curated list of amazingly awesome Mac OS X tools, applications and games. This repository is inspired by [awesome-php](https://github.com/ziadoz/awesome-php)! > Note: This repository isn't finished yet. It will be updated from time to time, stay tuned! ## Contributing Please see [CONTRIBUTING](https://github.com/xyNNN/awesome-mac/blob/master/CONTRIBUTING.md) for details. ## Table of Contents - [Cloud Storages](#cloud-storages) - [Developer Tools](#developer-tools) - [E-Mail](#e-mail) - [FTP Clients](#ftp-clients) - [Finance](#finance) - [Games](#games) - [IDE (Integrated development environment)](#ide-integrated-development-environment) - [Messaging](#messaging) - [Organisational](#organisational) - [Photo and Video](#photo-and-video) - [Music](#music) - [Productivity](#productivity) - [Utilities](#utilities) - [Security](#security) - [Text Editors](#text-editors) ## Cloud Storages *Several data providers who stores your data in the cloud* * [Google Drive](https://www.google.com/intl/de_de/drive) - A file storage and synchronization service created by Google. * [iCloud](https://www.icloud.com/) - A file storage and synchronization service powered by Apple. * [OneDrive](https://onedrive.live.com/about/en-us) - OneDrive is a file hosting service that allows users to sync files and later access them from a web browser or mobile device from Microsoft. ## Developer Tools *Several tools to support the work of a developer* * [Paw](https://luckymarmot.com/paw) - The ultimative REST client for Mac. * [Postman](https://www.getpostman.com) - Postman helps you develop APIs faster. * [PSequel](http://www.psequel.com) - A PostgreSQL GUI Tool for Mac OS X. * [Sequel Pro](http://www.sequelpro.com) - MySQL database management for Mac OS X. ## E-Mail *Programs which are used to access and manage a user's email* * [Airmail](http://airmailapp.com) - Lightning Fast Mail Client for Mac and iPhone. * [N1](https://www.nylas.com/n1) - The extensible, open source mail client. * [Postbox](https://www.postbox-inc.com) - Another powerful Mail Client for Mac. ## FTP Clients *Applications to connect via several protocols to a server.* * [Cyberduck](https://cyberduck.io) - Libre FTP, SFTP, WebDAV, S3 & OpenStack Swift client. * [FileZilla](https://filezilla-project.org) - A fast and reliable cross-platform FTP, FTPS and SFTP client. * [Flow](http://fivedetails.com/flow/) - The Mac's Best FTP + SFTP Client. * [Transmit](http://www.panic.com/transmit/) - The ultimate Mac OS X FTP + SFTP + S3 app. ## Finance *Applications to keep an eye on your costs* * [Banking 4](https://subsembly.com/de/banking.html) - Your banking software for OS X. ## Games *A list of awesome games which are running smoothly under Mac OS X* - [Tankist Online](http://github.com/servusDei2018/TankistOnline) - An free, opensource, lightweight, cross-platform and multiplayer 2D tank game. - [Heroes of the Storm](http://eu.battle.net/heroes) - A MOBA video game developed by Blizzard Entertainment. ## IDE (Integrated development environment) *Software Applications that provides comprehensive facilities for software development.* * [Android Studio](https://developer.android.com/studio/index.html) - Android Studio is the official integrated development environment (IDE) for Android platform development. * [AppCode](https://www.jetbrains.com/objc/) - Swift execution of your bright ideas. * [CLion](https://www.jetbrains.com/clion/) - intelligent cross-platform C/C++ IDE. * [Eclipse](https://www.eclipse.org) - A project aiming to provide a universal toolset for development. * [Intellij IDEA](https://www.jetbrains.com/idea/) - The Most Intelligent Java IDE. * [PhpStorm](https://www.jetbrains.com/phpstorm/) - The Most Intelligent PHP IDE. * [PyCharm](https://www.jetbrains.com/pycharm/) - The Most Intelligent Python IDE. * [RubyMine](https://www.jetbrains.com/ruby/) - The Most Intelligent Ruby and Rails IDE. * [WebStorm](https://www.jetbrains.com/webstorm/) - The smartest JavaScript IDE. * [VS Code](https://code.visualstudio.com/) - Excellent multipurpose IDE. ## Messaging *Apps to communicate with other human beings* * [ChitChat](https://github.com/stonesam92/ChitChat) - Unofficial Desktop client for WhatsApp. * [Nimbus](https://github.com/jnordberg/irccloudapp) - Standalone IRCCloud client for OS X. * [Skype](https://www.skype.com) - Share, message and call across Platforms. * [Slack](https://slack.com/) - A messaging app for teams. * [Telegram](https://desktop.telegram.org) - A new era of messaging. * [Textual](https://www.codeux.com/textual) - The world's most popular application for interacting with IRC on OS X. ## Organisational *Apps to organize your life like calendars or task lists* * [HULOG](https://hulog.reichel.dev) - A Mac and iOS app for quickly taking timestamped notes during meetings or oncall incidents. * [Taskade](https://taskade.com/downloads) - Beautiful task lists, notes and team workspaces on your Mac. ## Photo and Video *Apps for you to be more creative* - [Zoommy](http://zoommyapp.com) - Find awesome free stock photos. ## Music *Apps for listen to your favourite music* - [Soundnode](http://www.soundnodeapp.com) - An opensource SoundCloud app for desktop. ## Productivity *Apps to improve your productivity during your day* - [Cerebro](http://www.cerebroapp.com) - One-input productivity booster. ## Utilities *A list of tools to ease up your work with Mac OS X* * [Alfred](https://www.alfredapp.com/) - Search your Mac and the web effortlessly, and control your Mac using customised actions with the Alfred. * [Amphetamine](https://itunes.apple.com/de/app/amphetamine/id937984704?mt=12) - Don't let you mac sleep. * [Android File Transfer](https://www.android.com/filetransfer) - Browse and transfer files upto 4 GB between Mac and Android device. * [AppCleaner](http://www.freemacsoft.net/appcleaner/) - A small application to thoroughly uninstall unwanted apps. * [Battery Guardian](https://www.dssw.co.uk/batteryguardian) - Battery Guardian offers an easy way to remember to deplete your MacBook battery. Depleting your battery helps extend the battery's life. * [BetterTouchTool](https://www.folivora.ai/downloads) - BetterTouchTool is a great, feature packed app that allows you to customize various input devices on your Mac. * [CleanMyMac](http://cleanmymac.com) - CleanMyMac can helps you to clean your Mac, monitor its health, optimize it for speed, and more. * [Fluid](http://fluidapp.com) - Turn Your Favorite Web Apps into Real Mac Apps. * [Garbage Truck](http://www.macupdate.com/app/mac/47923/garbage-truck) - Automate emptying of trash on your Mac. * [HyperDock](https://bahoom.com/hyperdock/) - Windows 7 style preview of open windows/applications and more. * [iTerm2](https://www.iterm2.com) - A terminal emulator for Mac OS X that does amazing things. * [Knock](http://www.knocktounlock.com) - Unlock your Mac faster and more securely than ever. * [MacID](http://macid.co) - Unlock your Mac with just your fingerprint.™ * [Onyx](http://www.titanium.free.fr/onyx.html) - The multifunction Utility. * [Paste](http://pasteapp.me/) - Keep track of your clipboard. * [Spectacle](http://spectacleapp.com) - Window control with simple and customizable keyboard shortcuts. * [Kap](https://getkap.co/) - Kap. Capture your screen * [Muzzle](https://muzzleapp.com) - A simple mac app to silence embarrassing notifications while screensharing. ## Security *Encryption, Password Manager and other tools for your safety* * [1Password](https://agilebits.com/onepassword/mac) - A comprehensive password manager. * [Boxcryptor](https://www.boxcryptor.com) - A tool to encript your sensitive files in your cloud storage. * [Dashlane](https://www.dashlane.com/) - An another password manager & secure digital wallet. * [Pareto Security](https://paretosecurity.app/) - A MenuBar app to automatically audit your Mac for basic security hygiene. ## Text Editors *A type of program used for editing plain text files.* * [Atom](https://atom.io) - A hackable text editor for the 21st Century. * [BBEdit](http://www.barebones.com/products/bbedit/) - It doesn’t suck.® * [Coda2](https://panic.com/coda) - Your code for the web. * [Emacs](https://www.emacswiki.org/emacs/EmacsForMacOS) - Emacs is console based editor and highly customizable. * [Sublime Text 3](http://www.sublimetext.com/3) - A sophisticated text editor for code, markup and prose. * [TextMate](https://macromates.com) - The Missing Editor for Mac OS X. * [Vim](http://www.vim.org/) - Vim is a highly configurable console based editor aimed at efficient text creation and modification. ## Window/Tiling managers *A type of background app to let you manage your windows.* * [Amethyst](https://ianyh.com/amethyst/) - Tiling window manager for macOS along the lines of xmonad. * [Divvy](https://mizage.com/divvy/) - Window management at its finest. * [Magnet](https://magnet.crowdcafe.com) - Magnet keeps your workspace organized. * [Moom](https://manytricks.com/moom/) - Move and zoom windows. * [Mosaic](https://www.lightpillar.com/mosaic.html) - Optimise your workflow | Save Time | Boost Productivity. * [Spectacle](https://www.spectacleapp.com) - Move and resize windows with ease. ## Authors **Philipp Bräutigam** + [github/xyNNN](https://github.com/xyNNN) + [twitter/pbraeutigam](http://twitter.com/pbraeutigam) ... and [Contributors](https://github.com/xyNNN/awesome-mac/graphs/contributors)! ## License [![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/) To the extent possible under law, [Philipp Bräutigam](http://www.philipp-braeutigam.de) has waived all copyright and related or neighboring rights to this work.
{ "repo_name": "xyNNN/awesome-mac", "stars": "129", "repo_language": "None", "file_name": "README.md", "mime_type": "text/plain" }
package main /* Gets greatest common divisor of a and b */ func getGCD(a, b int) int { for a != b { if a > b { a -= b } else { b -= a } } return a }
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
package main import ( "io/ioutil" "os" "runtime" "strings" ) /* Get the name of OS/Distro or piped input */ func getDisplayText() (displayText string) { /* Check for piped input */ fi, _ := os.Stdin.Stat() if (fi.Mode() & os.ModeCharDevice) == 0 { bytes, _ := ioutil.ReadAll(os.Stdin) return string(bytes) } /* In case of no piped input, get OS name */ f, err := ioutil.ReadFile("/etc/os-release") if err != nil { return strings.ToTitle(runtime.GOOS) } osRelease := make(map[string]string) for _, l := range strings.Split(string(f), "\n") { kv := strings.SplitN(l, "=", 2) if len(kv) != 2 { continue } osRelease[kv[0]] = strings.Trim(kv[1], `"`) } if v, ok := osRelease["NAME"]; ok { return v } if v, ok := osRelease["PRETTY_NAME"]; ok { return v } return strings.ToTitle(runtime.GOOS) }
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
module github.com/ameyrk99/dvdts go 1.18 require github.com/gizak/termui/v3 v3.1.0 require ( github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/nsf/termbox-go v1.1.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect )
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
/* * DVDTS - DVD like screensaver for term * Github repo: https://github.com/ameyrk99/dvdts */ package main import ( "flag" "fmt" "log" "math" "strings" "time" ui "github.com/gizak/termui/v3" "github.com/gizak/termui/v3/widgets" ) const ( termOffset = 2 ) var ( termWidth = 0 termHeight = 0 xEdge = 0 yEdge = 0 /* Top left co-ordinates of the text */ px = 1 py = 1 /* Text size */ pTextLength = 0 pTextHeight = 0 xAdd = true yAdd = true colors = []string{"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"} colorsPos = -1 displayText string allColors = true textSpeed int textColor string ) func main() { log.SetPrefix("") /* Get custom text color */ flag.StringVar(&textColor, "c", "blue", "color for the bouncing text") /* Get text speed */ flag.IntVar(&textSpeed, "s", 10, "speed of text [more is slower]") /* Get whether to cycle through colors */ flag.BoolVar(&allColors, "a", false, "cycle through terminal colors") /* Get OS/distro name */ flag.StringVar(&displayText, "t", "<OS name>", "custom text to display") flag.Parse() /* Not in flag StringVar func incase input was piped */ displayText = getDisplayText() /* Get text color */ for i, c := range colors { if textColor == c { colorsPos = i break } } if colorsPos == -1 { log.Fatalf("Colors available:\n%s\n", strings.Join(colors, " ")) } /* Initialize termui */ if err := ui.Init(); err != nil { log.Fatalf("failed to initialize termui: %v", err) } defer ui.Close() /* Make the text widget */ p := widgets.NewParagraph() p.Border = false p.Text = fmt.Sprintf("[%s](fg:%s,mod:bold)", displayText, textColor) termWidth, termHeight = ui.TerminalDimensions() /* Respect multiline string */ var lines = strings.Split(displayText, "\n") for _, line := range lines { if len(line) > pTextLength { pTextLength = len(line) } } pTextHeight = len(lines) /* Top left doesn't go all the way to the end of terminal due to text wrap, hence new edges */ xEdge = termWidth - pTextLength - termOffset yEdge = termHeight - pTextHeight - termOffset px, py = generateRandomCoords() gcd := float64(getGCD(xEdge, yEdge)) /* Start loop only if GCD for terminal dimensions isn't 1.0 */ if gcd != 1.0 { for { /* The below condition needs to be met for thing to hit the corner */ /* Math from http://prgreen.github.io/blog/2013/09/30/the-bouncing-dvd-logo-explained/ */ if math.Mod(math.Abs(float64(px-py)), gcd) == 0 { /* If it is met, recalculate starting coordinates */ px, py = generateRandomCoords() } else { break } } } drawText(&p) ui.Render(p) uiEvents := ui.PollEvents() /* ticker to update the position/color of the text after fixed interval */ ticker := time.NewTicker(time.Duration(textSpeed) * 10 * time.Millisecond).C for { select { case e := <-uiEvents: switch e.ID { case "q", "<C-c>": /* Quit the program on q or Ctrl+c */ return case "a": /* Switch all colors on/off in the program */ allColors = !allColors } case <-ticker: drawText(&p) ui.Render(p) } } }
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
# Gopkg.toml example # # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html # for detailed Gopkg.toml documentation. # # required = ["github.com/user/thing/cmd/thing"] # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] # # [[constraint]] # name = "github.com/user/project" # version = "1.0.0" # # [[constraint]] # name = "github.com/user/project2" # branch = "dev" # source = "github.com/myfork/project2" # # [[override]] # name = "github.com/x/y" # version = "2.4.0" # # [prune] # non-go = false # go-tests = true # unused-packages = true [prune] go-tests = true unused-packages = true [[constraint]] name = "github.com/gizak/termui" version = "3.0.0"
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc= github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/nsf/termbox-go v1.1.1 h1:nksUPLCb73Q++DwbYUBEglYBRPZyoXJdrj5L+TkjyZY= github.com/nsf/termbox-go v1.1.1/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
# DVDTS - DVD Term Screensaver DVD Screensaver style screensaver for terminal. Instead of the logo of DVD, it uses the distro name/os name or custom text.<br> The text does not hit the corner of terminal perfectly only if GCD (greatest common divisor) for terminal dimensions isn't 1. ## Preview Preview shows ``` dvdts -c yellow -t "Hello, World" -s 7 # and cowsay Hello, World | dvdts -a ``` ![preview gif](readme_assets/dvdts.gif) ## Usage ### Example ``` dvdts -a -c green -s 5 ``` This will start the colors from green, cycle because of `a` flag, and text will move twice as fast. ### Flags ``` -a cycle through terminal colors -c string color for the bouncing text (default "blue") -s int speed of text [more is slower] (default 10) -t string text to display (default "<OS name>") ``` ### Piping input DVDTS supports piped input. For example ``` cowsay Hello, World | dvdts -a ``` ### In-use bindings |Key(s) |Action | |-----------|----------| |q or Ctrl+c|Quit | |a|Toggle color cycling| ## Build Dependencies - [Go](https://golang.org/) - [termui](https://github.com/gizak/termui)
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
package main import ( "fmt" "math/rand" "time" "github.com/gizak/termui/v3/widgets" ) /* Generate random initial coordinates for the text */ func generateRandomCoords() (xCoord, yCoord int) { rand.Seed(int64(time.Now().Nanosecond())) min := 1 max := termHeight - pTextHeight - 3 yCoord = rand.Intn(max-min) + min max = termWidth - pTextLength - 3 xCoord = rand.Intn(max-min) + min return xCoord, yCoord } /* Update the color of text when it hits the corner if all colors is used */ func updateTextColor(p **widgets.Paragraph) { colorsPos++ (*p).Text = fmt.Sprintf("[%s](fg:%s,mod:bold)", displayText, colors[colorsPos]) /* If the last we're at the last element in the list, begin from start */ if colorsPos == len(colors)-1 { colorsPos = 0 } } /* Draw the text on termui */ func drawText(p **widgets.Paragraph) { updateColor := false /* Did text hit the bottom or top of the term? */ if py == yEdge { yAdd = false updateColor = true } else if py == 0 { yAdd = true updateColor = true } /* Did the text hit the right or left of term? */ if px == xEdge { xAdd = false updateColor = true } else if px == 0 { xAdd = true updateColor = true } /* Update color on hit and when all a flag is used */ if updateColor && allColors { updateTextColor(p) } if yAdd { py++ } else { py-- } if xAdd { px++ } else { px-- } (*p).SetRect(px, py, termWidth, termHeight) }
{ "repo_name": "ameyrk99/dvdts", "stars": "36", "repo_language": "Go", "file_name": "update_text.go", "mime_type": "text/plain" }
#!/usr/bin/env ruby $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib'))) require 'rubygems' begin require 'rakefile' # http://github.com/bendiken/rakefile rescue LoadError => e end require 'trinity'
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
* Arto Bendiken <[email protected]> * Josh Huckabee <[email protected]> * Ben Lavender <[email protected]>
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
0.0.1
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
Trinity ======= This is a minimalistic web framework for publishing [Linked Data](http://linkeddata.org/). * <http://github.com/datagraph/trinity> Usage ----- To start up a Trinity server on <http://localhost:3000/>, invoke the installed `trinity` program with an RDF input file describing the resources to publish. An example N-Triples file is included as `etc/localhost.nt`: % trinity etc/localhost.nt >> Thin web server (v1.2.5 codename This Is Not A Web Server) >> Debugging ON >> Maximum connections set to 1024 >> Listening on 0.0.0.0:3000, CTRL+C to stop 127.0.0.1 - - [15/Jan/2010 22:33:44] "GET /hello HTTP/1.1" 200 Hints ----- Since [RDF.rb](http://rdf.rubyforge.org/) currently only supports the N-Triples serialization format, make sure that the input file to Trinity is in that format. You can convert RDF/XML to N-Triples with the [`rapper`](http://librdf.org/raptor/rapper.html) utility: % rapper -i rdfxml -o ntriples input.rdf > output.nt You can convert Turtle to N-Triples as follows: % rapper -i turtle -o ntriples input.ttl > output.nt Documentation ------------- * <http://trinity.datagraph.org/> Dependencies ------------ * [RDF.rb](http://gemcutter.org/gems/rdf) (>= 0.0.9) * [RDF::JSON](http://gemcutter.org/gems/rdf-json) (>= 0.0.1) * [Addressable](http://gemcutter.org/gems/addressable) (>= 2.1.1) * [Mime::Types](http://gemcutter.org/gems/mime-types) (>= 1.16) * [Rack](http://gemcutter.org/gems/rack) (>= 1.1.0) * [Thin](http://gemcutter.org/gems/thin) (>= 1.2.5) * [Markaby](http://gemcutter.org/gems/markaby) (>= 0.5) Installation ------------ The recommended installation method is via RubyGems. To install the latest official release from Gemcutter, do: % [sudo] gem install trinity Download -------- To get a local working copy of the development repository, do: % git clone git://github.com/datagraph/trinity.git Alternatively, you can download the latest development version as a tarball as follows: % wget http://github.com/datagraph/trinity/tarball/master Resources --------- * <http://trinity.datagraph.org/> * <http://github.com/datagraph/trinity> * <http://gemcutter.org/gems/trinity> * <http://raa.ruby-lang.org/project/trinity/> * <http://www.ohloh.net/p/trinity> Authors ------- * [Arto Bendiken](mailto:[email protected]) - <http://ar.to/> * [Josh Huckabee](mailto:[email protected]) - <http://joshhuckabee.com/> * [Ben Lavender](mailto:[email protected]) - <http://bhuga.net/> License ------- Trinity is free and unencumbered public domain software. For more information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
#!/usr/bin/env ruby $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))) require 'trinity' abort "Usage: #{File.basename($0)} site.rdf" if ARGV.empty? RDF::Repository.load(ARGV.shift) do |repository| Trinity::Server.start('0.0.0.0', 3000, repository, :debug => true) end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require 'erb' require 'addressable/uri' require 'mime/types' require 'rack' require 'rdf' require 'rdf/ntriples' require 'trinity/version' module Trinity autoload :Application, 'trinity/core/application' autoload :Builder, 'trinity/core/builder' autoload :Handler, 'trinity/core/handler' autoload :Plugin, 'trinity/core/plugin' autoload :Renderer, 'trinity/core/renderer' autoload :Resource, 'trinity/core/resource' autoload :Server, 'trinity/core/server' autoload :Theme, 'trinity/core/theme' autoload :Widget, 'trinity/core/widget' end require 'trinity/theme/data' require 'trinity/admin' require 'trinity/analytics' require 'trinity/bitcache'
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## # Administration plugin for Trinity. class Admin < Trinity::Plugin URI = RDF::URI.new('http://gemcutter.org/gems/trinity-admin') NS = RDF::Vocabulary.new("#{URI}#") def self.initialize!(application) application.map('/trinity.css', CSS) application.map('/trinity.js', JS) end ## class JS < Trinity::Handler def call(env) js_dir = File.expand_path(File.join(File.dirname(__FILE__), 'admin', 'js')) response = [] # Include jquery File.open(File.join(js_dir, 'jquery-1.4.1.min.js'), 'r').each_line do |line| response << line end [200, {}, response] end end ## class CSS < Trinity::Handler def call(env) [200, {}, ['/* TODO */']] end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## # Bitcache plugin for Trinity. # # @see http://bitcache.org/ class Bitcache < Trinity::Plugin URI = RDF::URI.new('http://gemcutter.org/gems/trinity-bitcache') NS = RDF::Vocabulary.new("#{URI}#") def self.initialize!(application) require 'bitcache' unless defined?(::Bitcache) application.map('/bitcache', Server) end ## class Server < Trinity::Handler def call(env) [200, {'Content-Type' => 'text/plain'}, ['TODO']] end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity module VERSION MAJOR = 0 MINOR = 0 TINY = 1 EXTRA = nil STRING = [MAJOR, MINOR, TINY].join('.') STRING << "-#{EXTRA}" if EXTRA ## # @return [String] def self.to_s() STRING end ## # @return [String] def self.to_str() STRING end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## # Google Analytics plugin for Trinity. # # @see http://www.google.com/analytics/ class Analytics < Trinity::Plugin URI = RDF::URI.new('http://gemcutter.org/gems/trinity-analytics') NS = RDF::Vocabulary.new("#{URI}#") def footer(html) # TODO end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require 'markaby' module Trinity ## class Builder < Markaby::Builder # TODO end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## class Resource include RDF::Enumerable attr_reader :url attr_reader :data def initialize(url, data = []) @url, @data = RDF::URI.new(url.to_s), data end def found? !empty? end def each(&block) data.each(&block) end def render(env) Renderer.for(env).new(env).render(self) end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## # Base class for Trinity plugins. class Plugin extend Enumerable ## # Enumerates loaded Trinity plugin classes. # # @yield [klass] # @yieldparam [Class] # @return [Enumerator] def self.each(&block) @@subclasses.each(&block) end ## # Invokes the given `method` on all loaded plugin classes. # # @return [void] def self.invoke(method, *args, &block) @@subclasses.each do |plugin| plugin.send(method, *args, &block) if plugin.respond_to?(method) end end ## # @param [Hash{Symbol => Object} options def initialize(options = {}) # implement this in subclasses end protected ## # @abstract def self.install! # implement this in subclasses that need it end ## # @abstract def self.uninstall! # implement this in subclasses that need it end ## # @abstract def self.enable! # implement this in subclasses that need it end ## # @abstract def self.disable! # implement this in subclasses that need it end ## # @abstract def self.initialize!(application) # implement this in subclasses that need it end private @@subclasses = [] # @private def self.inherited(child) # @private @@subclasses << child unless @@subclasses.include?(child) super end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## # Base class for Trinity themes. class Theme < Trinity::Plugin extend Enumerable ## # Enumerates loaded Trinity theme classes. # # @yield [klass] # @yieldparam [Class] # @return [Enumerator] def self.each(&block) @@subclasses.each(&block) end private @@subclasses = [] # @private def self.inherited(child) # @private @@subclasses << child unless @@subclasses.include?(child) super end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## class Application < Trinity::Handler ## # @param [RDF::Repository] repository # @param [Hash{Symbol => Object}] options def initialize(repository, options = {}, &block) this = self @repository = repository @application = Rack::Builder.new do map(options[:path] || '/') do use Trinity::Handler::Initializer, repository, options use Trinity::Handler::Acceptor, repository use Trinity::Handler::Aliaser, repository use Trinity::Handler::Redirector, repository use Trinity::Handler::Loader, repository use Trinity::Handler::Reasoner, repository run Trinity::Handler::Dispatcher.new(this, repository) end end @options = options Trinity::Plugin.invoke(:initialize!, self) end ## # Defines a URL path handler. # # @overload # @param [String, #to_s] path # @yield # # @overload # @param [String, #to_s] path # @param [Class, Handler, Proc] handler # # @return [void] def map(path, handler = nil, &block) case handler when Class application.map(path.to_s) { run handler.new(self) } when Handler, Proc application.map(path.to_s) { run handler } else application.map(path.to_s, &block) end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## # Base class for widgets. class Widget extend Enumerable include RDF ## # Enumerates loaded Trinity widget classes. # # @yield [klass] # @yieldparam [Class] # @return [Enumerator] def self.each(&block) @@subclasses.each(&block) end ## # Returns a widget class for the given RDF `property`. # # @param [RDF::URI] property # @return [Class] def self.for(property) # TODO: ultimately this should not be hardcoded. case property when RDFS.label, DC.title TextField when RDFS.comment, DC.description TextArea end end attr_accessor :object attr_reader :options ## # @param [RDF::Value] object # @param [Hash{Symbol => Object}] options # @option options [RDF::URI] :predicate (nil) # @option options [Boolean] :editable (false) def initialize(object, options = {}) @object = object @options = options end ## # @param [Builder] html # @return [void] # @abstract def content(html) html.text(ERB::Util.html_escape(object.inspect)) end ## # @return [RDF::URI] def predicate options[:predicate] end ## # @return [Boolean] def editable? options[:editable] == true end private @@subclasses = [] # @private def self.inherited(child) # @private @@subclasses << child unless @@subclasses.include?(child) super end require 'trinity/core/widget/text_field' require 'trinity/core/widget/text_area' end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require 'thin' module Trinity class Server def self.start(host, port, repository, options = {}, &block) Thin::Logging.debug = true if options[:debug] Thin::Server.start(host || '0.0.0.0', port || 3000, Trinity::Application.new(repository)) end private_class_method :new end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## class Renderer extend Enumerable ## # Enumerates known renderer classes. # # @yield [klass] # @yieldparam [Class] # @return [Enumerator] def self.each(&block) @@subclasses.each(&block) end ## # Finds a renderer class based on the value of the `HTTP_ACCEPT` header. # # @param [Hash{String => Object}] env # @return [Class] def self.for(env) # TODO: add support for wildcards and explicit weights. if env['HTTP_ACCEPT'] env['HTTP_ACCEPT'].split(',').each do |content_type_and_weight| content_type, weight = content_type_and_weight.split(';') each do |klass| return klass if klass.content_types.include?(content_type) end end end Renderer::RDF # the default end ## # Retrieves or defines the default MIME content type for this renderer class. # # @overload # @return String # # @overload # @param [String, #to_s] type # @return [void] # # @return [void] def self.content_type(type = nil) if type.nil? @content_types.first rescue nil else @content_types ||= [] @content_types << type.to_s end end ## # Retrieves or defines the MIME content types for this renderer class. # # @overload # @return [Array<String>] # # @overload # @param [Array<String>, #to_a] types # @return [void] # # @return [void] def self.content_types(*types) if types.empty? @content_types || [] else @content_types = types.to_a.map(&:to_s) end end attr_reader :env attr_reader :resource ## # @param [Hash{String => Object}] env def initialize(env) @env = env end ## # Returns the RDF subject for this request. # # @return [RDF::URI] def subject env['trinity.subject'] end ## # Returns the RDF data for this request. # # @return [RDF::Queryable] def data env['trinity.data'] end def render(resource, options = {}) @resource = resource [status, headers, [content]] end ## # Returns the HTTP headers for the response. # # @return [Hash{String => String}] def headers if content_type = self.class.content_type {'Content-Type' => content_type} else {} end end ## # Returns the HTTP status code for the response. # # @return [Integer] def status 200 # OK end ## # Returns the HTTP content for the response. # # @return [String] # @abstract def content raise NotImplementedError end private @@subclasses = [] # @private def self.inherited(child) # @private @@subclasses << child unless @@subclasses.include?(child) super end require 'trinity/core/renderer/rdf' require 'trinity/core/renderer/html' end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
module Trinity ## class Handler autoload :Initializer, 'trinity/core/handler/initializer' autoload :Acceptor, 'trinity/core/handler/acceptor' autoload :Aliaser, 'trinity/core/handler/aliaser' autoload :Redirector, 'trinity/core/handler/redirector' autoload :Loader, 'trinity/core/handler/loader' autoload :Reasoner, 'trinity/core/handler/reasoner' autoload :Dispatcher, 'trinity/core/handler/dispatcher' autoload :Admin, 'trinity/core/handler/admin' attr_reader :application attr_reader :repository def initialize(application, repository = nil) @application = application @repository = repository end def call(env) application.call(env) end ## # Queries the repository for statements matching the given pattern. # # @param [RDF::Query, RDF::Statement, Array(RDF::Value)] pattern def query(*args, &block) if block_given? repository.query(*args, &block) else repository.query(*args).extend(RDF::Enumerable) end end def redirect(url) [301, {'Content-Type' => 'text/plain', 'Location' => url}, "301 Moved Permanently to #{url}"] end def not_found [404, {'Content-Type' => 'text/plain'}, '404 Resource Not Found'] end def internal_error(message = nil) [500, {'Content-Type' => 'text/plain'}, message || "Unspecified internal server error"] end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Handler ## # URL aliasing support. # # If a resource has been declared to be the same as another resource, # changes the current request subject to be that resource instead. # # @see http://www.w3.org/TR/owl-ref/#sameAs-def class Aliaser < Trinity::Handler def call(env) # NB: if more than one matching statement is found, we will # effectively use the last found one: subjects = [env['trinity.subject']] object = nil while statement = query([env['trinity.subject'], RDF::OWL.sameAs]).first do object = statement.object return internal_error("Looping aliases") if subjects.include? object subjects << object env['trinity.subject'] = object end super end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Handler ## # Data loader. # # Loads all RDF statements about the current subject into the Rack # environment, where they are available to subsequent handlers. class Loader < Trinity::Handler ## # @param [Hash{String => Object}] env # @return [void] def call(env) load_data(env) load_plugins(env) super end ## # @param [Hash{String => Object}] env # @return [void] def load_data(env) # FIXME: remove the .extend(...) after RDF.rb 0.0.9 is released: env['trinity.data'] = query([env['trinity.subject']]).extend(RDF::Enumerable, RDF::Queryable) end ## # @param [Hash{String => Object}] env # @return [void] def load_plugins(env) # FIXME: implement RDF::URI#each_parent to make this easier. require 'pathname' unless defined?(Pathname) if subject = RDF::URI.new(env['trinity.subject'].to_s) # FIXME: RDF::URI.dup path = Pathname.new(subject.path) loop do # TODO: we need a more appropriate predicate than doap:implements. query([subject, ::RDF::DOAP.implements]) do |statement| load_plugin(statement.object) end break if path.to_s == '/' || path.to_s.empty? subject.path = (path = path.parent).to_s end end end ## # @param [RDF::URI] uri # @return [void] def load_plugin(uri) begin require uri.to_s['http://gemcutter.org/gems/'.size..-1].gsub('-', '/') # FIXME rescue LoadError => e # TODO: we should log the missing gem somewhere. end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Handler ## class Dispatcher < Trinity::Handler def call(env) if (resource = Trinity::Resource.new(env['trinity.subject'], env['trinity.data'])).found? resource.render(env) else not_found end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Handler ## # Initialization. # # Initializes the appropriate Rack environment variables with a valid # resource URI that will be used as the initial subject during the current # request. class Initializer < Trinity::Handler attr_reader :options def initialize(application, repository = nil, options = {}) @options = options super(application, repository) end def call(env) set_base_uri(env) set_resource_uri(env) set_subject_uri(env) super end def set_base_uri(env) env['trinity.base'] = RDF::URI.new(Addressable::URI.new({ :scheme => env['rack.url_scheme'], :host => options[:host] || env['SERVER_NAME'], :port => options[:port] || env['SERVER_PORT'], :path => '/', })) end def set_resource_uri(env) env['trinity.resource'] = RDF::URI.new(Addressable::URI.new({ :scheme => env['rack.url_scheme'], :host => options[:host] || env['SERVER_NAME'], :port => options[:port] || env['SERVER_PORT'], :path => env['REQUEST_URI'] || env['PATH_INFO'], :query => env['QUERY_STRING'].to_s.size > 0 ? env['QUERY_STRING'] : nil, })) end def set_subject_uri(env) env['trinity.subject'] = env['trinity.resource'] end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Handler ## class Reasoner < Trinity::Handler def call(env) super # TODO end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Handler ## # File extension support. # # Determines if a resource was requested with a specific file extension # (e.g. `http://resource/uri.xml` or `http://resource/uri.json`) and sets # the current Trinity subject to to the specified URI minus the file # extension, as well as rewriting the HTTP_ACCEPT header which is used # later for rendering. class Acceptor < Trinity::Handler def call(env) if query([env['trinity.subject']]).empty? subject = env['trinity.subject'].to_s if extension = File.extname(subject) types = MIME::Types.type_for(File.basename(subject)) subject = subject[0...-extension.size] unless query([RDF::URI.new(subject)]).empty? || types.empty? env['trinity.subject'] = RDF::URI.new(subject) env['HTTP_ACCEPT'] = env['HTTP_ACCEPT'].split(',').unshift(types.first.to_s).join(',') if env['HTTP_ACCEPT'] end end end super end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Handler ## # URL redirection support. # # If a resource has a "see also" property, this handler performs a # redirect to the value of that property. # # @see http://www.w3.org/TR/2000/CR-rdf-schema-20000327/#s2.3.4 class Redirector < Trinity::Handler def call(env) subjects = [env['trinity.subject']] object = nil while statement = query([env['trinity.subject'], RDF::RDFS.seeAlso]).first do object = statement.object return internal_error("Looping redirects") if subjects.include? object subjects << object env['trinity.subject'] = object end return redirect(object.to_s) if object super end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require 'markaby' class Trinity::Renderer ## # HTML renderer. class HTML < Trinity::Renderer content_type 'application/xhtml+xml' content_type 'text/html' attr_reader :builder def html(&block) if block_given? case block.arity when 1 then block.call(builder) else builder.instance_eval(&block) end end end ## # @return [Class] def theme_class require theme_path Trinity::Theme::Data # FIXME end ## # @return [String] def theme_path File.join('trinity', 'theme', theme_name) end ## # @return [String] def theme_name 'data' # TODO: query RDF repository end ## # Returns the HTTP content for the response. # # @return [String] def content require theme_path this = self # needed because Markaby is based on `instance_eval` @builder = Trinity::Builder.new(:indent => 2) @builder.instruct! @builder.declare! :DOCTYPE, :html, :PUBLIC, "-//W3C//DTD XHTML+RDFa 1.0//EN", "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd" @builder.html(:xmlns => 'http://www.w3.org/1999/xhtml') do head { this.render_html_head } body { this.render_html_body } end @builder.to_s end ## # @param [Builder] html # @return [void] def render_html_head builder.title 'Trinity' # FIXME Trinity::Plugin.invoke(:render_html_head, self) end ## # @param [Builder] html # @return [void] def render_html_body Trinity::Plugin.invoke(:render_html_body, self) end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Renderer ## # RDF renderer. class RDF < Trinity::Renderer content_type 'text/plain' content_type 'text/turtle' content_type 'text/n3' include ::RDF def headers super.merge({'Content-Type' => 'text/plain'}) # FIXME end def content RDF::Writer.for(:ntriples).buffer do |writer| # FIXME resource.each { |statement| writer << statement } end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Widget ## # Text field widget. class TextField < Trinity::Widget ## # @param [Builder] html # @return [void] def content(html) if editable? html.input(:type => :text, :name => predicate.to_s, :value => object.value.to_s) else html.text(object.value.to_s) end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
class Trinity::Widget ## # Text area widget. class TextArea < Trinity::Widget ## # @param [Builder] html # @return [void] def content(html) object = self.object if editable? html.textarea(:name => predicate.to_s) { html.text object.value.to_s } else html.text(object.value.to_s) end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require 'markaby' class Trinity::Theme ## # Theme plugin for Trinity. class Data < Trinity::Theme URI = RDF::URI.new('http://gemcutter.org/gems/trinity-theme') NS = RDF::Vocabulary.new("#{URI}#") ## # @param [Application] application # @return [void] def self.initialize!(application) application.map('/theme/data.css', CSS) application.map('/theme/data.js', JS) end ## # @param [Renderer] renderer # @return [void] def self.render_html_head(renderer) renderer.html do link :type => 'text/css', :rel => :stylesheet, :media => 'screen', :href => '/theme/data.css' script :type => 'text/javascript', :language => :javascript, :src => '/theme/data.js' end end ## # @param [Renderer] renderer # @return [void] def self.render_html_body(renderer) theme = self renderer.html do div(:id => :header) do # TODO end div(:id => :content) do table(:id => :description) do thead do th { text 'Property' } # TODO: L10n th { text 'Value' } # TODO: L10n end tbody do renderer.data.each do |statement| tr(:class => statement) do td(:class => :predicate) do theme.render_predicate(renderer, statement) end td(:class => :object) do theme.render_object(renderer, statement) end end end end end end div(:id => :footer) do # TODO end end end ## # @param [Renderer] renderer # @param [RDF::Statement] statement # @return [String] def self.render_predicate(renderer, statement) render_uri(renderer, statement.predicate) end ## # @param [Renderer] renderer # @param [RDF::Statement] statement # @return [String] def self.render_object(renderer, statement) case value = statement.object when RDF::Literal render_literal(renderer, value) when RDF::URI render_uri(renderer, value) when RDF::Node render_node(renderer, value) else value = escape_string(value.inspect) end end ## # @param [Renderer] renderer # @param [RDF::Literal] literal # @return [String] def self.render_literal(renderer, literal) value = escape_string(literal.value.to_s) case when literal.datatyped? type = literal.datatype value = case type when XSD.string, nil value else value # TODO end renderer.html do span(:class => 'literal') { value } # FIXME end when literal.language? lang = escape_string(literal.language.to_s) renderer.html do span(:class => 'literal', 'xml:lang' => lang, :title => lang) { value } end else renderer.html do span(:class => 'literal') { value } end end end ## # @param [Renderer] renderer # @param [RDF::URI] uri # @return [String] def self.render_uri(renderer, uri) value = escape_string(uri.to_s) title = value # Shorten the URI into a CURIE/QName, if possible: %w(cc dc doap exif foaf http owl rdf rdfs rss sioc skos wot xhtml xsd).each do |prefix| vocab = RDF.const_get(prefix.upcase) if uri.to_s.index(vocab.to_s) == 0 local_name = uri.to_s[vocab.to_s.size..-1] title = [prefix, local_name].join(':') end end renderer.html do a(:href => value) { title } end end ## # @param [Renderer] renderer # @param [RDF::Node] node # @return [String] def self.render_node(renderer, node) value = escape_string(node.to_s) renderer.html do text(value) end end ## # @param [String] string # @return [String] def self.escape_string(string) ERB::Util.html_escape(string) end ## class CSS < Trinity::Handler def call(env) [200, {'Content-Type' => 'text/css'}, [content]] end def content File.read(File.join(File.dirname(__FILE__), 'data.css')) end end ## class JS < Trinity::Handler def call(env) [200, {'Content-Type' => 'text/javascript'}, [content]] end def content File.read(File.join(File.dirname(__FILE__), 'data.js')) end end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require File.dirname(__FILE__) + '/spec_helper' describe 'The Hello World Dataset' do include Rack::Test::Methods def app repository = RDF::Repository.load(fixture('hello.nt')) Trinity::Application.new(repository) end context "at the root" do before :all do get '/' end it "should be http 200" do last_response.status.should be 200 end end context "/hello" do before :all do get '/hello' end it "should include the text 'Hello, World!'" do last_response.body.should include 'Hello, world!' end end context "a non-existent page" do before :all do get '/doesnt-exist' end it "should be a http 404" do last_response.status.should be 404 end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require File.dirname(__FILE__) + '/spec_helper' describe 'The Alias-Redirect dataset' do include Rack::Test::Methods def app repository = RDF::Repository.load(fixture('alias_redirect.nt')) Trinity::Application.new(repository) end context "at the root" do before :all do get '/' end it "should be http 200" do last_response.status.should == 200 end end context "/hello" do before :all do get '/hello' end it "should be http 200" do last_response.status.should == 200 end end context "/hello/alias" do before :all do get '/hello/alias' end it "should be http 200" do last_response.status.should == 200 end it "should be the same as /hello" do alias_body = last_response.body get '/hello' last_response.body.should == alias_body end end context "/hello/redirect" do before :all do get '/hello/redirect' end it "should be http 301" do last_response.status.should == 301 end it "should redirect to /hello" do last_response.should redirect_to 'http://example.org:80/hello' end end context "/hello/two-redirects" do before :all do get '/hello/two-redirects' end it "should be http 301" do last_response.status.should == 301 end it "should redirect to /hello" do last_response.should redirect_to 'http://example.org:80/hello' end end context "/hello/two-aliases" do before :all do get '/hello/two-aliases' end it "should be http 200" do last_response.status.should == 200 end it "should be the same as /hello" do alias_body = last_response.body get '/hello' last_response.body.should == alias_body end end context "/hello/alias-loop" do before :all do get '/hello/alias-loop' end #FIXME: this is maybe not what we want? should we merge results? it "should return http 500" do last_response.status.should == 500 end end context "/hello/redirect-loop" do before :all do get '/hello/redirect-loop' end it "should return http 500" do last_response.status.should == 500 end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
require File.dirname(__FILE__) + '/spec_helper' describe 'Content-type handling (using the hello dataset)' do include Rack::Test::Methods def app repository = RDF::Repository.load(fixture('hello.nt')) Trinity::Application.new(repository) end context "at the root" do before :all do get '/' end it "should be http 200 and application/xhtml+xml" do last_response.should be_ok_and_of_type 'application/xhtml+xml' end end context "/hello" do before :all do get '/hello' end it "should have a content type of application/xhtml+xml" do last_response.should be_ok_and_of_type 'application/xhtml+xml' end end context "/hello.txt" do before :all do get '/hello.txt' end it "should have a content-type of text/plain" do last_response.should be_ok_and_of_type 'text/plain' end it "should have 2 n-triple statements about hello" do last_response.should only_be_about "http://example.org:80/hello", 2 end end context "/hello with an accept header of plain/text" do before :all do header 'Accept', 'text/plain' get '/hello' end it "should have a content-type of text/plain" do last_response.should be_ok_and_of_type 'text/plain' end end context "/hello with an accept header of text/html" do before :all do header 'Accept', 'text/html' get '/hello' end it "should have a content-type of text/html" do last_response.should be_ok_and_of_type 'text/html' end end context "/hello with an accept header of application/xhtml" do before :all do header 'Accept', 'application/xhtml' get '/hello' end it "should have a content-type of application/xhtml" do last_response.should be_ok_and_of_type 'application/xhtml' end end context "/hello with an accept header of application/xhtml+xml" do before :all do header 'Accept', 'application/xhtml+xml' get '/hello' end it "should have a content-type of application/xhtml+xml" do last_response.should be_ok_and_of_type 'application/xhtml+xml' end end context "a non-existent page" do before :all do get '/doesnt-exist' end it "should be a http 404" do last_response.status.should be 404 end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..','lib'))) require 'trinity' require 'rack/test' def fixture(filename) File.join(File.dirname(__FILE__), 'fixtures', filename) end # a response should be an ntriples representation of a resource, with no other resources, and # an optional expected number of resources Spec::Matchers.define :only_be_about do |subject, expected_count| match do |actual| count = 0 subject = RDF::URI.new subject RDF::NTriples::Reader.new(actual.body.to_s).each do |statement| statement.subject.should == subject count += 1 end count.should == expected_count if expected_count end end # check content type of a response Spec::Matchers.define :be_of_type do |expected_type| match do |actual| actual.headers['Content-type'].should == expected_type end end Spec::Matchers.define :be_ok_and_of_type do |expected_type| match do |actual| actual.status.should be 200 actual.should be_of_type expected_type end end Spec::Matchers.define :redirect_to do |expected_location| match do |response| response.headers['Location'].should == expected_location end end describe 'The helpers' do context 'the fixture helper' do it "should create a filename based on a fixture name" do fixture('hello.nt').should include 'fixtures/hello.nt' end it "should find the file for a known fixture" do File.exists?(fixture 'hello.nt').should == true end end end
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
<http://example.org:80/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/> <http://www.w3.org/2000/01/rdf-schema#comment> "Congratulations, your Trinity installation is up and running."@en . <http://example.org:80/> <http://www.w3.org/2000/01/rdf-schema#label> "Trinity 0.0.1"@en . <http://example.org:80/hello> <http://www.w3.org/2000/01/rdf-schema#comment> "This is an example page for Trinity."@en . <http://example.org:80/hello> <http://www.w3.org/2000/01/rdf-schema#label> "Hello, world!"@en .
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
<http://example.org:80/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/> <http://www.w3.org/2000/01/rdf-schema#comment> "Congratulations, your Trinity installation is up and running."@en . <http://example.org:80/> <http://www.w3.org/2000/01/rdf-schema#label> "Trinity 0.0.1"@en . <http://example.org:80/hello> <http://www.w3.org/2000/01/rdf-schema#comment> "This is an example page for Trinity."@en . <http://example.org:80/hello> <http://www.w3.org/2000/01/rdf-schema#label> "Hello, world!"@en . <http://example.org:80/hello> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/alias> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/alias> <http://www.w3.org/2002/07/owl#sameAs> <http://example.org:80/hello> . <http://example.org:80/hello/redirect> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/redirect> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://example.org:80/hello> . <http://example.org:80/hello/redirect-loop> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/redirect-loop> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://example.org:80/hello/redirect-loopback> . <http://example.org:80/hello/redirect-loopback> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/redirect-loopback> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://example.org:80/hello/redirect-loop> . <http://example.org:80/hello/alias-loop> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/alias-loop> <http://www.w3.org/2002/07/owl#sameAs> <http://example.org:80/hello/alias-loopback> . <http://example.org:80/hello/alias-loopback> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/alias-loopback> <http://www.w3.org/2002/07/owl#sameAs> <http://example.org:80/hello/alias-loop> . <http://example.org:80/hello/two-redirects> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/two-redirects> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://example.org:80/hello/redirect> . <http://example.org:80/hello/two-aliases> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://example.org:80/hello/two-aliases> <http://www.w3.org/2002/07/owl#sameAs> <http://example.org:80/hello/alias> .
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
<http://localhost:3000/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://localhost:3000/> <http://www.w3.org/2000/01/rdf-schema#comment> "Congratulations, your Trinity installation is up and running."@en . <http://localhost:3000/> <http://www.w3.org/2000/01/rdf-schema#label> "Trinity 0.0.1"@en . <http://localhost:3000/hello/alias> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://localhost:3000/hello/alias> <http://www.w3.org/2002/07/owl#sameAs> <http://localhost:3000/hello> . <http://localhost:3000/hello/redirect> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://localhost:3000/hello/redirect> <http://www.w3.org/2000/01/rdf-schema#seeAlso> <http://localhost:3000/hello> . <http://localhost:3000/hello> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Resource> . <http://localhost:3000/hello> <http://www.w3.org/2000/01/rdf-schema#comment> "This is an example page for Trinity."@en . <http://localhost:3000/hello> <http://www.w3.org/2000/01/rdf-schema#label> "Hello, world!"@en .
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
@base <http://localhost:3000/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix dc: <http://purl.org/dc/terms/> . @prefix doap: <http://usefulinc.com/ns/doap#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix sioc: <http://rdfs.org/sioc/ns#> . @prefix skos: <http://www.w3.org/2004/02/skos/core#> . @prefix tri: <http://trinity.datagraph.org/rdf/> . <> a rdfs:Resource ; rdfs:label "Trinity 0.0.1"@en ; rdfs:comment "Congratulations, your Trinity installation is up and running."@en ; tri:theme "data" . <hello> a rdfs:Resource ; rdfs:label "Hello, world!"@en ; rdfs:comment "This is an example page for Trinity."@en . <hello/alias> a rdfs:Resource ; owl:sameAs <hello> . <hello/redirect> a rdfs:Resource ; rdfs:seeAlso <hello> .
{ "repo_name": "ruby-rdf/trinity", "stars": "34", "repo_language": "JavaScript", "file_name": "localhost.ttl", "mime_type": "text/plain" }
# <a href='https://github.com/orkestral/superchats/'><img src='./img/superchats.png' height='60' alt='SuperChats' aria-label='https://github.com/orkestral/superchats/' /></a> <a href='https://github.com/orkestral/superchats/'> Access SuperChats git and leave your star</a> <br> <br> <b>SuperChats</b> is a premium library with unique features that control Whatsapp functions with socket. With Superchats you can build service bots, multiservice chats or any system that uses Whatsapp <b>Superchats</b> is a premium version of <a target="_blank" href='https://github.com/orkestral/venom'>Venom</a>, with exclusive features and support for companies and developers worldwide ## Buy a license The value of the license is $50 monthly dollars, to acquire contact in whatsapp by clicking on the image below !! <a target="_blank" href="https://web.whatsapp.com/send?phone=5561985290357&text=I%20want%20to%20buy%201%20license" target="_blank"><img title="whatzapp" height="100" width="375" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/WhatsApp_logo.svg/2000px-WhatsApp_logo.svg.png"></a> ## Quickstart Run the following command to ensure you have SuperChats installed: ```bash $ npm install superchats ``` or using yarn: ```bash $ yarn add superchats ``` ## Documentations - <a href="#getting-started">Getting Started</a> - <a href="#multiples-sessions">Multiples Sessions</a> - <a href="#optional-parameters">Optional Parameters</a> - <a href="#download-and-save-files">Download and Save Files </a> - <a href="#disconnect-functions">Disconnect Functions </a> - <a href="#message-sending-functions">Message Sending Functions </a> - <a href="#send-message-text">Send Text </a> - <a href="#send-message-image">Send Image </a> - <a href="#send-message-sticker">Send Sticker </a> - <a href="#send-message-video">Send Video </a> - <a href="#send-message-audio">Send Audio </a> - <a href="#send-message-audio-voice">Send Voice </a> - <a href="#send-message-document">Send Document </a> - <a href="#send-message-location">Send Location </a> - <a href="#send-message-contact">Send Contact </a> - <a href="#send-message-link">Send Link </a> - <a href="#send-message-buttons">Send Buttons </a> - <a href="#send-message-list">Send List </a> - <a href="#get-all-contacts">Get All Contacts </a> - <a href="#delete-message">Delete Message </a> - <a href="#forwarding-message">Forwarding Message </a> - <a href="#mute-chat">Mute Chat </a> - <a href="#get-chats">Get Chats </a> - <a href="#read-chat-messages">Read Chat Messages</a> - <a href="#get-block-list">Get Block List </a> - <a href="#archive-chat">Archive Chat </a> - <a href="#delete-chat">Delete Chat </a> - <a href="#pin-chat">Pin Chat </a> - <a href="#block-contact">Block Contact </a> - <a href="#get-profile-status">Get Profile Status </a> - <a href="#get-picture">Get Picture </a> - <a href="#set-picture">Set Picture </a> - <a href="#get-number-profile">Get Number Profile </a> - <a href="#groups-functions">Groups Functions </a> - <a href="#create-group">Create Group</a> - <a href="#add-participants-group">Add Participants Group</a> - <a href="#add=admins-group">Add Admins Group</a> - <a href="#change-name-of-group">Change Name of Group</a> - <a href="#change-name-of-group">Change Description of Group</a> - <a href="#join-group">Join Group</a> - <a href="#leave-group">Leave Group</a> - <a href="#get-group-link">Get Group Link</a> - <a href="#revoke-group-link">Revoke Group Link</a> - <a href="#info-group">Info Group</a> - <a href="#set-group-settings">Set Group Settings</a> - <a href="#get-groups-list">Get Groups List</a> - <a href="#get-host-device">Get Host Device</a> - <a href="#chat-messages-functions">Chat Messages Functions</a> - <a href="#update-presence">Update Presence</a> - <a href="#send-messages-for-status">Send Messages for Status</a> - <a href="#observation-events">Observation Events</a> ## Getting Started ```javascript const superchats = require("superchats"); async function start(){ let client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", nodata: true, statusFind: async (status) => { console.log(status) }, onMessage: async (message) => { if ((message.type == "text" || message.subtype == 'text') && message.content == "hi") { await client.sendText(message.from, "Let's GO Superchats"); } } // Receive an event all the time you receive a message from some contact }) return client; } (async function(){ let client = await start(); let response = await client.sendText('0000000000000', 'Thanks for using Superchats!!!') console.log(response) })() ``` ## Multiples Sessions After executing create() function, **Superchats** will create an instance of whatsapp. If you are not logged in, it will print a QR code in the terminal. Scan it with your phone and you are ready to go! **Superchats** will remember the session so there is no need to authenticate everytime. Multiples sessions can be created at the same time by pasing a session name to create() function: ```javascript // Init sales whatsapp bot superchats.create({session:'sales', license: "asjdh-efddff734-sdsdf834-233272"}).then((salesClient) => {...}); // Init support whatsapp bot ssuperchats.create({session:'support', license: "asjdh-efddff734-sdsdf834-233272"}).then((supportClient) => {...}); ``` ## Optional Parameters Optional parameters are started along with the connection as events of **QRCODE and CONNECTION STATUS**, plus extra options ```javascript const superchats = require("superchats"); superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", // Valid license to use Superchats welcomeScreen: true, // Show or hide welcome in terminal retries: 3, // Number of connection attempts, nodata true, // It doesn't get the entire history of the device (default = true) logQr: true // (Default is true) Logs QR automatically in terminal qrcode: (base64QR, asciiQR, urlCode) => { console.log("base64 image of qrcode: ", base64QR); console.log("Terminal image of qrcode in caracter ascii: ", asciiQR); console.log("Terminal string hash of qrcode: ", urlCode); statusFind: (statusSession) => { console.log("Status Session: ", statusSession); }, onMessage: (event) => { // Receive an event all the time you receive a message from some contact console.log(event) }, onMessageFull: (event) => { // Receive an event all the time you receive a message complete no filters direct of socket do whatsapp console.log(event) }, onAck: (event) => { // Receive an event every time you send a message to some contact with the States of: failed, pending, sent, received or read console.log(event) }, onPresence: (event) => { // Receive an event every time a contact is: typing, recording, online or offline with you console.log(event) }, onGroups: (event) => { // Receive events all time the name of a group, configurations are changed console.log(event) }, onParticipants: (event) => { // Receive events about group participants console.log(event) }, onDelete: (event) => { // Receive events every time a message is deleted console.log(event) } }) ``` ## Callback StatusFind Get connection feedback by following codes: | Status | Condition | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `isLogged` | When the client already has a valid token and will not need to read the qrcode again | | `notLogged` | When the client does not have a valid token and needs to read the qr code again | | | `isDisconnected` | The client has disconnected or has been disconnected | | `isLogout` | The client has disconnected and removed the token from the device | | `isConnected` | The client has successfully connected list | | `serverDisconnected` | Disconnected for whatsapp socket server | | `isReconnected` | notifies that it is connected so that you can check if it has been successfully connected | ## Download and Save Files Download and save any message file with the functions below ```javascript let client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", onMessage: async (message) => { if (message.isMedia === true) { //retrieve the file buffer for a given message const buffer = await client.decryptByIdFile(message.from, message.id); // Save the message file in the project's root or in a directory: './diretory/filename' don't forget to create the directory const saveFile = await client.decryptByIdFileSave(message.from, message.id, filename); } } // Receive an event all the time you receive a message from some contact }) ``` ##### Return of decryptFile ```javascript { session: 'Marketing', status: 200, type: "decrypt-by-id-file", buffer: { type: "Buffer", data: [137,80,78,71,13,10,26,10,0,0,0,13,73,72,68] } } ``` ##### Return of decryptFileSave ```javascript { session: 'Marketing', status: 404, type: "decrypt-by-id-file-save", response: "./files/teste4.mp4" } ``` ## Disconnect Functions > Disconnect Functions ```javascript client.close() ``` ```javascript client.logout() ``` ## Message Sending Functions We created the easiest way to send messages with **Superchats** > Sending messages can be sent to the contact's number, example: **5561981590153** or to a group ID, example: **15815954040-1631239154** ### Send Message Text ```javascript let response = await client.sendText("5561981590153", "Thanks for using Superchats!!!"); ``` > To reply to a message, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendText("5561981590153", "Reply Message!!!", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'text', id: '3EB01A690E67', to: '556181590153', content: 'Thanks for using Superchats!!!', isgroup: false, timestamp: 1633101992 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'text', message: 'message of erro' } ``` ### Send Message Image > For image submission, you can use URL or the local file path ```javascript let response = await client.sendImage("5561981590153", "https://github.com/orkestral/superchats/raw/main/img/superchats.png", "Text optional"); ``` > To reply to a message with image, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendImage("5561981590153", "https://github.com/orkestral/superchats/raw/main/img/superchats.png", "Reply with image", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'image', id: '3EB0FF4E2532', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AmkmMjj4ZqieB6bDxS-Trox10ldAe5aIUZ5uQLutyKL8.enc', caption: 'Text optional', mimetype: 'image/jpeg', fileSha256: <Buffer 11 ed 0d 21 f2 59 96 9a 65 cf 7e fa c1 57 a1 ee a2 c9 50 b4 0d 09 df df a8 9f e1 44 dd cf a6 a5>, fileLength: Long { low: 15183, high: 0, unsigned: true }, height: 0, width: 0, mediaKey: <Buffer 17 0e ba 4b e6 81 69 eb 2b 30 28 59 5f a1 f4 42 7d fa 18 61 8a de 74 28 09 fc 92 79 7e 3d cc d4>, fileEncSha256: <Buffer fe 62 a7 a4 d9 c3 ca 84 44 51 26 08 4c 7f fe 0a b1 13 f0 ad b9 9a ba 7e de a4 83 35 07 b0 5a 3e>, directPath: '', thumbnail: <Buffer > }, participant: '', timestamp: 1633106913 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'image', message: 'message of erro' } ``` ### Send Message Sticker > For image sticker submission, you can use URL or the local file path ```javascript let response = await client.sendSticker("5561981590153", "https://static-00.iconduck.com/assets.00/node-js-icon-454x512-nztofx17.png"); ``` > To reply to a message with image sticker, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendSticker("5561981590153", "https://static-00.iconduck.com/assets.00/node-js-icon-454x512-nztofx17.png", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'sticker', id: '3EB07B2F281B', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/Ak39fUdprDRnKalZbWWyepoMbvNBlEOgIqZzY7GLEBil.enc', mimetype: 'image/webp', fileSha256: <Buffer ac b2 5f f4 af a4 2e 6d 9e 15 4a e7 58 c0 b3 0f df b6 0b 3f 27 cb 6c d9 55 dd 90 7f e8 92 b8 f7>, fileLength: Long { low: 23001, high: 0, unsigned: true }, mediaKey: <Buffer 6e 96 87 f9 90 1e f5 ae cb 8a c6 9d 95 92 86 ca d3 1a 2a e1 d6 f1 1f f6 5e c3 56 1f 8f 14 1b 08>, fileEncSha256: <Buffer 69 88 d6 36 1c 8b 5f 02 a1 8f e1 6b b2 41 3d da 68 77 b8 8b fd df f0 d0 73 5b bf 2c 84 ee 7e b4>, directPath: '' }, participant: '', timestamp: 1633129024 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'sticker', message: 'message of erro' } ``` ### Send Message Video > For video submission, you can use URL or the local file path ```javascript let response = await client.sendVideo("5561981590153", "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4", "Text optional"); ``` > To reply to a message with video, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendVideo("5561981590153", "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4", "Reply with video", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'video', id: '3EB0612BED9B', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AnrExTInFHkr446WcJoVnbHhhb1Tdmg8ort6g1SweEvS.enc', caption: 'Text optional', mimetype: 'video/mp4', fileSha256: <Buffer 75 de 47 ac c8 b9 b5 c6 ef 56 56 6e eb 50 72 af c3 bd e0 a4 ff 4f f4 09 62 a4 b5 33 c1 26 db 46>, fileLength: Long { low: 2252313, high: 0, unsigned: true }, mediaKey: <Buffer f7 91 19 c6 62 30 93 cc cb 83 b0 5a 20 f7 1c 5b 62 a6 36 fc 93 53 87 df 14 69 a6 14 db 9c ff 5e>, fileEncSha256: <Buffer 49 d9 c9 e4 61 96 36 fc 7e ae 83 a4 da a1 70 5e d2 d5 f4 f1 74 15 52 26 84 8f f1 cb f4 54 82 3f>, directPath: '', thumbnail: <Buffer > }, participant: '', timestamp: 1633108332 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'video', message: 'message of erro' } ``` ### Send Message Audio > For audio submission, you can use URL or the local file path ```javascript let response = await client.sendAudio("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3"); ``` > To reply to a message with audio, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendAudio("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'audio', id: '3EB072B039F6', to: '556181590153', content: '', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AjwRfBCBZ1XgeSLtdVTr96lMJO5CtZtjCi0HpNjEctDW.enc', mimetype: 'audio/ogg; codecs=opus', fileSha256: <Buffer fa 28 20 25 6f 2c d3 f2 df 03 fa 24 7d 7b 01 e7 9d 3f e7 94 34 4a ad ce a0 8c ee 06 bc ce 3c 94>, fileLength: Long { low: 764176, high: 0, unsigned: true }, seconds: 27, mediaKey: <Buffer ad f9 19 91 76 08 28 59 63 b2 be 43 13 8d 68 5b d3 90 e7 93 6d 32 29 5e e8 b5 b9 cb 37 76 d6 27>, fileEncSha256: <Buffer ab d4 0e 48 ca 4c 1e 47 86 02 50 3f 0d 87 aa 7f a7 82 ac ff eb 8d 1f ac f1 f8 6d da 36 1e ba e4>, directPath: '' }, participant: '', timestamp: 1633111077 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'audio', message: 'message of erro' } ``` ### Send Message Audio Voice > For audio voice submission, you can use URL or the local file path ```javascript let response = await client.sendVoice("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3"); ``` > To reply to a message with audio voice, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendVoice("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'voice', id: '3EB072B039F6', to: '556181590153', content: '', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AjwRfBCBZ1XgeSLtdVTr96lMJO5CtZtjCi0HpNjEctDW.enc', mimetype: 'audio/ogg; codecs=opus', fileSha256: <Buffer fa 28 20 25 6f 2c d3 f2 df 03 fa 24 7d 7b 01 e7 9d 3f e7 94 34 4a ad ce a0 8c ee 06 bc ce 3c 94>, fileLength: Long { low: 764176, high: 0, unsigned: true }, seconds: 27, mediaKey: <Buffer ad f9 19 91 76 08 28 59 63 b2 be 43 13 8d 68 5b d3 90 e7 93 6d 32 29 5e e8 b5 b9 cb 37 76 d6 27>, fileEncSha256: <Buffer ab d4 0e 48 ca 4c 1e 47 86 02 50 3f 0d 87 aa 7f a7 82 ac ff eb 8d 1f ac f1 f8 6d da 36 1e ba e4>, directPath: '' }, participant: '', timestamp: 1633111077 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'voice', message: 'message of erro' } ``` ### Send Message Document > For document submission, you can use URL or the local file path ```javascript let response = await client.sendDocument("5561981590153", "http://www.orimi.com/pdf-test.pdf", "Filename Optional"); ``` > To reply to a message with document, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendDocument("5561981590153", "http://www.orimi.com/pdf-test.pdf", "Filename Optional", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'document', id: '3EB07C8C333C', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/ArJfVUhnzdW7qcBk8-T-mzRWsfMN6k_WOS81td_xJs6E.enc', mimetype: 'application/pdf', filename: 'Filename Optional', fileSha256: <Buffer f6 ed cd 8a 1b 4f 7c b8 54 86 d0 c6 77 7f 91 74 ea db c4 d1 d0 d9 e5 ae ba 71 32 f3 0b 34 bc 3e>, fileLength: Long { low: 20597, high: 0, unsigned: true }, mediaKey: <Buffer 1b 7d 59 ce fa 4b 3f 35 14 ca 36 1b bd ba f7 c7 ed 6a f7 3d ea c1 04 b0 7c a1 6b d4 4a ab 33 40>, fileEncSha256: <Buffer 37 db ac 7a aa f5 c2 aa 13 c6 ec 18 9f 32 d7 5b 8a b3 0d fc 50 4f 9c ea aa 2f 8c ed 20 c9 f5 b0>, directPath: '', thumbnail: <Buffer > }, participant: '', timestamp: 1633121433 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'document', message: 'message of erro' } ``` ### Send Message Location ```javascript let response = await client.sendLocation("5561981590153", -15.8413105, -48.0270346, 'title optional', 'address optional'); ``` > To reply to a message with location, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendLocation("5561981590153", -15.8413105, -48.0270346, 'title optional', 'address optional', '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'location', id: '3EB01A3D9A34', to: '556181590153', name: 'title optional', address: 'address optional', url: '', thumbnail: <Buffer >, latitude: -15.8413105, longitude: -48.0270346, isgroup: false, participant: '', timestamp: 1633122748 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'location', message: 'message of erro' } ``` ### Send Message Contact ```javascript let response = await client.sendContact("5561981590153",'Name of Contact', '15815954040'); ``` > To reply to a message with contact, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendContact("5561981590153",'Name of Contact', '15815954040', '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'contact', id: '3EB00AFB1F60', to: '556181590153', display: 'Name of Contact', vcard: 'BEGIN:VCARD\n' + 'VERSION:3.0\n' + 'FN:Name of Contact\n' + 'TEL;type=CELL;type=VOICE;waid=15815954040:+15815954040\n' + 'END:VCARD', isgroup: false, timestamp: 1633128149 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'contact', message: 'message of erro' } ``` ### Send Message Link ```javascript let response = await client.sendLink("5561981590153", "https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share", 'Description optional'); ``` > To reply to a message with link, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendLink("5561981590153", "https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share", 'Description optional', '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'link', id: '3EB0746BE9A9', to: '556181590153', content: 'https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share\n' + 'Description optional', isgroup: false, timestamp: 1633130029 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'link', message: 'message of erro' } ``` ### Send Buttons Reply ```javascript const buttons = [ {buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1}, {buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1} ] let response = await client.sendButtons("5561981590153", "title of message", buttons, 'Description optional'); ``` > Use media in message header of buttons, image or optional video parameter. ```javascript let response = await client.sendButtons("5561981590153", "title of message", buttons, 'Description optional', 'image', 'https://domain.com/image.jpg'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'buttons-reply', id: '3EB071B7776A', to: '556181590153', title: 'title of message', description: 'Description optional', buttons: [ Button { buttonId: 'id1', buttonText: [ButtonText], type: 1 }, Button { buttonId: 'id2', buttonText: [ButtonText], type: 1 } ], isgroup: false, timestamp: 1633142713 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'buttons-reply', message: 'message of erro' } ``` ### Send Message Buttons Actions ```javascript const buttons = [ {index: 1, quickReplyButton: {displayText: 'Button Normal Reply', id: 'id-123'}}, {index: 2, callButton: {displayText: 'Button Call', phoneNumber: '+55 (61) 98159-0153'}}, {index: 3, urlButton: {displayText: 'Button Link', url: 'https://stuidomedia.io'}}, ] let response = await client.sendButtonsMD("5561981590153", "title of message", buttons, 'Description optional'); ``` > Use media in message header of buttons, image or optional video parameter. ```javascript let response = await client.sendButtonsMD("5561981590153", "title of message", buttons, 'Description optional', 'image', 'https://domain.com/image.jpg'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'buttons', id: '3EB071B7776A', to: '556181590153', title: 'title of message', description: 'Description optional', buttons: [ Button { buttonId: 'id1', buttonText: [ButtonText], type: 1 }, Button { buttonId: 'id2', buttonText: [ButtonText], type: 1 } ], isgroup: false, timestamp: 1633142713 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'buttons', message: 'message of erro' } ``` ### Send Message List > Attention! This function does not work if connected to a WhatsApp Business account ```javascript const sections = [ { title: "Bovina", rows: [ { title: "Fraudinha", rowId: "carnes1" }, { title: "Alcatra", rowId: "carnes2", description: "Carne boa" }, ], }, { title: "Suina", rows: [ { title: "Costelinha", rowId: "carnes3" }, { title: "Picanha Suina", rowId: "carnes4", description: "Carne boa", }, ], }, ]; //number of contact, name of button, sections array, title, description: optional, footer: optional let response = await const response = await client.sendList( "5561981590153", "Escolha a Carne", sections, "Escolha 1 tipo de carne", "", //Description opcional "Qual o tipo de carne vai na sua refeição?" ); ``` > To reply to a message with buttons, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript //number of contact, name of button, sections array, title, description: optional, footer: optional, id message for reply let response = await const response = await client.sendList( "5561981590153", "Escolha a Carne", sections, "Escolha 1 tipo de carne", "", //Description opcional "Qual o tipo de carne vai na sua refeição?", "3EB01A690E67" ); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'list', id: '3EB0F92B3F1D', to: '556181590153', description: 'Description optional', btnName: 'Name of Button', sections: [ Section { rows: [Array], title: 'Name of section' } ], isgroup: false, timestamp: 1633143340 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'list', message: 'message of erro' } ``` ## Delete Message > Delete messages in chats only for you or for all Delete message only for you ```javascript //number of chat, id of message let response = await client.deleteMessageMe("5561981590153", "3EB071B7776A") ``` Delete Message to everyone on chat ```javascript //number of chat, id of message let response = await client.deleteMessageAll("5561981590153", "3EB071B7776A") ``` Return with success ```javascript { session: 'Marketing', status: 200 type: 'delete-chat-me' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'delete-chat-me', message: 'message of erro' } ``` ## Forwarding Message > Message forwarding for any contact ```javascript //number of chat, id of message, number chat for send let response = await client.forwardMessage("5561981590153", "3EB042FA6555", "15815954040") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'forwarding', subtype: 'text', id: '3EB042FA6555', from: '15815954040', text: 'oi', isgroup: false, reply: { id: undefined }, participant: '', timestamp: 1633147282 } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'forwarding', message: 'message of erro' } ``` ## Get Chats > List All Chats of Conversations ```javascript let response = await client.getChats() ``` Return with success ```javascript { session: 'Marketing', type: 'get-chats', chats: [ { id: '556181590153', name: 'Joe Dutra', mute: '0', spam: 'false' }, { id: '5511982743910-1596072761', name: 'Venom Support', mute: '0', spam: 'false' } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-chats', message: 'message of erro' } ``` ## Read Chat Messages > Read all messages from a chat ```javascript let response = await client.markReadAll('5561981590153') ``` > Read message from a chat ```javascript let response = await client.markRead('5561981590153', '3EB01A690E67') // params: Number, MessageID ``` Return with success ```javascript { session: 'Marketing', status: 200, type: "mark-read" } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'mark-read', message: 'message of erro' } ``` ## Get All Contacts > List All Contacts ```javascript let response = await client.getAllContacts() ``` Return with success ```javascript { session: 'Marketing', type: 'get-all-contacts', qt: 2, contacts: [ { id: '552123919428', name: 'Alenii Venom', short: '' }, { id: '556181590153', name: 'Joe Dutra', short: '' } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-all-contacts', message: 'message of erro' } ``` ## Get Block List > List All Contacts Blocking ```javascript let response = await client.getBlockList() ``` Return with success ```javascript { session: 'Marketing', type: 'get-block-list', list: [ '5561986268199', '5561998745252' ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-block-list', message: 'message of erro' } ``` ## Mute Chat > Silence or remove the silence of a particular chat for a specific period **Mute** ```javascript //number of chat, timer: ['hour', 'week', 'ever'] let response = await client.muteChat("5561981590153", "hour") ``` **Unmute** ```javascript //number of chat let response = await client.unmuteChat("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'mute-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'mute-chat', message: 'message of erro' } ``` ## Archive Chat > Archive or unarchive a specific chat **Archive** ```javascript //number of chat, true let response = await client.archiveChat("5561981590153", true) ``` **Unarchive** ```javascript //number of chat, false let response = await client.archiveChat("5561981590153", false) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'archive-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'archive-chat', message: 'message of erro' } ``` ## Delete Chat > Delete a specific chat or group **Archive** ```javascript //number of chat or group let response = await client.deleteChat("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'delete-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'delete-chat', message: 'message of erro' } ``` ## Pin Chat > Pin or unpin a specific chat or group **Pin** ```javascript //number of chat, true let response = await client.pinChat("5561981590153", true) ``` **Unpin** ```javascript //number of chat, false let response = await client.pinChat("5561981590153", false) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'pin-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'pin-chat', message: 'message of erro' } ``` ## Block Contact > Blocking or unblocking a specific contact **Block** ```javascript //number of chat let response = await client.blockContact("5561981590153") ``` **Unblock** ```javascript //number of chat let response = await client.unblockContact("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'block-contact', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'block-contact', message: 'message of erro' } ``` ## Get Profile Status > Displays the text of the status of a specific contact ```javascript //number of chat let response = await client.getProfileStatus("5561981590153") ``` Return with success ```javascript { session: 'Marketing', type: 'get-profile-status', status: 'Que Deus seja sempre louvado em nossas vidas' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-profile-status', message: 'message of erro' } ``` ## Get Picture > Displays the image of a specific contact ```javascript //number of chat let response = await client.getPicture("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'get-picture', picture: 'https://pps.whatsapp.net/v/t61.24694-24/166060433_390988636021500_3494454124066997603_n.jpg?ccb=11-4&oh=453e672ddc35e64ca123439f7a89d7d2&oe=615EAAAF' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-picture', message: 'message of erro' } ``` ## Set Picture > Set image for profile or group ```javascript //number of chat, file local path let response = await client.setPicture("5561981590153", "./image-profile.png") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'set-picture' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'set-picture', message: 'message of erro' } ``` ## Get Number Profile > Checks if a number exists in the WhastApp ```javascript //number of chat let response = await client.getNumberProfile("5561981590153") ``` Return with success ```javascript { session: 'Marketing', type: 'get-number-profile', id: '556181590153', isBusiness: false, exist: true } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-number-profile', message: 'message of erro' } ``` ## Groups Functions We created the easiest way to create groups with **Superchats** ## Create Group > Create a group with participants ```javascript //name of group, array with number of contacts let response = await client.createGroup("Name Group", ["556181590153", "5561981819855"]) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'create-group', groupId: "15815954040-1631239154" } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'create-group', message: 'message of erro' } ``` ## Add Participants Group > Add participants in group ```javascript //id of group, array with number of contacts let response = await client.addParticipantsGroup("15815954040-1631239154", ["556181590153", "5561981819855"]) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'add-participants-group', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'add-participants-group', message: 'message of erro' } ``` ## Add Admins Group > Add or Remove participants of group as admin ```javascript //id of group, array with number of contacts let response = await client.addGroupAdmins("15815954040-1631239154", ["556181590153", "5561981819855"]) ``` ```javascript //id of group, array with number of contacts let response = await client.removeGroupAdmins("15815954040-1631239154", ["556181590153", "5561981819855"]) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'add-group-admins', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'add-group-admins', message: 'message of erro' } ``` ## Change Name of Group > Change name of group ```javascript //id of group, name group let response = await client.groupTitle("15815954040-1631239154", "new name of group") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'group-title', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'group-title', message: 'message of erro' } ``` ## Change Description of Group > Change description of group ```javascript //id of group, name group let response = await client.groupDescription("15815954040-1631239154", "description of group") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'group-description', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'group-description', message: 'message of erro' } ``` ## Join Group > Join a group specified ```javascript //id of group let response = await client.joinGroup("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'join-group', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'join-group', message: 'message of erro' } ``` ## Leave Group > Leaves a group specified ```javascript //id of group let response = await client.leaveGroup("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'leave-group', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'leave-group', message: 'message of erro' } ``` ## Revoke Group Link > Revoke link from a specified group ```javascript //id of group let response = await client.revokeGroupLink("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'revoke-group-link', linkGroup: 'G3M81fQbuwDB2cuAdPIv0h' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'revoke-group-link', message: 'message of erro' } ``` ## Info Group > Get info from a specified group ```javascript //id of group let response = await client.infoGroup("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', type: 'info-group', status: 200, id: '15795662985-1631581942', owner: '[email protected]', title: 'Teste Grupo Live', create: 1631581942, participants: [ { id: '556181590153', name: 'Joe Dutra', short: 'Joe', isAdmin: false, isSuperAdmin: false }, { id: '5521991977392', name: 'Israel - Fabrica de Sonhos', short: 'Israel - Fabrica', isAdmin: false, isSuperAdmin: false } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'info-group', message: 'message of erro' } ``` ## Set Group Settings > Get info from a specified group **Set sending messages in group only for admins** ```javascript //id of group, type, boolean let response = await client.setGroupSettings("15815954040-1631239154", "message", true) ``` **Set change settings in group only for admins** ```javascript //id of group, type, boolean let response = await client.setGroupSettings("15815954040-1631239154", "settings", true) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'set-group-settings', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'set-group-settings', message: 'message of erro' } ``` ## Get Groups List > Get all groups list ```javascript let response = await client.getGroups() ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'get-groups', chats: [ { id: '5511982743910-1596072761', name: 'Venom Support' }, { id: '556181590153-1625838636', name: 'Venom Business' } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-groups', message: 'message of erro' } ``` ## Get Host Device > Get info of device ```javascript let response = await client.getHostDevice() ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'get-host-device', phone: '556181590153', image: "https://pps.whatsapp.net/v/t61.24694-24/254827313_500572874791871_6168181924916411415_n.jpg?stp=dst-jpg_s96x96&ccb=11-4&oh=5ee43eb4f1fe109b10ceba05292561aa&oe=622FF53D", pushName: 'Joe Dutra' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-host-device', message: 'message of erro' } ``` ## Chat Messages Functions > Know the types of functions to recover chat messages **Take the last 10 messages from a chat** ```javascript //number of chat, Number let response = await client.getChatMessages('556181590153', 10) ``` **Take all messages from a chat** ```javascript //number of chat let response = await client.getChatAllMessages('556181590153') ``` **Take all unread messages from all chats** ```javascript let response = await client.getAllUnreadMessages() ``` Return with success ```javascript { session: 'Marketing', type: 'get-chat-messages', messages: [ { session: 'Marketing', type: 'reply', subtype: 'text', id: '3EB082EFA70F', from: '556181590153', text: 'Oi', isgroup: false, reply: [Object], participant: '', timestamp: 1633407729 }, { session: 'Marketing', type: 'text', id: '3EB0D91B1ECF', from: '556181590153', content: 'Oi', isgroup: false, participant: '', timestamp: 1633408611 }, { session: 'Marketing', type: 'text', id: '3EB0AD7A246F', from: '556181590153', content: 'Testando', isgroup: false, participant: '', timestamp: 1633411173 }, { session: 'Marketing', type: 'text', id: '46110924F9C202D3933AA4CBC2F209A3', from: '556181590153', content: 'Oi', isgroup: false, participant: '', timestamp: 1633411357 }, { session: 'Marketing', type: 'text', id: '3EB0EE5900AF', from: '556181590153', content: 'Testando', isgroup: false, participant: '', timestamp: 1633411382 }, { session: 'Marketing', type: 'text', id: '96033721D4426073C37802F407251F9A', from: '556181590153', content: 'Oi', isgroup: false, participant: '', timestamp: 1633411396 }, { session: 'Marketing', type: 'text', id: '3EB067D84A06', from: '556181590153', content: 'Testando', isgroup: false, participant: '', timestamp: 1633411746 }, { session: 'Marketing', type: 'text', id: '2CDF9BAF7E20E72BC74D602A339DA2C2', from: '556181590153', content: 'Oiiii', isgroup: false, participant: '', timestamp: 1633411781 }, { session: 'Marketing', type: 'text', id: '4DEBB46473A8E642E8764F6C70567089', from: '556181590153', content: 'Como vai???', isgroup: false, participant: '', timestamp: 1633411792 }, { session: 'Marketing', type: 'text', id: 'B536EAE6275FD6FF98F3E3326FE1682F', from: '556181590153', content: 'Top', isgroup: false, participant: '', timestamp: 1633411811 } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-chat-messages', message: 'message of erro' } ``` ## Update Presence Update your presence for a certain contact Types of state: a = available, c = composing, r = recording, p = paused ```javascript //chat number, state: a, c, r, p let response = await client.setPresence('556181590153', 'c'); ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'set-presence' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'set-presence', message: 'message of erro' } ``` ## Observation Events > Follow each event at the time that happen ### **Received Message Event** <br> > Receive an event all the time you receive a message from some contact ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onMessage: (event) => { console.log(event) }) ``` Return of event onMessage ```javascript { session: 'Marketing', type: 'text', id: '3EB07A5B9979E8CB453A', from: '556181590153', content: 'oiii', isgroup: false, participant: '', timestamp: 1633414066 } ``` ### **Reading Confirmation Event** <br> > Receive an event every time you send a message to some contact with the States of: failed, pending, sent, received or read ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onAck: (event) => { console.log(event) }) ``` Return of event onAck ```javascript { session: 'Marketing', status: 'RECEIVED', type: 'text', id: '3EB02BC6217B', to: '556181590153', text: 'Hii', isgroup: false, timestamp: 1633414317 } ``` ### **Presence Event** <br> > Receive an event every time a contact is: typing, recording, online or offline with you <br> Types of state: **available**, **composing**, **recording** and **paused** ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onPresence: (event) => { console.log(event) }) ``` Return of event onPresence ```javascript { session: 'Marketing', from: '556181590153', status: 'composing', pushname: 'Joe Dutra' } ``` ### **Group Event** <br> > Receive events all time the name of a group, configurations are changed <br> Types of return: **change-name**, **change-messages-admin**, **change-settings-admin** and **paused** ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onGroups: (event) => { console.log(event) }) ``` Return of event onGroup <br> ##### **Name change group** ```javascript { session: 'Marketing', action: 'change-name', changed: [ 'Grupo Live', 'Teste Grupo Live' ], group: 'Grupo Live', from: '15795662985-1631581942', participant: '15795662985', participants: 3 } ``` ##### **Group changes for messages just for admins** ```javascript { session: 'Marketing', action: 'change-messages-admin', changed: 'active', group: 'Grupo Live', from: '15795662985-1631581942', participant: '15795662985', participants: 3 } ``` ##### **Group changes for settings just for admins** ```javascript { session: 'Marketing', action: 'change-settings-admin', changed: 'active', group: 'Grupo Live', from: '15795662985-1631581942', participant: '15795662985', participants: 3 } ``` ### **Participants Event** <br> > Receive events about group participants <br> Types of action: **add**, **remove**, **promote** and **demote** ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onParticipants: (event) => { console.log(event) }) ``` Return of event onParticipants <br> ##### **Add participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'add', participants: 3 } ``` ##### **Remove participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'remove', participants: 2 } ``` ##### **Promote participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'promote', participants: 3 } ``` ##### **Demote participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'demote', participants: 3 } ``` ### **Delete Event** <br> > Receive events every time a message is deleted ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onDelete: (event) => { console.log(event) }) ``` Return of event onDelete <br> ```javascript { session: 'Marketing', type: 'message-delete', from: '15795662985-1631581942', id: '3EB07E88FDCF1C4EF887', timestamp: 1633453902 } ```
{ "repo_name": "orkestral/superchats", "stars": "176", "repo_language": "None", "file_name": "Docs.md", "mime_type": "text/plain" }
- <a href="#getting-started">Getting Started</a> - <a href="#multiples-sessions">Multiples Sessions</a> - <a href="#optional-parameters">Optional Parameters</a> - <a href="#download-and-save-files">Download and Save Files </a> - <a href="#disconnect-functions">Disconnect Functions </a> - <a href="#message-sending-functions">Message Sending Functions </a> - <a href="#send-message-text">Send Text </a> - <a href="#send-message-image">Send Image </a> - <a href="#send-message-sticker">Send Sticker </a> - <a href="#send-message-video">Send Video </a> - <a href="#send-message-audio">Send Audio </a> - <a href="#send-message-audio-voice">Send Voice </a> - <a href="#send-message-document">Send Document </a> - <a href="#send-message-location">Send Location </a> - <a href="#send-message-contact">Send Contact </a> - <a href="#send-message-link">Send Link </a> - <a href="#send-message-buttons">Send Buttons </a> - <a href="#send-message-list">Send List </a> - <a href="#get-all-contacts">Get All Contacts </a> - <a href="#delete-message">Delete Message </a> - <a href="#forwarding-message">Forwarding Message </a> - <a href="#mute-chat">Mute Chat </a> - <a href="#get-chats">Get Chats </a> - <a href="#read-chat-messages">Read Chat Messages</a> - <a href="#get-block-list">Get Block List </a> - <a href="#archive-chat">Archive Chat </a> - <a href="#delete-chat">Delete Chat </a> - <a href="#pin-chat">Pin Chat </a> - <a href="#block-contact">Block Contact </a> - <a href="#get-profile-status">Get Profile Status </a> - <a href="#get-picture">Get Picture </a> - <a href="#set-picture">Set Picture </a> - <a href="#get-number-profile">Get Number Profile </a> - <a href="#groups-functions">Groups Functions </a> - <a href="#create-group">Create Group</a> - <a href="#add-participants-group">Add Participants Group</a> - <a href="#add=admins-group">Add Admins Group</a> - <a href="#change-name-of-group">Change Name of Group</a> - <a href="#change-name-of-group">Change Description of Group</a> - <a href="#join-group">Join Group</a> - <a href="#leave-group">Leave Group</a> - <a href="#get-group-link">Get Group Link</a> - <a href="#revoke-group-link">Revoke Group Link</a> - <a href="#info-group">Info Group</a> - <a href="#set-group-settings">Set Group Settings</a> - <a href="#get-groups-list">Get Groups List</a> - <a href="#get-host-device">Get Host Device</a> - <a href="#chat-messages-functions">Chat Messages Functions</a> - <a href="#update-presence">Update Presence</a> - <a href="#send-messages-for-status">Send Messages for Status</a> - <a href="#observation-events">Observation Events</a>
{ "repo_name": "orkestral/superchats", "stars": "176", "repo_language": "None", "file_name": "Docs.md", "mime_type": "text/plain" }
## Quickstart Run the following command to ensure you have SuperChats installed: ```bash $ npm install superchats ``` or using yarn: ```bash $ yarn add superchats ``` ## Getting Started ```javascript const superchats = require("superchats"); const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onMessage: async (message) => { if (message.type == "text" && message.content == "hi") { await client.sendText(message.from, "Thanks for using Superchats!!!"); } } // Receive an event all the time you receive a message from some contact }) ``` ## Multiples Sessions After executing create() function, **Superchats** will create an instance of whatsapp. If you are not logged in, it will print a QR code in the terminal. Scan it with your phone and you are ready to go! **Superchats** will remember the session so there is no need to authenticate everytime. Multiples sessions can be created at the same time by pasing a session name to create() function: ```javascript // Init sales whatsapp bot superchats.create({session:'sales', license: "asjdh-efddff734-sdsdf834-233272"}).then((salesClient) => {...}); // Init support whatsapp bot ssuperchats.create({session:'support', license: "asjdh-efddff734-sdsdf834-233272"}).then((supportClient) => {...}); ``` ## Optional Parameters Optional parameters are started along with the connection as events of **QRCODE and CONNECTION STATUS**, plus extra options ```javascript const superchats = require("superchats"); superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", // Valid license to use Superchats welcomeScreen: true, // Show or hide welcome in terminal retries: 3, // Number of connection attempts, nodata true, // It doesn't get the entire history of the device (default = true) logQr: true // (Default is true) Logs QR automatically in terminal qrcode: (base64QR, asciiQR, urlCode) => { console.log("base64 image of qrcode: ", base64QR); console.log("Terminal image of qrcode in caracter ascii: ", asciiQR); console.log("Terminal string hash of qrcode: ", urlCode); statusFind: (statusSession) => { console.log("Status Session: ", statusSession); }, onMessage: (event) => { // Receive an event all the time you receive a message from some contact console.log(event) }, onAck: (event) => { // Receive an event every time you send a message to some contact with the States of: failed, pending, sent, received or read console.log(event) }, onPresence: (event) => { // Receive an event every time a contact is: typing, recording, online or offline with you console.log(event) }, onGroups: (event) => { // Receive events all time the name of a group, configurations are changed console.log(event) }, onParticipants: (event) => { // Receive events about group participants console.log(event) }, onDelete: (event) => { // Receive events every time a message is deleted console.log(event) } }) ``` ## Callback StatusFind Get connection feedback by following codes: | Status | Condition | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `isLogged` | When the client already has a valid token and will not need to read the qrcode again | | `notLogged` | When the client does not have a valid token and needs to read the qr code again | | | `isDisconnected` | The client has disconnected or has been disconnected | | `isLogout` | The client has disconnected and removed the token from the device | | `isConnected` | The client has successfully connected list | | `serverDisconnected` | Disconnected for whatsapp socket server | | `isReconnected` | notifies that it is connected so that you can check if it has been successfully connected | ## Download and Save Files Download and save any message file with the functions below ```javascript const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", onMessage: async (message) => { if (message.isMedia === true) { //retrieve the file buffer for a given message const buffer = await client.decryptByIdFile(message.from, message.id); // Save the message file in the project's root or in a directory: './diretory/filename' don't forget to create the directory const saveFile = await client.decryptByIdFileSave(message.from, message.id, filename); } } // Receive an event all the time you receive a message from some contact }) ``` ##### Return of decryptFile ```javascript { session: 'Marketing', status: 200, type: "decrypt-by-id-file", buffer: { type: "Buffer", data: [137,80,78,71,13,10,26,10,0,0,0,13,73,72,68] } } ``` ##### Return of decryptFileSave ```javascript { session: 'Marketing', status: 404, type: "decrypt-by-id-file-save", response: "./files/teste4.mp4" } ``` ## Disconnect Functions > Disconnect Functions ```javascript client.close() ``` ```javascript client.logout() ``` ## Message Sending Functions We created the easiest way to send messages with **Superchats** > Sending messages can be sent to the contact's number, example: **5561981590153** or to a group ID, example: **15815954040-1631239154** ### Send Message Text ```javascript let response = await client.sendText("5561981590153", "Thanks for using Superchats!!!"); ``` > To reply to a message, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendText("5561981590153", "Reply Message!!!", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'text', id: '3EB01A690E67', to: '556181590153', content: 'Thanks for using Superchats!!!', isgroup: false, timestamp: 1633101992 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'text', message: 'message of erro' } ``` ### Send Message Image > For image submission, you can use URL or the local file path ```javascript let response = await client.sendImage("5561981590153", "https://github.com/orkestral/superchats/raw/main/img/superchats.png", "Text optional"); ``` > To reply to a message with image, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendImage("5561981590153", "https://github.com/orkestral/superchats/raw/main/img/superchats.png", "Reply with image", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'image', id: '3EB0FF4E2532', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AmkmMjj4ZqieB6bDxS-Trox10ldAe5aIUZ5uQLutyKL8.enc', caption: 'Text optional', mimetype: 'image/jpeg', fileSha256: <Buffer 11 ed 0d 21 f2 59 96 9a 65 cf 7e fa c1 57 a1 ee a2 c9 50 b4 0d 09 df df a8 9f e1 44 dd cf a6 a5>, fileLength: Long { low: 15183, high: 0, unsigned: true }, height: 0, width: 0, mediaKey: <Buffer 17 0e ba 4b e6 81 69 eb 2b 30 28 59 5f a1 f4 42 7d fa 18 61 8a de 74 28 09 fc 92 79 7e 3d cc d4>, fileEncSha256: <Buffer fe 62 a7 a4 d9 c3 ca 84 44 51 26 08 4c 7f fe 0a b1 13 f0 ad b9 9a ba 7e de a4 83 35 07 b0 5a 3e>, directPath: '', thumbnail: <Buffer > }, participant: '', timestamp: 1633106913 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'image', message: 'message of erro' } ``` ### Send Message Sticker > For image sticker submission, you can use URL or the local file path ```javascript let response = await client.sendSticker("5561981590153", "https://static-00.iconduck.com/assets.00/node-js-icon-454x512-nztofx17.png"); ``` > To reply to a message with image sticker, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendSticker("5561981590153", "https://static-00.iconduck.com/assets.00/node-js-icon-454x512-nztofx17.png", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'sticker', id: '3EB07B2F281B', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/Ak39fUdprDRnKalZbWWyepoMbvNBlEOgIqZzY7GLEBil.enc', mimetype: 'image/webp', fileSha256: <Buffer ac b2 5f f4 af a4 2e 6d 9e 15 4a e7 58 c0 b3 0f df b6 0b 3f 27 cb 6c d9 55 dd 90 7f e8 92 b8 f7>, fileLength: Long { low: 23001, high: 0, unsigned: true }, mediaKey: <Buffer 6e 96 87 f9 90 1e f5 ae cb 8a c6 9d 95 92 86 ca d3 1a 2a e1 d6 f1 1f f6 5e c3 56 1f 8f 14 1b 08>, fileEncSha256: <Buffer 69 88 d6 36 1c 8b 5f 02 a1 8f e1 6b b2 41 3d da 68 77 b8 8b fd df f0 d0 73 5b bf 2c 84 ee 7e b4>, directPath: '' }, participant: '', timestamp: 1633129024 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'sticker', message: 'message of erro' } ``` ### Send Message Video > For video submission, you can use URL or the local file path ```javascript let response = await client.sendVideo("5561981590153", "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4", "Text optional"); ``` > To reply to a message with video, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendVideo("5561981590153", "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4", "Reply with video", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'video', id: '3EB0612BED9B', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AnrExTInFHkr446WcJoVnbHhhb1Tdmg8ort6g1SweEvS.enc', caption: 'Text optional', mimetype: 'video/mp4', fileSha256: <Buffer 75 de 47 ac c8 b9 b5 c6 ef 56 56 6e eb 50 72 af c3 bd e0 a4 ff 4f f4 09 62 a4 b5 33 c1 26 db 46>, fileLength: Long { low: 2252313, high: 0, unsigned: true }, mediaKey: <Buffer f7 91 19 c6 62 30 93 cc cb 83 b0 5a 20 f7 1c 5b 62 a6 36 fc 93 53 87 df 14 69 a6 14 db 9c ff 5e>, fileEncSha256: <Buffer 49 d9 c9 e4 61 96 36 fc 7e ae 83 a4 da a1 70 5e d2 d5 f4 f1 74 15 52 26 84 8f f1 cb f4 54 82 3f>, directPath: '', thumbnail: <Buffer > }, participant: '', timestamp: 1633108332 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'video', message: 'message of erro' } ``` ### Send Message Audio > For audio submission, you can use URL or the local file path ```javascript let response = await client.sendAudio("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3"); ``` > To reply to a message with audio, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendAudio("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'audio', id: '3EB072B039F6', to: '556181590153', content: '', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AjwRfBCBZ1XgeSLtdVTr96lMJO5CtZtjCi0HpNjEctDW.enc', mimetype: 'audio/ogg; codecs=opus', fileSha256: <Buffer fa 28 20 25 6f 2c d3 f2 df 03 fa 24 7d 7b 01 e7 9d 3f e7 94 34 4a ad ce a0 8c ee 06 bc ce 3c 94>, fileLength: Long { low: 764176, high: 0, unsigned: true }, seconds: 27, mediaKey: <Buffer ad f9 19 91 76 08 28 59 63 b2 be 43 13 8d 68 5b d3 90 e7 93 6d 32 29 5e e8 b5 b9 cb 37 76 d6 27>, fileEncSha256: <Buffer ab d4 0e 48 ca 4c 1e 47 86 02 50 3f 0d 87 aa 7f a7 82 ac ff eb 8d 1f ac f1 f8 6d da 36 1e ba e4>, directPath: '' }, participant: '', timestamp: 1633111077 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'audio', message: 'message of erro' } ``` ### Send Message Audio Voice > For audio voice submission, you can use URL or the local file path ```javascript let response = await client.sendVoice("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3"); ``` > To reply to a message with audio voice, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendVoice("5561981590153", "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'voice', id: '3EB072B039F6', to: '556181590153', content: '', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/AjwRfBCBZ1XgeSLtdVTr96lMJO5CtZtjCi0HpNjEctDW.enc', mimetype: 'audio/ogg; codecs=opus', fileSha256: <Buffer fa 28 20 25 6f 2c d3 f2 df 03 fa 24 7d 7b 01 e7 9d 3f e7 94 34 4a ad ce a0 8c ee 06 bc ce 3c 94>, fileLength: Long { low: 764176, high: 0, unsigned: true }, seconds: 27, mediaKey: <Buffer ad f9 19 91 76 08 28 59 63 b2 be 43 13 8d 68 5b d3 90 e7 93 6d 32 29 5e e8 b5 b9 cb 37 76 d6 27>, fileEncSha256: <Buffer ab d4 0e 48 ca 4c 1e 47 86 02 50 3f 0d 87 aa 7f a7 82 ac ff eb 8d 1f ac f1 f8 6d da 36 1e ba e4>, directPath: '' }, participant: '', timestamp: 1633111077 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'voice', message: 'message of erro' } ``` ### Send Message Document > For document submission, you can use URL or the local file path ```javascript let response = await client.sendDocument("5561981590153", "http://www.orimi.com/pdf-test.pdf", "Filename Optional"); ``` > To reply to a message with document, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendDocument("5561981590153", "http://www.orimi.com/pdf-test.pdf", "Filename Optional", '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'document', id: '3EB07C8C333C', to: '556181590153', isgroup: false, file: { url: 'https://mmg.whatsapp.net/d/f/ArJfVUhnzdW7qcBk8-T-mzRWsfMN6k_WOS81td_xJs6E.enc', mimetype: 'application/pdf', filename: 'Filename Optional', fileSha256: <Buffer f6 ed cd 8a 1b 4f 7c b8 54 86 d0 c6 77 7f 91 74 ea db c4 d1 d0 d9 e5 ae ba 71 32 f3 0b 34 bc 3e>, fileLength: Long { low: 20597, high: 0, unsigned: true }, mediaKey: <Buffer 1b 7d 59 ce fa 4b 3f 35 14 ca 36 1b bd ba f7 c7 ed 6a f7 3d ea c1 04 b0 7c a1 6b d4 4a ab 33 40>, fileEncSha256: <Buffer 37 db ac 7a aa f5 c2 aa 13 c6 ec 18 9f 32 d7 5b 8a b3 0d fc 50 4f 9c ea aa 2f 8c ed 20 c9 f5 b0>, directPath: '', thumbnail: <Buffer > }, participant: '', timestamp: 1633121433 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'document', message: 'message of erro' } ``` ### Send Message Location ```javascript let response = await client.sendLocation("5561981590153", -15.8413105, -48.0270346, 'title optional', 'address optional'); ``` > To reply to a message with location, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendLocation("5561981590153", -15.8413105, -48.0270346, 'title optional', 'address optional', '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'location', id: '3EB01A3D9A34', to: '556181590153', name: 'title optional', address: 'address optional', url: '', thumbnail: <Buffer >, latitude: -15.8413105, longitude: -48.0270346, isgroup: false, participant: '', timestamp: 1633122748 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'location', message: 'message of erro' } ``` ### Send Message Contact ```javascript let response = await client.sendContact("5561981590153",'Name of Contact', '15815954040'); ``` > To reply to a message with contact, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendContact("5561981590153",'Name of Contact', '15815954040', '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'contact', id: '3EB00AFB1F60', to: '556181590153', display: 'Name of Contact', vcard: 'BEGIN:VCARD\n' + 'VERSION:3.0\n' + 'FN:Name of Contact\n' + 'TEL;type=CELL;type=VOICE;waid=15815954040:+15815954040\n' + 'END:VCARD', isgroup: false, timestamp: 1633128149 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'contact', message: 'message of erro' } ``` ### Send Message Link ```javascript let response = await client.sendLink("5561981590153", "https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share", 'Description optional'); ``` > To reply to a message with link, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript let response = await client.sendLink("5561981590153", "https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share", 'Description optional', '3EB01A690E67'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'link', id: '3EB0746BE9A9', to: '556181590153', content: 'https://music.youtube.com/watch?v=mqA5iMLsME8&feature=share\n' + 'Description optional', isgroup: false, timestamp: 1633130029 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'link', message: 'message of erro' } ``` ### Send Buttons Reply ```javascript const buttons = [ {buttonId: 'id1', buttonText: {displayText: 'Button 1'}, type: 1}, {buttonId: 'id2', buttonText: {displayText: 'Button 2'}, type: 1} ] let response = await client.sendButtons("5561981590153", "title of message", buttons, 'Description optional'); ``` > Use media in message header of buttons, image or optional video parameter. ```javascript let response = await client.sendButtons("5561981590153", "title of message", buttons, 'Description optional', 'image', 'https://domain.com/image.jpg'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'buttons-reply', id: '3EB071B7776A', to: '556181590153', title: 'title of message', description: 'Description optional', buttons: [ Button { buttonId: 'id1', buttonText: [ButtonText], type: 1 }, Button { buttonId: 'id2', buttonText: [ButtonText], type: 1 } ], isgroup: false, timestamp: 1633142713 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'buttons-reply', message: 'message of erro' } ``` ### Send Message Buttons ```javascript const buttons = [ {index: 1, quickReplyButton: {displayText: 'Button Normal Reply', id: 'id-123'}}, {index: 2, callButton: {displayText: 'Button Call', phoneNumber: '+55 (61) 98159-0153'}}, {index: 3, urlButton: {displayText: 'Button Link', url: 'https://stuidomedia.io'}}, ] let response = await client.sendButtonsMD("5561981590153", "title of message", buttons, 'Description optional'); ``` > Use media in message header of buttons, image or optional video parameter. ```javascript let response = await client.sendButtonsMD("5561981590153", "title of message", buttons, 'Description optional', 'image', 'https://domain.com/image.jpg'); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'buttons', id: '3EB071B7776A', to: '556181590153', title: 'title of message', description: 'Description optional', buttons: [ Button { buttonId: 'id1', buttonText: [ButtonText], type: 1 }, Button { buttonId: 'id2', buttonText: [ButtonText], type: 1 } ], isgroup: false, timestamp: 1633142713 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'buttons', message: 'message of erro' } ``` ### Send Message List > Attention! This function does not work if connected to a WhatsApp Business account ```javascript const sections = [ { title: "Bovina", rows: [ { title: "Fraudinha", rowId: "carnes1" }, { title: "Alcatra", rowId: "carnes2", description: "Carne boa" }, ], }, { title: "Suina", rows: [ { title: "Costelinha", rowId: "carnes3" }, { title: "Picanha Suina", rowId: "carnes4", description: "Carne boa", }, ], }, ]; //number of contact, name of button, sections array, title, description: optional, footer: optional let response = await const response = await client.sendList( "5561981590153", "Escolha a Carne", sections, "Escolha 1 tipo de carne", "", //Description opcional "Qual o tipo de carne vai na sua refeição?" ); ``` > To reply to a message with buttons, use the id of the message you want to reply to in the last parameter, which is optional. ```javascript //number of contact, name of button, sections array, title, description: optional, footer: optional, id message for reply let response = await const response = await client.sendList( "5561981590153", "Escolha a Carne", sections, "Escolha 1 tipo de carne", "", //Description opcional "Qual o tipo de carne vai na sua refeição?", "3EB01A690E67" ); ``` ##### Return with success ```javascript { session: 'Marketing', status: 200, type: 'list', id: '3EB0F92B3F1D', to: '556181590153', description: 'Description optional', btnName: 'Name of Button', sections: [ Section { rows: [Array], title: 'Name of section' } ], isgroup: false, timestamp: 1633143340 } ``` ##### Return with erro ```javascript { session: 'Marketing', status: 404, type: 'list', message: 'message of erro' } ``` ## Delete Message > Delete messages in chats only for you or for all Delete message only for you ```javascript //number of chat, id of message let response = await client.deleteMessageMe("5561981590153", "3EB071B7776A") ``` Delete Message to everyone on chat ```javascript //number of chat, id of message let response = await client.deleteMessageAll("5561981590153", "3EB071B7776A") ``` Return with success ```javascript { session: 'Marketing', status: 200 type: 'delete-chat-me' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'delete-chat-me', message: 'message of erro' } ``` ## Forwarding Message > Message forwarding for any contact ```javascript //number of chat, id of message, number chat for send let response = await client.forwardMessage("5561981590153", "3EB042FA6555", "15815954040") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'forwarding', subtype: 'text', id: '3EB042FA6555', from: '15815954040', text: 'oi', isgroup: false, reply: { id: undefined }, participant: '', timestamp: 1633147282 } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'forwarding', message: 'message of erro' } ``` ## Get Chats > List All Chats of Conversations ```javascript let response = await client.getChats() ``` Return with success ```javascript { session: 'Marketing', type: 'get-chats', chats: [ { id: '556181590153', name: 'Joe Dutra', mute: '0', spam: 'false' }, { id: '5511982743910-1596072761', name: 'Venom Support', mute: '0', spam: 'false' } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-chats', message: 'message of erro' } ``` ## Read Chat Messages > Read all messages from a chat ```javascript let response = await client.markReadAll('5561981590153') ``` > Read message from a chat ```javascript let response = await client.markRead('5561981590153', '3EB01A690E67') // params: Number, MessageID ``` Return with success ```javascript { session: 'Marketing', status: 200, type: "mark-read" } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'mark-read', message: 'message of erro' } ``` ## Get All Contacts > List All Contacts ```javascript let response = await client.getAllContacts() ``` Return with success ```javascript { session: 'Marketing', type: 'get-all-contacts', qt: 2, contacts: [ { id: '552123919428', name: 'Alenii Venom', short: '' }, { id: '556181590153', name: 'Joe Dutra', short: '' } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-all-contacts', message: 'message of erro' } ``` ## Get Block List > List All Contacts Blocking ```javascript let response = await client.getBlockList() ``` Return with success ```javascript { session: 'Marketing', type: 'get-block-list', list: [ '5561986268199', '5561998745252' ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-block-list', message: 'message of erro' } ``` ## Mute Chat > Silence or remove the silence of a particular chat for a specific period **Mute** ```javascript //number of chat, timer: ['hour', 'week', 'ever'] let response = await client.muteChat("5561981590153", "hour") ``` **Unmute** ```javascript //number of chat let response = await client.unmuteChat("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'mute-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'mute-chat', message: 'message of erro' } ``` ## Archive Chat > Archive or unarchive a specific chat **Archive** ```javascript //number of chat, true let response = await client.archiveChat("5561981590153", true) ``` **Unarchive** ```javascript //number of chat, false let response = await client.archiveChat("5561981590153", false) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'archive-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'archive-chat', message: 'message of erro' } ``` ## Delete Chat > Delete a specific chat or group **Archive** ```javascript //number of chat or group let response = await client.deleteChat("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'delete-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'delete-chat', message: 'message of erro' } ``` ## Pin Chat > Pin or unpin a specific chat or group **Pin** ```javascript //number of chat, true let response = await client.pinChat("5561981590153", true) ``` **Unpin** ```javascript //number of chat, false let response = await client.pinChat("5561981590153", false) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'pin-chat', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'pin-chat', message: 'message of erro' } ``` ## Block Contact > Blocking or unblocking a specific contact **Block** ```javascript //number of chat let response = await client.blockContact("5561981590153") ``` **Unblock** ```javascript //number of chat let response = await client.unblockContact("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'block-contact', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'block-contact', message: 'message of erro' } ``` ## Get Profile Status > Displays the text of the status of a specific contact ```javascript //number of chat let response = await client.getProfileStatus("5561981590153") ``` Return with success ```javascript { session: 'Marketing', type: 'get-profile-status', status: 'Que Deus seja sempre louvado em nossas vidas' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-profile-status', message: 'message of erro' } ``` ## Get Picture > Displays the image of a specific contact ```javascript //number of chat let response = await client.getPicture("5561981590153") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'get-picture', picture: 'https://pps.whatsapp.net/v/t61.24694-24/166060433_390988636021500_3494454124066997603_n.jpg?ccb=11-4&oh=453e672ddc35e64ca123439f7a89d7d2&oe=615EAAAF' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-picture', message: 'message of erro' } ``` ## Set Picture > Set image for profile or group ```javascript //number of chat, file local path let response = await client.setPicture("5561981590153", "./image-profile.png") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'set-picture' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'set-picture', message: 'message of erro' } ``` ## Get Number Profile > Checks if a number exists in the WhastApp ```javascript //number of chat let response = await client.getNumberProfile("5561981590153") ``` Return with success ```javascript { session: 'Marketing', type: 'get-number-profile', id: '556181590153', isBusiness: false, exist: true } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-number-profile', message: 'message of erro' } ``` ## Groups Functions We created the easiest way to create groups with **Superchats** ## Create Group > Create a group with participants ```javascript //name of group, array with number of contacts let response = await client.createGroup("Name Group", ["556181590153", "5561981819855"]) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'create-group', groupId: "15815954040-1631239154" } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'create-group', message: 'message of erro' } ``` ## Add Participants Group > Add participants in group ```javascript //id of group, array with number of contacts let response = await client.addParticipantsGroup("15815954040-1631239154", ["556181590153", "5561981819855"]) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'add-participants-group', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'add-participants-group', message: 'message of erro' } ``` ## Add Admins Group > Add or Remove participants of group as admin ```javascript //id of group, array with number of contacts let response = await client.addGroupAdmins("15815954040-1631239154", ["556181590153", "5561981819855"]) ``` ```javascript //id of group, array with number of contacts let response = await client.removeGroupAdmins("15815954040-1631239154", ["556181590153", "5561981819855"]) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'add-group-admins', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'add-group-admins', message: 'message of erro' } ``` ## Change Name of Group > Change name of group ```javascript //id of group, name group let response = await client.groupTitle("15815954040-1631239154", "new name of group") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'group-title', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'group-title', message: 'message of erro' } ``` ## Change Description of Group > Change description of group ```javascript //id of group, name group let response = await client.groupDescription("15815954040-1631239154", "description of group") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'group-description', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'group-description', message: 'message of erro' } ``` ## Join Group > Join a group specified ```javascript //id of group let response = await client.joinGroup("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'join-group', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'join-group', message: 'message of erro' } ``` ## Leave Group > Leaves a group specified ```javascript //id of group let response = await client.leaveGroup("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'leave-group', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'leave-group', message: 'message of erro' } ``` ## Revoke Group Link > Revoke link from a specified group ```javascript //id of group let response = await client.revokeGroupLink("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'revoke-group-link', linkGroup: 'G3M81fQbuwDB2cuAdPIv0h' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'revoke-group-link', message: 'message of erro' } ``` ## Info Group > Get info from a specified group ```javascript //id of group let response = await client.infoGroup("15815954040-1631239154") ``` Return with success ```javascript { session: 'Marketing', type: 'info-group', status: 200, id: '15795662985-1631581942', owner: '[email protected]', title: 'Teste Grupo Live', create: 1631581942, participants: [ { id: '556181590153', name: 'Joe Dutra', short: 'Joe', isAdmin: false, isSuperAdmin: false }, { id: '5521991977392', name: 'Israel - Fabrica de Sonhos', short: 'Israel - Fabrica', isAdmin: false, isSuperAdmin: false } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'info-group', message: 'message of erro' } ``` ## Set Group Settings > Get info from a specified group **Set sending messages in group only for admins** ```javascript //id of group, type, boolean let response = await client.setGroupSettings("15815954040-1631239154", "message", true) ``` **Set change settings in group only for admins** ```javascript //id of group, type, boolean let response = await client.setGroupSettings("15815954040-1631239154", "settings", true) ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'set-group-settings', } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'set-group-settings', message: 'message of erro' } ``` ## Get Groups List > Get all groups list ```javascript let response = await client.getGroups() ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'get-groups', chats: [ { id: '5511982743910-1596072761', name: 'Venom Support' }, { id: '556181590153-1625838636', name: 'Venom Business' } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-groups', message: 'message of erro' } ``` ## Get Host Device > Get info of device ```javascript let response = await client.getHostDevice() ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'get-host-device', phone: '556181590153', image: "https://pps.whatsapp.net/v/t61.24694-24/254827313_500572874791871_6168181924916411415_n.jpg?stp=dst-jpg_s96x96&ccb=11-4&oh=5ee43eb4f1fe109b10ceba05292561aa&oe=622FF53D", pushName: 'Joe Dutra' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-host-device', message: 'message of erro' } ``` ## Chat Messages Functions > Know the types of functions to recover chat messages **Take the last 10 messages from a chat** ```javascript //number of chat, Number let response = await client.getChatMessages('556181590153', 10) ``` **Take all messages from a chat** ```javascript //number of chat let response = await client.getChatAllMessages('556181590153') ``` **Take all unread messages from all chats** ```javascript let response = await client.getAllUnreadMessages() ``` Return with success ```javascript { session: 'Marketing', type: 'get-chat-messages', messages: [ { session: 'Marketing', type: 'reply', subtype: 'text', id: '3EB082EFA70F', from: '556181590153', text: 'Oi', isgroup: false, reply: [Object], participant: '', timestamp: 1633407729 }, { session: 'Marketing', type: 'text', id: '3EB0D91B1ECF', from: '556181590153', content: 'Oi', isgroup: false, participant: '', timestamp: 1633408611 }, { session: 'Marketing', type: 'text', id: '3EB0AD7A246F', from: '556181590153', content: 'Testando', isgroup: false, participant: '', timestamp: 1633411173 }, { session: 'Marketing', type: 'text', id: '46110924F9C202D3933AA4CBC2F209A3', from: '556181590153', content: 'Oi', isgroup: false, participant: '', timestamp: 1633411357 }, { session: 'Marketing', type: 'text', id: '3EB0EE5900AF', from: '556181590153', content: 'Testando', isgroup: false, participant: '', timestamp: 1633411382 }, { session: 'Marketing', type: 'text', id: '96033721D4426073C37802F407251F9A', from: '556181590153', content: 'Oi', isgroup: false, participant: '', timestamp: 1633411396 }, { session: 'Marketing', type: 'text', id: '3EB067D84A06', from: '556181590153', content: 'Testando', isgroup: false, participant: '', timestamp: 1633411746 }, { session: 'Marketing', type: 'text', id: '2CDF9BAF7E20E72BC74D602A339DA2C2', from: '556181590153', content: 'Oiiii', isgroup: false, participant: '', timestamp: 1633411781 }, { session: 'Marketing', type: 'text', id: '4DEBB46473A8E642E8764F6C70567089', from: '556181590153', content: 'Como vai???', isgroup: false, participant: '', timestamp: 1633411792 }, { session: 'Marketing', type: 'text', id: 'B536EAE6275FD6FF98F3E3326FE1682F', from: '556181590153', content: 'Top', isgroup: false, participant: '', timestamp: 1633411811 } ] } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'get-chat-messages', message: 'message of erro' } ``` ## Update Presence Update your presence for a certain contact Types of state: a = available, c = composing, r = recording, p = paused ```javascript //chat number, state: a, c, r, p let response = await client.setPresence('556181590153', 'c'); ``` Return with success ```javascript { session: 'Marketing', status: 200, type: 'set-presence' } ``` Return with erro ```javascript { session: 'Marketing', status: 404, type: 'set-presence', message: 'message of erro' } ``` ## Observation Events > Follow each event at the time that happen ### **Received Message Event** <br> > Receive an event all the time you receive a message from some contact ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onMessage: (event) => { console.log(event) }) ``` Return of event onMessage ```javascript { session: 'Marketing', type: 'text', id: '3EB07A5B9979E8CB453A', from: '556181590153', content: 'oiii', isgroup: false, participant: '', timestamp: 1633414066 } ``` ### **Reading Confirmation Event** <br> > Receive an event every time you send a message to some contact with the States of: failed, pending, sent, received or read ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onAck: (event) => { console.log(event) }) ``` Return of event onAck ```javascript { session: 'Marketing', status: 'RECEIVED', type: 'text', id: '3EB02BC6217B', to: '556181590153', text: 'Hii', isgroup: false, timestamp: 1633414317 } ``` ### **Presence Event** <br> > Receive an event every time a contact is: typing, recording, online or offline with you <br> Types of state: **available**, **composing**, **recording** and **paused** ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onPresence: (event) => { console.log(event) }) ``` Return of event onPresence ```javascript { session: 'Marketing', from: '556181590153', status: 'composing', pushname: 'Joe Dutra' } ``` ### **Group Event** <br> > Receive events all time the name of a group, configurations are changed <br> Types of return: **change-name**, **change-messages-admin**, **change-settings-admin** and **paused** ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onGroups: (event) => { console.log(event) }) ``` Return of event onGroup <br> ##### **Name change group** ```javascript { session: 'Marketing', action: 'change-name', changed: [ 'Grupo Live', 'Teste Grupo Live' ], group: 'Grupo Live', from: '15795662985-1631581942', participant: '15795662985', participants: 3 } ``` ##### **Group changes for messages just for admins** ```javascript { session: 'Marketing', action: 'change-messages-admin', changed: 'active', group: 'Grupo Live', from: '15795662985-1631581942', participant: '15795662985', participants: 3 } ``` ##### **Group changes for settings just for admins** ```javascript { session: 'Marketing', action: 'change-settings-admin', changed: 'active', group: 'Grupo Live', from: '15795662985-1631581942', participant: '15795662985', participants: 3 } ``` ### **Participants Event** <br> > Receive events about group participants <br> Types of action: **add**, **remove**, **promote** and **demote** ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onParticipants: (event) => { console.log(event) }) ``` Return of event onParticipants <br> ##### **Add participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'add', participants: 3 } ``` ##### **Remove participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'remove', participants: 2 } ``` ##### **Promote participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'promote', participants: 3 } ``` ##### **Demote participants** ```javascript { session: 'Marketing', group: 'Grupo Live', from: '15795662985-1631581942', participant: '5521991977392', action: 'demote', participants: 3 } ``` ### **Delete Event** <br> > Receive events every time a message is deleted ```javascript //event:any const client = await superchats.create({ session: "Marketing", license: "asjdh-efddff734-sdsdf834-233272", multidevice: true, // (default is false) for used whatsapp beta onDelete: (event) => { console.log(event) }) ``` Return of event onDelete <br> ```javascript { session: 'Marketing', type: 'message-delete', from: '15795662985-1631581942', id: '3EB07E88FDCF1C4EF887', timestamp: 1633453902 } ```
{ "repo_name": "orkestral/superchats", "stars": "176", "repo_language": "None", "file_name": "Docs.md", "mime_type": "text/plain" }
[flake8] max-line-length = 100
{ "repo_name": "rdegges/django-heroku-memcacheify", "stars": "100", "repo_language": "Python", "file_name": "README.md", "mime_type": "text/x-script.python" }
include README.md requirements.txt tests.py UNLICENSE recursive-include assets *.jpg
{ "repo_name": "rdegges/django-heroku-memcacheify", "stars": "100", "repo_language": "Python", "file_name": "README.md", "mime_type": "text/x-script.python" }
from os import environ # Memcache addon environment variables. # See: https://addons.heroku.com/memcache MEMCACHE_ENV_VARS = ( 'MEMCACHE_PASSWORD', 'MEMCACHE_SERVERS', 'MEMCACHE_USERNAME', ) # MemCachier addon environment variables. # See: https://addons.heroku.com/memcachier MEMCACHIER_ENV_VARS = ( 'MEMCACHIER_PASSWORD', 'MEMCACHIER_SERVERS', 'MEMCACHIER_USERNAME', ) # Memcached Cloud # See: https://addons.heroku.com/memcachedcloud MEMCACHEDCLOUD_ENV_VARS = ( 'MEMCACHEDCLOUD_PASSWORD', 'MEMCACHEDCLOUD_SERVERS', 'MEMCACHEDCLOUD_USERNAME', ) # Memcache defaults # Both Memcachier and MemcacheCloud share these CACHE_DEFAULTS = { 'BACKEND': 'django_pylibmc.memcached.PyLibMCCache', 'BINARY': True, 'OPTIONS': { 'ketama': True, 'tcp_nodelay': True, }, } def memcacheify(timeout=500): """Return a fully configured Django ``CACHES`` setting. We do this by analyzing all environment variables on Heorku, scanning for an available memcache addon, and then building the settings dict properly. If no memcache servers can be found, we'll revert to building a local memory cache. Returns a fully configured caches dict. """ caches = {} if all((environ.get(e, '') for e in MEMCACHE_ENV_VARS)): caches['default'] = CACHE_DEFAULTS caches['default'].update({ 'LOCATION': 'localhost:11211', 'TIMEOUT': timeout, }) elif all((environ.get(e, '') for e in MEMCACHIER_ENV_VARS)): servers = environ.get('MEMCACHIER_SERVERS').replace(',', ';') environ['MEMCACHE_SERVERS'] = servers environ['MEMCACHE_USERNAME'] = environ.get('MEMCACHIER_USERNAME') environ['MEMCACHE_PASSWORD'] = environ.get('MEMCACHIER_PASSWORD') caches['default'] = CACHE_DEFAULTS caches['default'].update({ 'LOCATION': servers, 'TIMEOUT': timeout, }) elif all((environ.get(e, '') for e in MEMCACHEDCLOUD_ENV_VARS)): servers = environ.get('MEMCACHEDCLOUD_SERVERS').replace(',', ';') environ['MEMCACHE_SERVERS'] = servers environ['MEMCACHE_USERNAME'] = environ.get('MEMCACHEDCLOUD_USERNAME') environ['MEMCACHE_PASSWORD'] = environ.get('MEMCACHEDCLOUD_PASSWORD') caches['default'] = CACHE_DEFAULTS caches['default'].update({ 'LOCATION': servers, 'TIMEOUT': timeout, }) elif environ.get('MEMCACHEIFY_USE_LOCAL', False): caches['default'] = { 'BACKEND': 'django_pylibmc.memcached.PyLibMCCache', } else: caches['default'] = { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', } return caches
{ "repo_name": "rdegges/django-heroku-memcacheify", "stars": "100", "repo_language": "Python", "file_name": "README.md", "mime_type": "text/x-script.python" }
flake8==2.5.1 nose==1.1.2
{ "repo_name": "rdegges/django-heroku-memcacheify", "stars": "100", "repo_language": "Python", "file_name": "README.md", "mime_type": "text/x-script.python" }
from os import environ from unittest import TestCase from memcacheify import memcacheify class Memcacheify(TestCase): def test_uses_local_memory_backend_if_no_memcache_addon_is_available(self): self.assertEqual(memcacheify(), { 'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'} }) def tests_uses_local_memory_backend_if_one_of_the_memcache_env_vars_is_missing(self): environ['MEMCACHE_PASSWORD'] = 'GCnQ9DhfEJqNDlo1' environ['MEMCACHE_SERVERS'] = 'mc3.ec2.northscale.net' self.assertEqual(memcacheify(), { 'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'} }) del environ['MEMCACHE_PASSWORD'] del environ['MEMCACHE_SERVERS'] def test_sets_proper_backend_when_memcache_addon_is_available(self): environ['MEMCACHE_PASSWORD'] = 'GCnQ9DhfEJqNDlo1' environ['MEMCACHE_SERVERS'] = 'mc3.ec2.northscale.net' environ['MEMCACHE_USERNAME'] = 'appxxxxx%40heroku.com' self.assertEqual(memcacheify()['default']['BACKEND'], 'django_pylibmc.memcached.PyLibMCCache') del environ['MEMCACHE_PASSWORD'] del environ['MEMCACHE_SERVERS'] del environ['MEMCACHE_USERNAME'] def test_uses_local_memory_backend_if_no_memcachier_addon_is_available(self): environ['MEMCACHIER_PASSWORD'] = 'xxx' environ['MEMCACHIER_SERVERS'] = 'mc1.ec2.memcachier.com' self.assertEqual(memcacheify(), { 'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'} }) del environ['MEMCACHIER_PASSWORD'] del environ['MEMCACHIER_SERVERS'] def test_sets_proper_backend_when_memcachier_addon_is_available(self): environ['MEMCACHIER_PASSWORD'] = 'xxx' environ['MEMCACHIER_SERVERS'] = 'mc1.ec2.memcachier.com' environ['MEMCACHIER_USERNAME'] = 'xxx' caches = memcacheify() self.assertEqual(caches['default']['BACKEND'], 'django_pylibmc.memcached.PyLibMCCache') self.assertEqual(environ['MEMCACHE_SERVERS'], environ['MEMCACHIER_SERVERS']) self.assertEqual(environ['MEMCACHE_USERNAME'], environ['MEMCACHIER_USERNAME']) self.assertEqual(environ['MEMCACHE_PASSWORD'], environ['MEMCACHIER_PASSWORD']) del environ['MEMCACHIER_PASSWORD'] del environ['MEMCACHIER_SERVERS'] del environ['MEMCACHIER_USERNAME'] del environ['MEMCACHE_PASSWORD'] del environ['MEMCACHE_SERVERS'] del environ['MEMCACHE_USERNAME'] def test_sets_proper_backend_when_memcachedcloud_addon_is_available(self): environ['MEMCACHEDCLOUD_PASSWORD'] = 'xyz' environ['MEMCACHEDCLOUD_SERVERS'] = 'zzzz' environ['MEMCACHEDCLOUD_USERNAME'] = 'xyzzy' caches = memcacheify() self.assertEqual(caches['default']['BACKEND'], 'django_pylibmc.memcached.PyLibMCCache') self.assertEqual(environ['MEMCACHE_SERVERS'], environ['MEMCACHEDCLOUD_SERVERS']) self.assertEqual(environ['MEMCACHE_USERNAME'], environ['MEMCACHEDCLOUD_USERNAME']) self.assertEqual(environ['MEMCACHE_PASSWORD'], environ['MEMCACHEDCLOUD_PASSWORD']) del environ['MEMCACHEDCLOUD_PASSWORD'] del environ['MEMCACHEDCLOUD_SERVERS'] del environ['MEMCACHEDCLOUD_USERNAME'] del environ['MEMCACHE_PASSWORD'] del environ['MEMCACHE_SERVERS'] del environ['MEMCACHE_USERNAME']
{ "repo_name": "rdegges/django-heroku-memcacheify", "stars": "100", "repo_language": "Python", "file_name": "README.md", "mime_type": "text/x-script.python" }
from os.path import abspath, dirname, join, normpath from setuptools import setup setup( # Basic package information: name='django-heroku-memcacheify', version='1.0.1', py_modules=('memcacheify',), # Packaging options: zip_safe=False, include_package_data=True, # Package dependencies: install_requires=['django-pylibmc>=0.6.1'], # Metadata for PyPI: author='Randall Degges', author_email='[email protected]', license='UNLICENSE', url='https://github.com/rdegges/django-heroku-memcacheify', keywords='django heroku cloud cache memcache memcached awesome epic', classifiers=[ 'Framework :: Django', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.5', ], description='Automatic Django memcached configuration on Heroku.', long_description=open(normpath(join(dirname(abspath(__file__)), 'README.md'))).read(), long_description_content_type='text/markdown' )
{ "repo_name": "rdegges/django-heroku-memcacheify", "stars": "100", "repo_language": "Python", "file_name": "README.md", "mime_type": "text/x-script.python" }
# django-heroku-memcacheify Automatic Django memcached configuration on Heroku. ![Deploying memcached is easy](https://github.com/rdegges/django-heroku-memcacheify/raw/master/assets/memcacheify.jpg) ## Install To install ``django-heroku-memcacheify``, simply run ``pip install django-heroku-memcacheify`` and you'll get the latest version installed automatically. **NOTE**: If you'd like to install this locally, you'll need to have the ``libmemcached-dev`` libraries installed for this to compile properly. On Debian and Ubuntu you can install this by running ``sudo aptitude -y install libmemcached-dev``. If you're using a Mac, you can use [homebrew](http://mxcl.github.com/homebrew/) and run ``brew install libmemcached``. ## Usage Modify your Django ``settings.py`` file, and set: ``` python from memcacheify import memcacheify CACHES = memcacheify() ``` Next, ensure pylibmc is present in your ``requirements.txt`` file (or one included from it), so the Heroku Python buildpack will detect the necessary C dependencies and 'bootstrap' your application. Assuming you have a memcache server available to your application on Heroku, it will instantly be available. If you have no memcache addon provisioned for your app, ``memcacheify`` will default to using local memory caching as a backup :) ## Heroku Setup Now that you've got Django configured to use memcache, all you need to do is install one memcache addons that Heroku provides! I personally recommend [MemCachier](https://addons.heroku.com/memcachier) -- they're stable, cheap, great! Let's say I want to install the ``memcachier`` addon, I could simply run: ``` bash $ heroku addons:add memcachier:25 $ heroku config ... MEMCACHIER_SERVERS => memcachier1.example.net MEMCACHIER_USERNAME => bobslob MEMCACHIER_PASSWORD => l0nGr4ndoMstr1Ngo5strang3CHaR4cteRS ... ``` The example above will provision a *free* 25m memcache server for your application. Assuming everything worked, ``heroku config``'s output should show that you now have 3 new environment variables set. ## Local Development If you have a memcached server locally for development that doesn't support authentication, you can still use memcache by setting an environment variable `MEMCACHEIFY_USE_LOCAL=True`. This will set the default cache to `django_pylibmc.memcached.PyLibMCCache` If there are no environment variables for memcache or memcacheify, the default cache will be local memory `django.core.cache.backends.locmem.LocMemCache`. ## Testing Your Cache If you don't trust me, and want to make sure your caching is working as expected, you may do the following: ``` bash $ heroku run python manage.py shell Running python manage.py shell attached to terminal... up, run.1 Python 2.7.2 (default, Oct 31 2011, 16:22:04) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.core.cache import cache >>> cache.set('memcache', 'ify!') True >>> cache.get('memcache') 'ify!' >>> ``` Assuming everything is working, you should be able to set and retrieve cache keys. ## References If you're confused, you should probably read: - [Heroku's Getting Started Guide](http://devcenter.heroku.com/articles/django) - [Heroku's memcachier Addon Documentation](https://devcenter.heroku.com/articles/memcachier) ## Tests [![Build Status](https://secure.travis-ci.org/rdegges/django-heroku-memcacheify.png?branch=master)](http://travis-ci.org/rdegges/django-heroku-memcacheify) Want to run the tests? No problem: ``` bash $ git clone git://github.com/rdegges/django-heroku-memcacheify.git $ cd django-heroku-memcacheify $ python setup.py develop ... $ pip install -r requirements.txt # Install test dependencies. $ flake8 $ nosetests ............. ---------------------------------------------------------------------- Ran 13 tests in 0.166s OK ``` ## Changelog v1.0.1: 10-10-2021 - Fixing PyPI description v1.0.0: 01-04-2016 - Update django-pylibmc dependency to >=0.6.1. - Officially support Python 3.5. - Stop testing on Python 2.6. v0.8: 11-12-2014 - Adding support for memcachedcloud! v0.7: 9-22-2014 - Upgrading dependencies (again)! v0.6: 9-20-2014 - Upgrading dependencies. v0.5: 12-31-2013 - Making the timeout option configurable. - Removing Python 2.5 support. - Adding an option to use memcached locally without SASL. - Updating the README, explaining how to use memcached locally. v0.4: 12-5-2012 - Update which allows memcachier users to support multiple servers >:) Thanks @alexlod! v0.3: 6-27-2012 - Fixing broken memcachier support. v0.2: 5-22-2012 - Adding support for memcachier Heroku addon. - Updating documentation. - Refactoring implementation for clarity. - Adding better tests. v0.1: 5-2-2012 - Initial release!
{ "repo_name": "rdegges/django-heroku-memcacheify", "stars": "100", "repo_language": "Python", "file_name": "README.md", "mime_type": "text/x-script.python" }
# Contribution Guidelines Ensure your pull request adheres to the following guidelines: - This list is geared towards haxe4 content, if you find a library made made for haxe3 relevant enough for study or legacy add it to its own succinct section at the bottom of the category. - Use the existing style format for each section. - Keep descriptions short and simple. - Start the description with a capital. - Check your spelling and grammar. - Order alphabetically Thank you for your contributions! 🙏
{ "repo_name": "Dvergar/awesome-haxe-gamedev", "stars": "343", "repo_language": "Haxe", "file_name": "awesome-lint.yml", "mime_type": "text/plain" }
# Community list ## Games |Game |Platform |Engine |Screenshot | |----------------------------------------------------------------------------|--------------------|-------------------|----------------------------------------------| |[Squash The Creeps](https://github.com/HxGodot/squash-the-creeps-3d-hxgodot)|Desktop |HxGodot |![Screenshot](images/squash-the-creeps.jpg) | |[Friday Night Funkin'](https://ninja-muffin24.itch.io/funkin) |Desktop |HaxeFlixel (OpenFL)|![Screenshot](images/friday-night-funkin.jpg) |
{ "repo_name": "Dvergar/awesome-haxe-gamedev", "stars": "343", "repo_language": "Haxe", "file_name": "awesome-lint.yml", "mime_type": "text/plain" }
<div align="center"><a href="https://haxe.org/"><img src="images/haxe-logo.png" width="500"></a></div> # Awesome Haxe Game Development [![Awesome](https://awesome.re/badge-flat2.svg)](https://awesome.re) A curated list of game development resources for **[Haxe 4](https://haxe.org/)**, a high level strictly typed programming language which is used to produce cross-platform native code. Feel free to update it. ## Contents * [Game engines](#game-engines) * [Low-level Engine](#low-level-engine) * [Physics](#physics) * [Architecture](#architecture) * [Networking](#networking) * [Serialization and storage](#serialization-and-storage) * [Games](#games) * [Miscellaneous](#miscellaneous) * [Articles](#articles) * [Other haxe lists](#other-haxe-lists) ## Game engines Those are Haxe 4 compatible game engines * [Armory (Kha)](https://github.com/armory3d/armory) - An open-source 3D game engine with full Blender integration (`Web`, `Mobile`, `Desktop`, `Consoles`). * [Away3D](https://github.com/openfl/away3d) - An open source, real-time 3D engine for OpenFL (`Web`, `Mobile`, `Desktop`). * [ceramic](https://github.com/ceramic-engine/ceramic) - Cross-platform 2D framework (`Web`, `Mobile`, `Desktop`, `Unity`). * [HaxeFlixel (OpenFL)](https://github.com/HaxeFlixel/flixel) - Free, cross-platform 2D game engine powered by OpenFL (`Web`, `Mobile`, `Desktop`, `Consoles`). * [Haxegon (OpenFL)](https://github.com/haxegon/haxegon) - A programming library for beginners. Powered by OpenFL and Starling (`Web`, `Mobile`, `Desktop`, `Consoles`). * [Heaps](https://github.com/HeapsIO/heaps) - High Performance Game Framework (`Web`, `Mobile`, `Desktop`, `Consoles`). * [hxdefold](https://github.com/hxdefold/hxdefold) - Haxe/Lua externs for Defold game engine (`Web`, `Mobile`, `Desktop`). * [OpenFL](https://github.com/openfl/openfl) - Interactive game and app development library (`Web`, `Mobile`, `Desktop`, `Consoles`). * [Starling](https://github.com/openfl/starling) - The "Cross-Platform Game Engine", a popular Stage3D framework (`Web`, `Mobile`, `Desktop`). * [Stencyl (OpenFL)](https://github.com/Stencyl/stencyl-engine) - Create Flash, HTML5, iOS, Android, and desktop games with no code (`Mobile`, `Desktop`). * [unreal.hx](https://github.com/proletariatgames/unreal.hx) - Haxe Integration for Unreal (`Web`, `Mobile`, `Desktop`, `Consoles`). * [HxGodot (Godot 4.0)](https://github.com/HxGodot/hxgodot) - A Haxe GDExtension for Godot 4 (`Web`, `Mobile`, `Desktop`, `Consoles`). ## Low-level Engine * [Kha](https://github.com/Kode/Kha) - Ultra-portable, high performance, open source multimedia framework (`Web`, `Mobile`, `Desktop`, `Consoles`). * [Lime](https://github.com/openfl/lime) - A flexible, lightweight layer for Haxe cross-platform developers (`Web`, `Mobile`, `Desktop`). * [linc_glfw](https://github.com/Sunjammer/linc_glfw) - Desktop - GLFW binding (multi-platform library for OpenGL, OpenGL ES and Vulkan) _(Desktop)_. * [NME](https://github.com/haxenme/nme) - A cross-platform native backend (`Web`, `Mobile`, `Desktop`). * [3DSHaxe](https://github.com/Krismowo/3DSHaxe) - Make 3ds homebrew! (`3DS`). ## Physics * [echo](https://github.com/AustinEast/echo/) - Simple Physics Library. * [haxebullet](https://github.com/armory3d/haxebullet) - Bullet 3D Physics. * [nape-haxe4](https://github.com/HaxeFlixel/nape-haxe4) - Physics Engine (the original Haxe3 version of nape can be found [here](https://github.com/deltaluca/nape)). ## Architecture ``` IoC == Inversion of Control EC == Entity Component ECS == Entity-Component-System FSM == Finite State Machine MVC == Model View Controller ``` * [awe6](https://github.com/hypersurge/awe6) - `IoC`, `EC` - The inverted game framework, is a development tool focused on Future Proofing. * [ecx](https://github.com/eliasku/ecx) - `ECS` - An Entity Component System framework. * [hexMachina](https://github.com/DoclerLabs/hexCore) - `MVC` - A powerful multi-modular MVC framework. * [OSIS](https://github.com/Dvergar/OSIS) - `ECS` - Entity Component System architecture with networking support. ## Networking * [Anette](https://github.com/Dvergar/Anette) - Simple network library (no UDP). * [colyseus-hx](https://github.com/colyseus/colyseus-hx) - Multiplayer Game Client. * [haxe-simple-peer (js)](https://github.com/melonin/haxe-simple-peer) - Haxe externs for simple-peer. * [hxWebSockets](https://github.com/ianharrigan/hxWebSockets) - Websockets for all platforms. * Built-in - Heaps, OpenFL (HaxeFlixel & co), Kha (Armory). ## Serialization and storage * [Bits](https://github.com/RealyUniqueName/Bits) - Binary bit flags with unlimited amount of bits. * [CastleDB](https://github.com/ncannasse/castle) - A structured static database easing collaboration. * [hxbit](https://github.com/ncannasse/hxbit) - A binary serialization and network synchronization library. * [PODStream](https://github.com/Dvergar/PODStream) - Plain Old Data serializer. <!--lint disable awesome-list-item--> ## Games * [Darksburg](https://store.steampowered.com/app/939100/Darksburg/) - Heaps - `Desktop`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/darksburg.jpg) * [Dead Cells](https://dead-cells.com/) - Heaps - `Desktop`, `Consoles`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/dead-cells.jpg) * [Defender's Quest](http://www.defendersquest.com/) - HaxeFlixel (OpenFL) - `Desktop`, `Consoles`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/defenders-quest.jpg) * [Defender's Quest 2](https://store.steampowered.com/app/252190/Defenders_Quest_2_Mists_of_Ruin/) - HaxeFlixel (OpenFL) - `Desktop`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/defenders-quest-2.jpg) * [Dicey Dungeons](http://diceydungeons.com/) - Haxegon (OpenFL) - `Desktop`, `Consoles`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/dicey-dungeons.jpg) * [Evoland](http://evoland.shirogames.com/) - Heaps - `Desktop`, `Mobile`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/evoland.jpg) * [Northgard](http://northgard.net/) - Heaps - `Desktop`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/northgard.jpg) * [Papers, Please](http://papersplea.se/) - OpenFL - `Desktop`, `iOS`, `PsVita`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/papers-please.jpg) * [Pocket Kingdom](https://store.steampowered.com/app/462620/Pocket_Kingdom/) - HaxePunk (OpenFL)- `Desktop`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/pocket-kingdom.jpg) * [rymdkapsel](https://rymdkapsel.com/) - OpenFL - `Desktop`, `Mobile`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/rymdkapsel.jpg) * [Spellbreak](https://playspellbreak.com/) - unreal.hx - `PC`, `PS`, `Xbox`, `Switch`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/spellbreak.jpg) * [The Westport Independent](http://www.doublezeroonezero.com/westport.html) - Luxe - `Desktop`, `Mobile`. * ![Screenshot](https://raw.githubusercontent.com/Dvergar/awesome-haxe-gamedev/main/images/westport-independent.jpg) <!--lint enable--> More showcase : * [OpenFL showcase](https://www.openfl.org/showcase) * [HaxeFlixel showcase](https://haxeflixel.com/showcase/) * [itch.io showcase](https://itch.io/games/made-with-haxe) * [HaxePunk showcase](https://haxepunk.com/games/) * [Flambe showcase](https://github.com/aduros/flambe/wiki/Showcase) * [Kha showcase](https://github.com/Kode/Kha/wiki/Games-Built-With-Kha) ## Miscellaneous ### 3rd party API * [SteamWrap](https://github.com/larsiusprime/SteamWrap) - Native extension for the SteamAPI. * [newgrounds](https://lib.haxe.org/p/newgrounds) - Newgrounds API. * [hxgamejolt-api](https://github.com/MAJigsaw77/hxgamejolt-api) - Haxe bindings for GameJolt API. ### AI [goap](https://gitlab.com/haath/goap) - Goal-oriented action planner for AI. ### Animation * [spine-hx](https://github.com/jeremyfa/spine-hx) - Spine runtime automatically converted from the official Java/libgdx runtime. * HaxeFlixel - Spine parser. * [Heaps-Spine](https://github.com/Beeblerox/Heaps-Spine) - Spine player for heaps. * [heaps-aseprite](https://github.com/AustinEast/heaps-aseprite) - Load and render sprites and animations in Aseprite format. * [openfl-aseprite](https://github.com/miriti/openfl-aseprite) - Load and render sprites and animations in Aseprite format. * [openfl-spine](https://github.com/rainyt/openfl-spine) - Render Spine animation in the OpenFL engine, rendering processing can be achieved throughSprite and Tilemap. * [ase](https://github.com/miriti/ase) - File format reader/writer for .ase/.aseprite without external dependencies. * [flxgif](https://github.com/MAJigsaw77/flxgif) - Yagp's Gif Player for HaxeFlixel. ### Audio * [sfxr-hx](https://github.com/jobf/sfxr-hx) - Pure haxe implementation of Sfxr. ### Color manipulation * [nxColor](https://github.com/oscarcs/nxColor) - Color manipulation library. ### Collision * [differ](https://github.com/snowkit/differ) - A separation axis theorem collision library. ### Computer Vision * [Vision](https://github.com/ShaharMS/Vision) - Cross platform computer vision library. ### Data structures * [polygonal-ds](https://github.com/polygonal/ds) - Data structures for games. ### Editor * [flixel-studio](https://github.com/Dovyski/flixel-studio) - In-game editor for HaxeFlixel. ### Helpers * [deepnightLibs](https://github.com/deepnight/deepnightLibs) - General gamedev purpose libs. |Procedural generation|[Dungeon builder](https://github.com/julsam/dungeon-builder) - A set of dungeon generation algorithm (works w/ hx4 w/ minor changes). ### Localization * [firetongue](https://github.com/larsiusprime/firetongue) - A translation/localization framework. ### Map parser * [PyxelEdit Map Importer](https://github.com/Dvergar/PyxelEdit-Map-Importer) - Parser for maps generated by the editor PyxelEdit. * Heaps - Built-in parser for Tiled. * HaxeFlixel - Parser for Tiled & Ogmo. * [LEd](https://github.com/deepnight/led-haxe-api) - 2D level editor with a typed compile time loader. * [TiledHX](https://github.com/yanrishatum/tiledhx) - A comprehensive modern Tiled parser. ### Math helpers * [hxmath](https://github.com/tbrosman/hxmath) - A game-oriented math library. * [haxe-glm](https://github.com/hamaluik/haxe-glm) - A toolset for using 2, 3, and 4 dimensional vectors and matrices, as well as quaternions. * [hx-vector2d](https://github.com/markknol/hx-vector2d) - Worlds most complete Vector2d / Point class. With operator overloading. ### Modding * [polymod](https://github.com/larsiusprime/polymod) - An atomic modding framework for games/apps. ### Particles * [Sparkler](https://github.com/RudenkoArts/sparkler) - Modular Particle System. ### Monetization * [extension-iap](https://github.com/charmdev/extension-iap) - Provides an access to in-app purchases (iOS) and in-app billing (Android) for OpenFL projects using a common API. Fork of [this](https://github.com/HaxeExtension/extension-iap). ### Pathfinding * [pathfinder](https://github.com/hypersurge/pathfinder) - Easy A* pathfinding algorithm. * [astar](https://gitlab.com/haath/astar) - Versatile framework-agnostic A-star solver Library. ### Shaders * [HGSL](https://github.com/saharan/HGSL) - Haxe to GL Shading Language. * [parasol](https://github.com/47rooks/parasol) - HaxeFlixel library of shaders. ### Sprite * [haxe-aseprite](https://github.com/PongoEngine/haxe-aseprite) - Parser for .ase and .aseprite files. ### Texture Packer * [hxpk](https://github.com/bendmorris/hxpk) - Port of the libGDX Texture Packer. ### Tweening * [actuate](https://github.com/jgranick/actuate) - A flexible, fast "tween" library. * [YATL](https://github.com/Yanrishatum/yatl) - Yet Another (Haxe) Tweening Library. * [TweenX/TweenXCore](https://github.com/shohei909/tweenx) - Tween library. ### UI * [domkit](https://github.com/ncannasse/domkit) - CSS Components based strictly typed UI framework. * [flixel-ui](https://github.com/HaxeFlixel/flixel-ui) - GUI library for HaxeFlixel. * [HaxeUI](http://haxeui.org/) - UI library with multiple framework backends (HTML5, Kha, OpenFL, PixiJS, WxWidgets, and a number of others as works in progress). * [Feathers UI](https://feathersui.com/) - Cross-platform graphical user interface components for creative frontend projects. ### Video * [hxCodec](https://github.com/polybiusproxy/hxCodec) - Adds native video playback on HaxeFlixel and OpenFL. ## Articles * [Flash is dead, long live OpenFL!](http://gamasutra.com/blogs/LarsDoucet/20140318/213407/Flash_is_dead_long_live_OpenFL.php) * [Flash is gone, what now?](https://www.linkedin.com/pulse/flash-gone-what-now-matan-uberstein/) * [How I wrote my own 3D game engine and shipped a game with it in 20 months](https://kircode.com/post/how-i-wrote-my-own-3d-game-engine-and-shipped-a-game-with-it-in-20-months) * [Building 42 games within a year — Insane game development](https://medium.com/@mknol/building-42-games-within-a-year-insane-game-development-5340d506068f) * [Porting to console via Unity](https://do-games.com/blog/the-adventure-pals-console-tech-part1) ## Other haxe lists * [awesome haxe](https://github.com/nadako/awesome-haxe) * [awesome snowkit](https://github.com/anissen/awesome-snowkit) * [awesome haxe js](https://github.com/MatthijsKamstra/awesome-haxe-js)
{ "repo_name": "Dvergar/awesome-haxe-gamedev", "stars": "343", "repo_language": "Haxe", "file_name": "awesome-lint.yml", "mime_type": "text/plain" }
name: CI on: push: branches: [main] pull_request: branches: [main] jobs: Awesome_Lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 - run: npx awesome-lint
{ "repo_name": "Dvergar/awesome-haxe-gamedev", "stars": "343", "repo_language": "Haxe", "file_name": "awesome-lint.yml", "mime_type": "text/plain" }
 Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.32228.343 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mspaintCompanion", "mspaintCompanion.csproj", "{D31FB0D3-8D7C-4068-AD19-5BD098A68B31}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {D31FB0D3-8D7C-4068-AD19-5BD098A68B31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D31FB0D3-8D7C-4068-AD19-5BD098A68B31}.Debug|Any CPU.Build.0 = Debug|Any CPU {D31FB0D3-8D7C-4068-AD19-5BD098A68B31}.Release|Any CPU.ActiveCfg = Release|Any CPU {D31FB0D3-8D7C-4068-AD19-5BD098A68B31}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9EA1A2DE-C171-4F0B-9148-A58EBBEF7643} EndGlobalSection EndGlobal
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
using System; using System.Diagnostics; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Windows.Forms; using System.Drawing; using System.ComponentModel; using System.Threading; namespace mspaintCompanion { public partial class Main : Form { [DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hWnd); public static Layer ActiveLayer; public static List<Layer> Layers = new List<Layer>(); public static Process mspaint; public static FlowLayoutPanel _LayerPanel; public static Screen Monitor => Screen.FromHandle(Main.mspaint.Handle); public Main() { InitializeComponent(); //check to see if mspaint is open, if its not then open it if (Process.GetProcessesByName("mspaint").Length == 0) mspaint = Process.Start("mspaint"); else mspaint = Process.GetProcessesByName("mspaint")[0]; _LayerPanel = LayerPanel; //create initial layer new Layer(); } public static void MoveLayer(Control child, int newIndex) { _LayerPanel.Controls.SetChildIndex(child, newIndex); for (int i = 0; i < Layers.Count; i++) { Layers[i].index = i; } _LayerPanel.Refresh(); } public static Color TransparentColor = Color.White; public static Image GetCanvasImage() { Clipboard.Clear(); IntPtr hwnd = Main.mspaint.MainWindowHandle; SetForegroundWindow(hwnd); while (Clipboard.ContainsImage() == false) { SendKeys.SendWait("^a"); SendKeys.SendWait("^c"); } Image i = Clipboard.GetImage(); return i; } public static void EraseCanvas() { IntPtr hwnd = Main.mspaint.MainWindowHandle; if (SetForegroundWindow(hwnd)) { SendKeys.SendWait("^a"); SendKeys.SendWait("{DEL}"); } } public static void UpdateLayer(Layer layerToChange, Image replace) { if (layerToChange == null) return; layerToChange.fullres = replace; layerToChange.RefreshThumbnail(); } public static void UpdateActive() { for (int i = 0; i < Layers.Count; i++) Layers[i].SetInactiveLayer(); //LayerRenderer.Inst.UpdateRenderer(); } private void AddLayer_Click(object sender, EventArgs e) { new Layer(); EraseCanvas(); LayerRenderer.Inst.UpdateRenderer(); } public static void DeleteLayer(Layer layer) { if (Layers.Count == 1) return; Layer oldLayer = layer; Layer.SetActiveLayer(Layers[0]); Layers.Remove(oldLayer); oldLayer.Dispose(); LayerRenderer.Inst.UpdateRenderer(); } public static void UpdateLayerTags() { for (int i = 0; i < Layers.Count; i++) { Layers[i].UpdateLayerTag(); } } private void DeleteButton_Click(object sender, EventArgs e) { DeleteLayer(ActiveLayer); } private void transparency_Click(object sender, EventArgs e) { if (TransparencyColor.ShowDialog() == DialogResult.OK) { TransparentColor = TransparencyColor.Color; } } //i should definitely just make an export method that takes a parameter structure but. ill do it later probs. private void ExportButton_Click(object sender, EventArgs e) { Image CurrentLayer = GetCanvasImage(); UpdateLayer(ActiveLayer, CurrentLayer); Size imageSize = CurrentLayer.Size; Bitmap o = new Bitmap(imageSize.Width, imageSize.Height); using (Graphics gr = Graphics.FromImage(o)) { using (SolidBrush brush = new SolidBrush(Main.TransparentColor)) { gr.FillRectangle(brush, 0, 0, imageSize.Width, imageSize.Height); } for (int i = Layers.Count - 1; i >= 0; i--) { if (Layers[i].IsLayerVisible) { Bitmap toDraw = new Bitmap(Layers[i].fullres); toDraw.MakeTransparent(Main.TransparentColor); gr.DrawImage(toDraw, Point.Empty); } } } Random r = new Random(); string[] randomFileNames = { "awesome drawing", "nice work", "wonderful art", "beautiful", "looks great", "lovely", "stunning" }; ExportDialog.FileName = randomFileNames[r.Next(0, randomFileNames.Length)]; if (ExportDialog.ShowDialog() == DialogResult.OK) o.Save(ExportDialog.FileName); } private void ExportButton_Transparent_Click(object sender, EventArgs e) { Image CurrentLayer = GetCanvasImage(); UpdateLayer(ActiveLayer, CurrentLayer); Size imageSize = CurrentLayer.Size; Bitmap o = new Bitmap(imageSize.Width, imageSize.Height); using (Graphics gr = Graphics.FromImage(o)) { for (int i = Layers.Count - 1; i >= 0; i--) { if (Layers[i].IsLayerVisible) { Bitmap toDraw = new Bitmap(Layers[i].fullres); toDraw.MakeTransparent(Main.TransparentColor); gr.DrawImage(toDraw, Point.Empty); } } } Random r = new Random(); string[] randomFileNames = { "awesome drawing", "nice work", "wonderful art", "beautiful", "looks great", "lovely", "stunning" }; ExportDialog.FileName = randomFileNames[r.Next(0, randomFileNames.Length)]; if (ExportDialog.ShowDialog() == DialogResult.OK) o.Save(ExportDialog.FileName); } private void Main_FormClosing(object sender, FormClosingEventArgs e) { LayerRenderer.Inst.Close(); } } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
using System; using System.Drawing; using System.Drawing.Imaging; using System.Threading; using System.Windows.Forms; namespace mspaintCompanion { public partial class LayerRenderer : Form { static LayerRenderer inst; public static LayerRenderer Inst { get { if (inst == null) { inst = new LayerRenderer(); Console.WriteLine("fuck"); } return inst; } } public LayerRenderer() { InitializeComponent(); BackColor = Main.TransparentColor; Rectangle canvas = Main.Monitor.Bounds; Bounds = canvas; this.StartPosition = FormStartPosition.Manual; this.Location = new Point(5, 150); //ORIGINALLY 5, 150 AllowTransparency = true; TransparencyKey = Main.TransparentColor; BackgroundImageLayout = ImageLayout.None; inst = this; } public void UpdateRenderer() { if (Main.Layers.Count == 0) return; //also a failsafe Size = Main.GetCanvasImage().Size; BackgroundImage = GenerateImage(Main.Layers.ToArray(), Size); } static Image GenerateImage(Layer[] layers, Size size) { Bitmap o = new Bitmap(size.Width, size.Height); using (Graphics g = Graphics.FromImage(o)) { for (int i = layers.Length - 1; i >= 0; i--) { if (layers[i].IsLayerVisible && !layers[i].IsLayerActive) { Bitmap toDraw = new Bitmap(layers[i].fullres); toDraw.MakeTransparent(Main.TransparentColor); g.DrawImage(toDraw, Point.Empty); } } } return o; } protected override CreateParams CreateParams { get { CreateParams createParams = base.CreateParams; createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT return createParams; } } } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> </startup> </configuration>
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{D31FB0D3-8D7C-4068-AD19-5BD098A68B31}</ProjectGuid> <OutputType>WinExe</OutputType> <RootNamespace>mspaintCompanion</RootNamespace> <AssemblyName>mspaintCompanion</AssemblyName> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <Deterministic>true</Deterministic> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Debug\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PlatformTarget>AnyCPU</PlatformTarget> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <PropertyGroup> <ApplicationIcon>icon.ico</ApplicationIcon> </PropertyGroup> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Deployment" /> <Reference Include="System.Drawing" /> <Reference Include="System.Net.Http" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> <Compile Include="Form1.cs"> <SubType>Form</SubType> </Compile> <Compile Include="Form1.Designer.cs"> <DependentUpon>Form1.cs</DependentUpon> </Compile> <Compile Include="Layer.cs"> <SubType>UserControl</SubType> </Compile> <Compile Include="Layer.Designer.cs"> <DependentUpon>Layer.cs</DependentUpon> </Compile> <Compile Include="LayerRenderer.cs"> <SubType>Form</SubType> </Compile> <Compile Include="LayerRenderer.Designer.cs"> <DependentUpon>LayerRenderer.cs</DependentUpon> </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <EmbeddedResource Include="Form1.resx"> <DependentUpon>Form1.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="Layer.resx"> <DependentUpon>Layer.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="LayerRenderer.resx"> <DependentUpon>LayerRenderer.cs</DependentUpon> </EmbeddedResource> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> <SubType>Designer</SubType> <LastGenOutput>Resources.Designer.cs</LastGenOutput> </EmbeddedResource> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> </None> <Compile Include="Properties\Resources.Designer.cs"> <AutoGen>True</AutoGen> <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> <Compile Include="Properties\Settings.Designer.cs"> <AutoGen>True</AutoGen> <DependentUpon>Settings.settings</DependentUpon> <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> </ItemGroup> <ItemGroup> <None Include="App.config" /> </ItemGroup> <ItemGroup> <Content Include="icon.ico" /> <Content Include="Resources\placeholder.png" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
<?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> </root>
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
 namespace mspaintCompanion { partial class Layer { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Component Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.isVisible = new System.Windows.Forms.CheckBox(); this.LayerThumbnail = new System.Windows.Forms.PictureBox(); this.Active = new System.Windows.Forms.CheckBox(); this.ActiveLabel = new System.Windows.Forms.Label(); this.MoveLayerUp = new System.Windows.Forms.Button(); this.MoveLayerDown = new System.Windows.Forms.Button(); this.LayerLabel = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.LayerThumbnail)).BeginInit(); this.SuspendLayout(); // // isVisible // this.isVisible.AutoSize = true; this.isVisible.Checked = true; this.isVisible.CheckState = System.Windows.Forms.CheckState.Checked; this.isVisible.Location = new System.Drawing.Point(5, 28); this.isVisible.Name = "isVisible"; this.isVisible.Size = new System.Drawing.Size(15, 14); this.isVisible.TabIndex = 0; this.isVisible.UseVisualStyleBackColor = true; this.isVisible.CheckStateChanged += new System.EventHandler(this.onLayerVisiblityToggled); // // LayerThumbnail // this.LayerThumbnail.BackColor = System.Drawing.SystemColors.Window; this.LayerThumbnail.Location = new System.Drawing.Point(29, 7); this.LayerThumbnail.Name = "LayerThumbnail"; this.LayerThumbnail.Size = new System.Drawing.Size(78, 58); this.LayerThumbnail.TabIndex = 1; this.LayerThumbnail.TabStop = false; // // Active // this.Active.AutoSize = true; this.Active.Location = new System.Drawing.Point(400, 27); this.Active.Name = "Active"; this.Active.Size = new System.Drawing.Size(15, 14); this.Active.TabIndex = 3; this.Active.UseVisualStyleBackColor = true; this.Active.Click += new System.EventHandler(this.Active_Click); // // ActiveLabel // this.ActiveLabel.AutoSize = true; this.ActiveLabel.Font = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.ActiveLabel.Location = new System.Drawing.Point(382, 25); this.ActiveLabel.Name = "ActiveLabel"; this.ActiveLabel.Size = new System.Drawing.Size(51, 16); this.ActiveLabel.TabIndex = 4; this.ActiveLabel.Text = "ACTIVE"; this.ActiveLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // MoveLayerUp // this.MoveLayerUp.Location = new System.Drawing.Point(457, -1); this.MoveLayerUp.Name = "MoveLayerUp"; this.MoveLayerUp.Size = new System.Drawing.Size(20, 27); this.MoveLayerUp.TabIndex = 5; this.MoveLayerUp.Text = "↑"; this.MoveLayerUp.UseVisualStyleBackColor = true; this.MoveLayerUp.Click += new System.EventHandler(this.MoveLayerUp_Click); // // MoveLayerDown // this.MoveLayerDown.Location = new System.Drawing.Point(457, 44); this.MoveLayerDown.Name = "MoveLayerDown"; this.MoveLayerDown.Size = new System.Drawing.Size(20, 27); this.MoveLayerDown.TabIndex = 6; this.MoveLayerDown.Text = "↓"; this.MoveLayerDown.UseVisualStyleBackColor = true; this.MoveLayerDown.Click += new System.EventHandler(this.MoveLayerDown_Click); // // LayerLabel // this.LayerLabel.AutoSize = true; this.LayerLabel.Location = new System.Drawing.Point(114, 28); this.LayerLabel.Name = "LayerLabel"; this.LayerLabel.Size = new System.Drawing.Size(36, 15); this.LayerLabel.TabIndex = 7; this.LayerLabel.Text = "label1"; // // Layer // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlDarkDark; this.Controls.Add(this.LayerLabel); this.Controls.Add(this.MoveLayerDown); this.Controls.Add(this.MoveLayerUp); this.Controls.Add(this.ActiveLabel); this.Controls.Add(this.Active); this.Controls.Add(this.LayerThumbnail); this.Controls.Add(this.isVisible); this.Font = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Name = "Layer"; this.Size = new System.Drawing.Size(482, 69); ((System.ComponentModel.ISupportInitialize)(this.LayerThumbnail)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.CheckBox isVisible; private System.Windows.Forms.PictureBox LayerThumbnail; private System.Windows.Forms.CheckBox Active; private System.Windows.Forms.Label ActiveLabel; private System.Windows.Forms.Button MoveLayerUp; private System.Windows.Forms.Button MoveLayerDown; private System.Windows.Forms.Label LayerLabel; } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
 namespace mspaintCompanion { partial class Main { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main)); this.AddLayer = new System.Windows.Forms.Button(); this.LayerPanel = new System.Windows.Forms.FlowLayoutPanel(); this.DeleteButton = new System.Windows.Forms.Button(); this.TransparencyColor = new System.Windows.Forms.ColorDialog(); this.transparency = new System.Windows.Forms.Button(); this.ExportButton = new System.Windows.Forms.Button(); this.ExportDialog = new System.Windows.Forms.SaveFileDialog(); this.ExportButton_Transparent = new System.Windows.Forms.Button(); this.SuspendLayout(); // // AddLayer // this.AddLayer.Location = new System.Drawing.Point(14, 18); this.AddLayer.Name = "AddLayer"; this.AddLayer.Size = new System.Drawing.Size(25, 25); this.AddLayer.TabIndex = 0; this.AddLayer.Text = "+"; this.AddLayer.UseVisualStyleBackColor = true; this.AddLayer.Click += new System.EventHandler(this.AddLayer_Click); // // LayerPanel // this.LayerPanel.Anchor = System.Windows.Forms.AnchorStyles.Top; this.LayerPanel.AutoScroll = true; this.LayerPanel.BackColor = System.Drawing.Color.DarkGray; this.LayerPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.LayerPanel.Location = new System.Drawing.Point(15, 48); this.LayerPanel.Name = "LayerPanel"; this.LayerPanel.Size = new System.Drawing.Size(512, 275); this.LayerPanel.TabIndex = 1; this.LayerPanel.WrapContents = false; // // DeleteButton // this.DeleteButton.Location = new System.Drawing.Point(45, 17); this.DeleteButton.Name = "DeleteButton"; this.DeleteButton.Size = new System.Drawing.Size(25, 25); this.DeleteButton.TabIndex = 2; this.DeleteButton.Text = "-"; this.DeleteButton.UseVisualStyleBackColor = true; this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click); // // TransparencyColor // this.TransparencyColor.AnyColor = true; this.TransparencyColor.Color = System.Drawing.Color.White; this.TransparencyColor.FullOpen = true; // // transparency // this.transparency.Location = new System.Drawing.Point(15, 334); this.transparency.Name = "transparency"; this.transparency.Size = new System.Drawing.Size(119, 25); this.transparency.TabIndex = 4; this.transparency.Text = "Transparent Color"; this.transparency.UseVisualStyleBackColor = true; this.transparency.Click += new System.EventHandler(this.transparency_Click); // // ExportButton // this.ExportButton.Location = new System.Drawing.Point(342, 334); this.ExportButton.Name = "ExportButton"; this.ExportButton.Size = new System.Drawing.Size(54, 25); this.ExportButton.TabIndex = 5; this.ExportButton.Text = "Export"; this.ExportButton.UseVisualStyleBackColor = true; this.ExportButton.Click += new System.EventHandler(this.ExportButton_Click); // // ExportDialog // this.ExportDialog.DefaultExt = "png"; // // ExportButton_Transparent // this.ExportButton_Transparent.Location = new System.Drawing.Point(402, 334); this.ExportButton_Transparent.Name = "ExportButton_Transparent"; this.ExportButton_Transparent.Size = new System.Drawing.Size(125, 25); this.ExportButton_Transparent.TabIndex = 6; this.ExportButton_Transparent.Text = "Export (Transparent)"; this.ExportButton_Transparent.UseVisualStyleBackColor = true; this.ExportButton_Transparent.Click += new System.EventHandler(this.ExportButton_Transparent_Click); // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Gray; this.ClientSize = new System.Drawing.Size(541, 370); this.Controls.Add(this.ExportButton_Transparent); this.Controls.Add(this.transparency); this.Controls.Add(this.LayerPanel); this.Controls.Add(this.ExportButton); this.Controls.Add(this.DeleteButton); this.Controls.Add(this.AddLayer); this.Font = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "Main"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "mspaintCompanion"; this.TopMost = true; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button AddLayer; private System.Windows.Forms.FlowLayoutPanel LayerPanel; private System.Windows.Forms.Button DeleteButton; private System.Windows.Forms.ColorDialog TransparencyColor; private System.Windows.Forms.Button ExportButton; private System.Windows.Forms.SaveFileDialog ExportDialog; private System.Windows.Forms.Button ExportButton_Transparent; private System.Windows.Forms.Button transparency; } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
 namespace mspaintCompanion { partial class LayerRenderer { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.SuspendLayout(); // // LayerRenderer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.BackColor = System.Drawing.SystemColors.Control; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.ClientSize = new System.Drawing.Size(480, 360); this.ControlBox = false; this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "LayerRenderer"; this.ShowIcon = false; this.ShowInTaskbar = false; this.Text = "LayerRenderer"; this.TopMost = true; this.ResumeLayout(false); } #endregion } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
<?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> </root>
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
using System; using System.Runtime.InteropServices; using System.Drawing; using System.Windows.Forms; using System.Threading.Tasks; using System.Threading; namespace mspaintCompanion { public partial class Layer : UserControl { public int index; public bool IsLayerVisible = true; public bool IsLayerActive = false; [DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hWnd); public Image fullres, thumbnail; public Layer() { InitializeComponent(); Main.Layers.Add(this); Main._LayerPanel.Controls.Add(this); index = Main.Layers.Count - 1; LayerLabel.Text = "(" + (index + 1) + ")"; Image i = Main.GetCanvasImage(); fullres = i; SetActiveLayer(this); } [DllImport("User32.dll")] static extern IntPtr GetDC(IntPtr hwnd); [DllImport("User32.dll")] static extern int ReleaseDC(IntPtr hwnd, IntPtr dc); public void RefreshThumbnail() { thumbnail = new Bitmap(fullres, LayerThumbnail.Size); LayerThumbnail.Image = thumbnail; } public void SetInactiveLayer() { IsLayerActive = false; Active.Checked = false; ActiveLabel.Text = ""; isVisible.Enabled = true; } public static void SetActiveLayer(Layer layer) { Layer oldActiveLayer = Main.ActiveLayer; Main.UpdateLayer(oldActiveLayer, Main.GetCanvasImage()); Main.UpdateActive(); layer.IsLayerActive = true; layer.Active.Checked = true; layer.ActiveLabel.Text = "ACTIVE"; Main.ActiveLayer = layer; layer.isVisible.Checked = true; layer.isVisible.Enabled = false; IntPtr hwnd = Main.mspaint.MainWindowHandle; if (SetForegroundWindow(hwnd)) { Clipboard.SetData(DataFormats.Bitmap, layer.fullres); Thread.Sleep(20); SendKeys.SendWait("^v"); } LayerRenderer.Inst.UpdateRenderer(); } private void Active_Click(object sender, EventArgs e) { SetActiveLayer(this); } public void UpdateLayerTag() { LayerLabel.Text = "(" + (index + 1) + ")"; } private void MoveLayerUp_Click(object sender, EventArgs e) { if (index == 0) return; Main.Layers.RemoveAt(index); Main.Layers.Insert(index - 1, this); Main.MoveLayer(this, index - 1); Main.UpdateLayerTags(); LayerRenderer.Inst.UpdateRenderer(); Refresh(); } private void MoveLayerDown_Click(object sender, EventArgs e) { if (index == Main.Layers.Count - 1) return; Main.Layers.RemoveAt(index); Main.Layers.Insert(index + 1, this); Main.MoveLayer(this, index + 1); Main.UpdateLayerTags(); LayerRenderer.Inst.UpdateRenderer(); Refresh(); } private void onLayerVisiblityToggled(object sender, EventArgs e) { if (isVisible.CheckState == CheckState.Checked) { IsLayerVisible = true; } else if (isVisible.CheckState == CheckState.Unchecked) { IsLayerVisible = false; } LayerRenderer.Inst.UpdateRenderer(); } } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
<?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <metadata name="TransparencyColor.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> <metadata name="ExportDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>170, 17</value> </metadata> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAEZcAABGXAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJ+f nwC7u7sDRkZGGQAAABwPDw8dX19fDktLSwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGJi YgCQkJAMBgYGTQwMDIwYFxfYAAAA5AYGBuUXFhaxAAAAfQAAAIAiIiJ0SkpKJJycnAJ6enoAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYmJiAIOD gwxLS0tODAwMfxwcHLALCAjzCBIT/wUfIP8eREb/I2Jm/wkhIv8AGhv/CRQU/wkFBP0ZGRncSUlJf0ZG RiOcnJwCenp6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGpq agCDg4MMQEBAow0MDPQFAQH/CgcH/xRZXP8axM3/Advm/wrm8f8L8Pr/A9rm/wDZ5P8dx8//F4SK/x4z Nf8HBAT9GRkZ3UFBQVlkZGQLS0tLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AACfn58Avr6+C1hYWFwQDg7zIjg4/xOBh/8foqn/Cebv/wD1//8A9f//APX//wD2//8A+P//APj//wD3 //8C+P//FrjA/z1cXv8WFRX/CQgI9S4uLn+ioqIKenp6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AACfn58A////AV1dXUkvLy+zJCIi8ys/QP8oy9P/Aff//wD1//8A9P//AvX+/wbi7f8H1N7/FZif/wB3 fv8FfIP/ErrC/wTu+P8C9///G+33/y2nrf8nPD3/GRcX9Do6OqNeXl4MUVFRAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAFJSUgBfX19KJSUl6QoHB/8WKSr/IsTM/wL1//8A8///AvT//w3f6f8blJv/FDg6/wIY Gf8HCAj/AAAA/wEAAP8KFBT/FV1h/xXCy/8B9f//Afb//zDS2v8nPD7/CQgH8kNDQ39bW1sNUVFRAAAA AAAAAAAAAAAAAAAAAABqamoAkpKSCygoKLEJCgr/OX6C/yHP2P8A8v3/APP//wbu+v8eu8T/Hj0//wYG Bv8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8BAAD/Gi4v/xe1vf8E7Pj/A/f//wl4ff8BAAD/DQ0N5yws LCcdHR0AAAAAAAAAAAAAAAAA3t7eAPz8/A2ysrJ/FxQU8iRERf8Q4uz/APX//wD0//8N6/X/K3+E/w0W Fv8CAQH/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8BAAD/ChIS/xWSmP8B+v//EYiO/xEK Cf8EBQX/KysrfwAAAAB6enoAAAAAAAAAAABZWVkAYmJiTUNBQfMmOz3/J8nR/wHz//8A8///Dev1/y5+ gv8NCwv/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/FSor/xm9 xf8n3+n/NGxv/wIAAP8UFBTcTExMIzo6OgAAAAAAnp6eAOfn5wodHR2OCgkJ/yCan/8B9v//APP//wbu +f8sgIT/DQsL/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA AP8BAAD/FzY4/wnf6f8hzNP/Iyor/wgHB/8jIyN1GxsbAAAAAAA/Pz8AQkJCcB4cHPUBGBr/CNbg/wD0 //8A9P//GL/I/w8YGf8AAAD/AQEB/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA AP8AAAD/AAAA/wAAAP8FBAT/FY6V/wrx/f87tLr/CRQV/xYVFbF0dHQLUVFRAAAAAAAAAAB/AAAA/wAa HP8A2OP/APT//wD2//8If4X/AwAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8QNTb/BeXt/wrp8/8fREb/BQIC4w8PDxwNDQ0AAAAAAAAA AH8AAAD/ABoc/wDY4/8A9P//APf//wB5f/8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8BAQH/AgEB/wAMDP8Ph43/CO/7/wl4ff8CAADnIiIiJhIS EgAAAAAAAAAAfwAAAP8AGhz/ANjj/wD0//8A9v//D4aM/wYAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA AP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8FAQH/CRIS/yRSVf8K6PT/DIWL/wkE BP8jIyN0GxsbACAgIAAhISF/EA8O/wAaG/8A2eP/APT//wDz//8f1N7/D4aM/wB6gP8AeoD/AHl//wB5 f/8AeX//AHl//wB5f/8AeX//AHl//wB5f/8AeX//AHl//wB5f/8AeoD/AHqA/w2Eiv8aw8v/COXx/wL0 //8dxs//CRQV/wAAAH8AAAAAlZWVAKGhoT0zMjLCBA8P/xC6wf8A9f//APL//wD0//8H7/r/BN/r/wXw +P8A+P//APf//wD3//8A9///APf//wD3//8A9///APf//wD3//8A9///Avb//wbl8f8F5O//AvX+/wD1 //8A8///APT//wDY4/8AGhv/AAAAfwAAAAAAAAAANjY2AEVFRXUMCQj/FV1g/wXt+f8A8///APX//xac o/8MHyH/IXV5/wrm8v8A8///APL//wDy//8A8v//APL//wDy//8A8v//APL//wDz//8H4u3/FUVI/w8/ Qv8F4Ov/APP//wDy//8A9P//ANnj/wAaG/8AAAB/AAAAAAAAAABvb28AhYWFI1BPT9EUHR39EbrB/wD1 //8A9///AHl//wAAAP8KBwf/EpSb/wD2//8A8v//APL//wDy//8A8v//APL//wDy//8A8v//APT//wDY 4/8AGRr/ABka/wDY4/8A9P//APL//wD1//8Vv8b/BxES/wAAAH8AAAAAAAAAANTU1AD///8BXl5eMgUB AOYVXWD/Be35/wD3//8NhIr/BAAA/wAAAP8AeYD/APf//wDy//8A8v//APL//wDy//8A8v//APL//wDy //8A9P//ANjj/wAZGv8AGRr/ANjj/wD0//8A8///B/D6/xxlaP8KBgb/Nzc3dCsrKwAAAAAAAAAAAFtb WwBtbW0YJSQk2AkTE/8Su8L/APn//yHJ0v8YHx//Eg0N/xyfpv8A9f//APL//wDy//8A8v//APL//wDy //8A8v//APL//wD0//8E2+f/EiYn/yNERv8I4+//APT//w3p9P8uo6n/DRgY/yAfH9x2dnYjXFxcAAAA AAAAAAAA1NTUAAAAAABSUlKACwkI/xpSVf8ayNL/Cu/6/yOpr/8ho6r/EOr2/wDy//8A8v//APL//wDy //8A8v//APL//wDy//8A8v//APL//wnu+v8vs7r/I83W/wHz//8I8f7/IZad/xMPD/8TEhL/SEhJfwAA AAC6uroAAAAAAAAAAAAAAAAAb29vAIuLiyM1NTXcCAQE/xg2OP8K3Ob/APf//wD1//8A8///APL//wDy //8A8v//APL//wDy//8A8v//APL//wDy//8A8v//APL//wD1//8A9P//Afb//yKfpv8bJCX/AQEA/zMz M7Wzs7MWjY2NAAAAAAAAAAAAAAAAAAAAAADU1NQA////AI6OjlU7OzvoEhIS/yFydv8K6PL/APX//wDz //8A8v//APL//wDy//8A8v//APL//wDy//8A8v//APL//wDy//8A8v//APL//wH0//8ixMz/GzAx/w8O Dv1HR0febm5uS2JiYgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADV1dUA////AaOjo0lfX1+3EhAQ/iFx df8F1N//BeHs/wL0/v8A8///APL//wDy//8A8v//APL//wDy//8A8v//APP//wD2//8B9///IsTM/yA0 Nf8jIiH0XV1dpqurqyLT09MCurq6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbGxsAIiI iCM0MzPcCAgI/wEXF/8PMjT/B6Ss/wXv+f8A9///APb//wD0//8A9///APf//wL2/v8H5O//AKix/wZz ef8aMDH/EhAQ/0tLS4P39/cKurq6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AADV1dUA////AYeHh0k9PT20FhQU5A8NDfEJExP/D1ld/wB5f/8QlJv/BcnS/wCDiv8AeH7/B3V7/xQ5 O/8DDQ3/EAsL/BAPD+lTU1OnqampF42NjQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAk5OTALCwsA44ODgbaWpqTBsaGrMEAwPoCwcH/AcGBv8CFRb/CQkJ/AMC AuYAAADjDg0N5Tc1NbJtbW1zSkpKJ5ubmw2BgYEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXFxcAFRUVDT09PSdLS0t1CwsLgQEB AYFAQEB1MzMzJwAAABsmJiYdnJycDoGBgQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAA///////4P///4AH//wAAf/4AAD/8AAAf8AAAD/AAAAfgAAAHwAAAB8AA AAOAAAADgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABwAAAAcAAAAHAAAAB4AAAAfAAAAPwAAAD+AAAB/gA AAf+AAAf/gAAP/+AAH//8AP///////////8= </value> </data> </root>
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Threading; using System.Windows.Forms; namespace mspaintCompanion { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Main()); Application.Run(new MultiFormContext(new Main(), new LayerRenderer())); } } public class MultiFormContext : ApplicationContext { private int openForms; public MultiFormContext(params Form[] forms) { openForms = forms.Length; foreach (var form in forms) { form.FormClosed += (s, args) => { if (Interlocked.Decrement(ref openForms) == 0) ExitThread(); }; form.Show(); } } } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
<?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </root>
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace mspaintCompanion.Properties { using System; /// <summary> /// A strongly-typed resource class, for looking up localized strings, etc. /// </summary> // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// <summary> /// Returns the cached ResourceManager instance used by this class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("mspaintCompanion.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// <summary> /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// </summary> [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace mspaintCompanion.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); public static Settings Default { get { return defaultInstance; } } } }
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
<?xml version='1.0' encoding='utf-8'?> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> <Profiles> <Profile Name="(Default)" /> </Profiles> <Settings /> </SettingsFile>
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("mspaintCompanion")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("mspaintCompanion")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("d31fb0d3-8d7c-4068-ad19-5bd098a68b31")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
{ "repo_name": "TalonZane/mspaintCompanion", "stars": "133", "repo_language": "C#", "file_name": "AssemblyInfo.cs", "mime_type": "text/plain" }
require "bundler/gem_tasks" require "rake/testtask" Rake::TestTask.new :copy do # for make ./lib_lock to use ./lib require_relative "./bin/lock_lib.rb" end Rake::TestTask.new :test do |t| t.warning = false t.libs << "test" t.libs << "lib" t.test_files = FileList["test/**/*_test.rb"] end task :default => %i[copy test]
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
### Other language English version(英語バージョン) This file is for Japanese to read. The following files are written in English: (英語で読みたい方は次のファイルを) - [README.md (ver. English)](README.md) # ac-library-rb [![Gem Version](https://badge.fury.io/rb/ac-library-rb.svg)](https://badge.fury.io/rb/ac-library-rb) [![codecov](https://codecov.io/gh/universato/ac-library-rb/branch/main/graph/badge.svg?token=NUAIDTMGBE)](https://codecov.io/gh/universato/ac-library-rb) <img width="560" src="ac-library-rb_header.jpg" alt="ac-library-rb Logo"> ac-library-rbは、AtCoder Library (ACL)のRuby版です。 ACLの詳細は、以下をご覧ください. - AtCoder Library(ACL)とは - [AtCoder Library (ACL) - AtCoder](https://atcoder.jp/posts/517) - [AtCoder Library - Codeforces](https://codeforces.com/blog/entry/82400) - [けんちょん氏による日本語訳](https://drken1215.hatenablog.com/entry/2020/09/08/181500) - コード - [atcoder/ac-library - GitHub](https://github.com/atcoder/ac-library) ## ライブラリの使い方 [ライブラリ目次: index.md](https://github.com/universato/ac-library-rb/blob/main/document_ja/index.md) 公式に、ac-library-rbの利用として、以下の方法を想定しています。 - 直接コピペして使う方法 - `lib`ディレクトリに、ac-library-rbのライブラリのコードがあります。 - `lib_lock`ディレクトリに、Gem用にモジュール化されたコードがあります。 (別途モジュール化するの、ちょっとトリッキーですが……) - Gemとして使う方法(詳細は後述) 他に、有志作成のバンドルツール[expander-rb](https://github.com/surpace/expander-rb)(by surpaceさん)を利用する方法もあります。 目次は、[index.md](https://github.com/universato/ac-library-rb/blob/main/document_ja/index.md)をご覧ください。 ## Gemとなったac-library-rbを使う方法 コピペ以外にGemとなったac-library-rbを使う方法を紹介します。 ### gemのインストール方法 ac-library-rbに限った話ではないですが、一般的な2種類のgemのインストール方法を紹介します。 - Gemとして使う方法 - `gem`コマンドにより、`gem install ac-library-rb` - gemのbundlerを用いる方法 #### gemコマンドによるインストール方法 Ruby本体に付属のgemコマンドを用い、そのまま`gem install ac-library-rb`を実行します。 #### gemのbundlerを用いたインストール方法 bundlerをインストールしてない場合は、`gem install bundler`というコマンドを打ちインストールします。 次に、ac-library-rbを使いたいディレクトリ配下にGemfileを置きます。Gemfileという名称のファイルです。 このGemfileの中で、次のように書きます。 ```ruby gem "ac-library-rb" ``` そして、`budnle install`というコマンドにより、Gemfileに書かれたac-library-rbをインストールします。 このとき、bundlerを通してRubyファイルを実行する必要があるため、`bundle exec`コマンドを用います。 `$ bundle exec ruby sample.rb` ### (インストール後の)Rubyファイルでの書き方 #### 一括ロード Rubyファイル上で一括でac-library-rbのライブラリを使えるようにするには、下記のように書きます。 ```ruby require "ac-library-rb/all" dsu = AcLibraryRb::DSU.new include AcLibraryRb dsu = DSU.new ``` `include AcLibraryRb`とモジュールをインクルードすることで、 何度も`AcLibraryRb`といわゆる名前空間を書く必要がなくなります。 また、`/all`なしで`require "ac-library-rb"`とした場合は、`include AcLibraryRb`も同時に実行されます。 ```ruby require "ac-library-rb" dsu = DSU.new ``` #### 個別ロード 特定のライブラリのみをインストールしたいときは下記のように`ac-library-rb/`のあとにライブラリ名を指定します。 ```ruby require "ac-library-rb/dsu" dsu = AcLibraryRb::DSU.new require "ac-library-rb/priority_queue" pq = AcLibraryRb::PriorityQueue.new ``` 本gem名はハイフン区切りですが、ac-library-rb内のライブラリ名はアンダースコア区切りであるため、注意して下さい。 一般的にRubyのライブラリ名はアンダースコアが推奨されていますが、 ACL本家のレポジトリ名がac-libraryとハイフン区切りで、それに合わせているため、レポジトリ名・gem名がハイフン区切りとなっています。 ## Rubyバージョン 現在、AtCoderのRubyバージョンは、2.7.1です。 そのため、2.7と最新の3.1でテストをしています。 ただ、開発される方は2.7より古くても動かせるようNumbered parametersなどの使用は控えてもらえると嬉しいです。 ## ライセンス とりあえず、本家ライブラリと同じCC0-1.0 Licenseです。 競技プログラミング等で自由に使って下さい。 宣伝・バグ報告などしてもらえると嬉しいです。 ## ac-library-rbを開発したい方向けの情報(CONTRIBUTEING) ### コーディングスタイル 推奨スタイル - インデントは、半角スペース2文字 - 行末の余計なスペースは削除 RuboCopを使用できる方は、使用してもらえるとありがたいです。 使い方のわからない方は、使う必要がないです。 ```console $gem install rubocop ``` 上記の方法でrubocopをインストールします。 ```console $rubocop <- チェック $rubocop -a <- 安全に直せるところは自動で修正 $rubocop -A <- 安全でない可能性のところも自動で修正 ``` ### ディレクトリの説明 `lib`ディレクトリ内に各種のデータ構造などのライブラリがあります。 `lib_lock`は、Gem用にモジュール化させるため`lib`の内容をコピーする形でモジュール化させています。 [`bin/lock_lib.rb`](./bin/lock_lib.rb)を実行することで、`lib`から`lib_lock`にモジュール化させる形でコピーします。 `rake copy`コマンドを実行すると、[`bin/lock_lib.rb`](./bin/lock_lib.rb)が実行されるため、この2つは同等です。 なお、`rake`コマンドでテストを実行させると、自動的に`require_relative "./bin/lock_lib.rb"`により、コピーが行われます。 このあたりはトリッキーで、予定は未定ですが、今後全てモジュール化される等に統一される可能性があります。 ``` $ rake copy <- `lib`に変更があれば、`./lib_lokc`を更新する。 $ rake test <- 全てのテストを実行 $ rake <- 上2つのcopy & testを実行 ``` ## その他の情報 ### RubyのSlackのAtCoderチャンネル [ruby-jp](https://ruby-jp.github.io/) に"atcoder"というチャンネルがあります。 ここで、バグ報告などすると、競プロ詳しい人などが反応しやすいかもしれません。 Slackに4000人近く、atcoderチャンネルに350人ほどの登録者がいるので、お気軽に参加してください。 ### 他言語のライブラリ - [Unofficial Portings of AtCoder Library](https://docs.google.com/spreadsheets/d/19jMAqUbv98grVkLV_Lt54x5B8ILoTcvBzG8EbSvf5gY/edit#gid=0) (by [notさん](https://twitter.com/not_522/status/1303466197300649984)) ### 他言語 [README in English](README.md)
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
source "https://rubygems.org" gemspec
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
require_relative 'lib/ac-library-rb/version' gem_description = <<~DESCRIPTION ac-library-rb is a ruby port of AtCoder Library (ACL). DSU(UnionFind), FenwickTree, PriorityQueue, Segtree, SCC, 2-SAT, suffix_array, lcp_array, z_algorithm, crt, inv_mod, floor_sum, max_flow, min_cost_flow...... DESCRIPTION Gem::Specification.new do |spec| spec.name = "ac-library-rb" spec.version = AcLibraryRb::VERSION spec.authors = ["universato"] spec.email = ["[email protected]"] spec.summary = "ac-library-rb is a ruby port of AtCoder Library (ACL)." spec.description = gem_description spec.homepage = "https://github.com/universato/ac-library-rb" spec.license = "CC0" spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0") spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "https://github.com/universato/ac-library-rb" spec.metadata['rubygems_mfa_required'] = 'true' spec.add_dependency "prime" spec.add_development_dependency "minitest" spec.add_development_dependency "rake" spec.add_development_dependency "simplecov" spec.add_development_dependency 'simplecov-cobertura' # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = %w[lib_lock lib_helpers"] end
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
### Other language Japanese version(ver. 日本語) [README 日本語バージョン(ver. Japanese)](README.ja.md) - [ライブラリ目次: index.md](https://github.com/universato/ac-library-rb/blob/main/document_ja/index.md) <hr> # ac-library-rb [![Gem Version](https://badge.fury.io/rb/ac-library-rb.svg)](https://badge.fury.io/rb/ac-library-rb) [![codecov](https://codecov.io/gh/universato/ac-library-rb/branch/main/graph/badge.svg?token=NUAIDTMGBE)](https://codecov.io/gh/universato/ac-library-rb) <img width="560" src="ac-library-rb_header.jpg" alt="ac-library-rb Logo"> ac-library-rb is a ruby port of AtCoder Library (ACL). See below for ACL. - [AtCoder Library (ACL) - AtCoder](https://atcoder.jp/posts/517) - [AtCoder Library - Codeforces](https://codeforces.com/blog/entry/82400) - [atcoder/ac-library - GitHub](https://github.com/atcoder/ac-library) # Ruby version Currently, the Ruby version in AtCoder is 2.7.1. Therefore, 2.7 and the latest 3.1 are tested. # Document Please read [index.md](https://github.com/universato/ac-library-rb/blob/main/document_en/index.md). ## How to use ac-library-rb as a Gem We will show you how to use ac-library-rb as a gem. ## How to install This is not limited to ac-library-rb, but I will show you how to install the two common types of gem. - By `gem` command, `gem install ac-library-rb`. - By using the gem bundler's commands. #### By gem command, `gem install ac-library-rb` Execute `gem install ac-library-rb` by using the gem command included in Ruby itself. #### How to use the gem bundler If you have not installed bundler, type `gem install bundler` to install it. Next, place Gemfile under the directory where you want to use ac-library-rb. In this Gemfile, write: ```ruby gem "ac-library-rb". ``` Then, install ac-library-rb by using the command `budnle install`. At this point, we need to run the Ruby file through bundler, so we use the command `bundle exec`. `$ bundle exec ruby sample.rb`. ### How to write in Ruby files (after installation) #### Bulk loading To enable the ac-library-rb library to be used in bulk on Ruby files, write as follows. ```ruby require "ac-library-rb/all" dsu = AcLibraryRb::DSU.new include AcLibraryRb dsu = DSU.new ``` #### Individual loading If you want to install only a specific library, specify the library name after `ac-library-rb/` as shown below. ```ruby require "ac-library-rb/dsu" dsu = AcLibraryRb::DSU.new require "ac-library-rb/priority_queue" pq = AcLibraryRb::PriorityQueue.new ``` Note that the gem names are separated by hyphens, but the library names in ac-library-rb are separated by underscores. In general, underscores are recommended for Ruby library names. However, the repository names in the original ACL are separated by a hyphen, ac-library, so ac-library-rb is also separated by a hyphen. ## Development: How to Contirubute After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. ```bash $ rake test $ rake $ ruby test/fenwick_tree_test.rb ``` # Other ## Other languages's ac-library - [Unofficial Portings of AtCoder Library](https://docs.google.com/spreadsheets/d/19jMAqUbv98grVkLV_Lt54x5B8ILoTcvBzG8EbSvf5gY/edit#gid=0) (by [not522-san](https://github.com/not522)) ## Other language Japanese version [README 日本語バージョン(ver. Japanese)](README.ja.md) - [ライブラリ目次: index.md](https://github.com/universato/ac-library-rb/blob/main/document_ja/index.md)
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
name: Unittest on: push: paths-ignore: - 'document_*/**/*' - 'README.*' pull_request: paths-ignore: - 'document_*/**/*' - 'README.*' jobs: unittest: runs-on: ${{ matrix.os }} strategy: matrix: os: [macos-latest, ubuntu-latest, windows-latest] ruby: [2.7, 3.2] steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: insall by bundler run: bundle install - name: run unittests run: bundle exec ruby test/*.rb - name: Upload coverage to Codecov uses: codecov/codecov-action@v3
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
# SCC Strongly Connected Components It calculates the strongly connected components of directed graph. ## Class Methods ### new(n) -> SCC ```ruby graph = SCC.new(6) ``` It creates a directed graph of `n` vertices and `0` edges. This `n` is 0-based index. **Constraints** `0 ≦ n` **Complexity** $O(n)$ ## Instance Methods ### add_edge(from, to) ```ruby graph.add_edge(1, 4) ``` It adds a directed edge from the vertex `from` to the vertex `to`. **Constraints** `0 ≦ from < n`, `0 ≦ to < n` **Complexity** $O(n)$ ### scc -> Array[Array[Integer]] ```ruby graph.scc ``` It returns the array of the "array of the vertices" that satisfies the following. - Each vertex is in exactly one "array of the vertices". - Each "array of the vertices" corresponds to the vertex set of a strongly connected component. The order of the vertices in the list is undefined. - The array of "array of the vertices" are sorted in topological order, i.e., for two vertices $u, v$ in different strongly connected components, if there is a directed path from $u$ to $v$, the list contains uu appears earlier than the list contains $v$. **Complexity** $O(n + m)$ , where $m$ is the number of added edges. ## Verified - [ALPC: G - SCC](https://atcoder.jp/contests/practice2/tasks/practice2_g) - [Ruby 2.7 1848ms 2022/11/22](https://atcoder.jp/contests/practice2/submissions/36708506) - [typical90: 021 - Come Back in One Piece](https://atcoder.jp/contests/typical90/tasks/typical90_u) - [Ruby2.7 471ms 2021/6/15](https://atcoder.jp/contests/typical90/submissions/23487102) # 参考リンク - ac-library-rb - [scc.rb](https://github.com/universato/ac-library-rb/blob/main/lib/scc.rb) - [scc_test.rb](https://github.com/universato/ac-library-rb/blob/main/test/scc_test.rb) - Original C++ - [Original C++ code scc.hpp](https://github.com/atcoder/ac-library/blob/master/atcoder/scc.hpp) - [Original document scc.md](https://github.com/atcoder/ac-library/blob/master/document_en/scc.md)
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
See [DSU document (dsu.md)](https://github.com/universato/ac-library-rb/blob/main/document_en/dsu.md). DSU is an alias of UnionFind.
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
# String The substring of the `a`-th to `b-1`-th element of the string `s` is written as `s[a..b)`. ## suffix_array ```ruby (1) suffix_array(s) (2) suffix_array(a) (3) suffix_array(a, upper) ``` For a string `s` of length `n`, returns an array of `Integer` of length `n` as a Suffix Array. Suffix Array `sa` is a permutation of `0 ... ... n`, and for each `i`, it is a permutation of `s[sa[i]. .n) < s[sa[i+1]. .n)` is satisfied. This concept of Suffix Array can also be applied to general columns and works for `a`, an array of elements comparable with `<=>` operator. 1. ### 1. `suffix_array(s)` Convert internally to a sequence of bytes by `s.bytes`. **Constraints** - `s` is a string consisting only of characters with character code 255 or less. **Complexity** - `O(|s|)` ### 2. `suffix_array(a)` Inside, so-called coordinate compression is performed. Elements are converted to non-negative integers keeping their size relation. **Constraints** - The elements of `a` are comparable to each other with the `<=>` operator. **Complexity** - Assuming elements can be compared in constant time, `O(|a| log |a|)` ### 3. `suffix_array(a, upper)` **Constraints** - `a` is an array of `Integer`. - For all elements `x` of `a`, `0 ≤ x ≤ upper`. **Complexity** - `O(|a| + upper)` ## lcp_array ```ruby lcp_array(s, sa) ``` It returns an array of `Integer` of length `n-1` as an LCP Array of length `n` for strings `s`. The `i` th element is the length of LCP ( Longest Common Prefix ) for `s[sa[i]. .n)` and `s[sa[i+1]. .n)`. This also works for general columns as well as `suffix_array`. **Constraints** - `sa` is a Suffix Array of `s`. - If `s` is a string, `s` consists only of characters with character code 255 or less. **Complexity** - `O(|s|)` ## z_algorithm ```ruby z_algorithm(s) ``` It returns an array of `Integer` of length `n`, where `n` is the length of the input array. The `i` th element is the length of LCP ( Longest Common Prefix ) of `s[0..n)` and `s[i..n)`. **Constraints** - The elements of `s` can be compared with each other with the `==` operator **Complexity** - `O(|s|)` <hr> ## Verified - suffix_array, lcp_array - [I - Number of Substrings](https://atcoder.jp/contests/practice2/tasks/practice2_i) - [AC 1362 ms](https://atcoder.jp/contests/practice2/submissions/17194669) - z_algorithm - [ABC135 F - Strings of Eternity](https://atcoder.jp/contests/abc135/tasks/abc135_f) - [AC 1076 ms](https://atcoder.jp/contests/abc135/submissions/16656965) ## Links - AtCoder Library - [Document String(HTML)](https://atcoder.github.io/ac-library/master/document_ja/string.html)
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
See [FenwickTree document (fenwick_tree.md)](https://github.com/universato/ac-library-rb/blob/main/document_en/fenwick_tree.md). Fenwick Tree is an alias of BIT(Binary Index Tree).
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
# MaxFlow Library for solving [Maximum flow problem](https://en.wikipedia.org/wiki/Maximum_flow_problem). ## Class Methods ### new(n) -> MaxFlow ```ruby graph = Maxflow.new(10) ``` It creates a graph of `n` vertices and `0` edges. **Complexity** - `O(n)` ## Instance Methods ### add_edge(from, to, cap) -> Integer ```ruby graph.add_edge(0, 1, 5) ``` It adds an edge oriented from the vertex `from` to the vertex `to` with the capacity cap and the flow amount `0`. It returns an integer `k` such that this is the `k`-th edge that is added. **Complexity** - `O(1)` amortized ### flow(start, to, flow_limit = 1 << 64) -> Integer ```ruby (1) graph.flow(0, 3) (2) graph.flow(0, 3, flow_limit) ``` - It augments the flow from `s` to `t` as much as possible. It returns the amount of the flow augmented. **Aliases** - `max_flow` - `flow` **Constraints** - `start ≠ to` ### min_cut(start) -> Array(boolean) ```ruby graph.min_cut(start) ``` The return value is an array of length `n`. The `i`-th element of the return value is filled with `true` if the vertex `start` to `i` is reachable by the remainder graph, otherwise it is filled with `false`. **Complexity** - `O(n + m)`, where `m` is the number of added edges. ### get_edge(i) -> [from, to, cap, flow]. ```ruby graph.get_edge(i) graph.edge(i) graph[i]. ``` - It returns the current internal state of the `i`-th edge. - The edges are ordered in the same order as added by `add_edge`. **Complexity** - `O(1)`. **Aliases** - `get_edge` - `edge` - `[]` ### edges -> Array([from, to, cap, flow]) ```ruby graph.edges ``` - It returns the current internal state of the all edges. - The edges are ordered in the same order as added by `add_edge`. **Complexity** - `O(m)`, where `m` is the number of added edges. #### Notes on the `edges` method The `edges` method is `O(m)` because it generates information for all edges. Because of the generation cost, consider using `get_edge(i)` or storing it in a separate variable once, `edges = graph.edges`. ### change_edge(i, new_cap, new_flow) Change the capacity and flow rate of the `i`-th changed edge to `new_cap` and `new_flow`. **Constraints** - `0 ≤ new_fow ≤ new_cap` **Complexity** - `O(1)` ## Verified. - [ALPC: D - Maxflow](https://atcoder.jp/contests/practice2/tasks/practice2_d) - [AC Code 211ms 2020/9/17](https://atcoder.jp/contests/practice2/submissions/16789801) - [ALPC: D \fnDroid Sans Fallback - Qiita](https://qiita.com/magurofly/items/bfaf6724418bfde86bd0) ## Reference links - ac-library-rb - [Code max_flow.rb(GitHub)](https://github.com/universato/ac-library-rb/blob/main/lib/max_flow.rb) - [Test code: max_flow_test.rb(GitHub)](https://github.com/universato/ac-library-rb/blob/main/test/max_flow_test.rb) - The original library AtCoder Library - Code of the original library - [Code: maxflow.hpp(GitHub)](https://github.com/atcoder/ac-library/blob/master/atcoder/maxflow.hpp) - [Test code: maxflow_test.cpp(GitHub)](https://github.com/atcoder/ac-library/blob/master/test/unittest/maxflow_test.cpp) - Main family documentation - [Documentat: maxflow.md(GitHub)](https://github.com/atcoder/ac-library/blob/master/document_en/maxflow.md) - [Documentat: maxflow.html](https://atcoder.github.io/ac-library/document_en/maxflow.html) - [Document: appendix.md(GitHub)](https://github.com/atcoder/ac-library/blob/master/document_en/appendix.md) ## Questions and Answers. ### Why does the `flow_limit` of the `flow` method default to `1 << 64`? I don't remember, and there is no deeper meaning. It looks like `Float::MAX` or `Float::INFINITY` might be OK, but won't it slow things down? ### Don't use Struct for edges. Using Struct makes the code slimmer, more advanced, and better looking. However, as a result of measurements, Struc is slow, so we use arrays. ### What is the purpose of a variable that starts with `_`? It's a bit confusing, but there are two separate intentions: 1. 1. `_e` and `_re` are matching variable names to make them easier to read with the original ACL code. 2. 2. `_rev` is spit out but not used for the convenience of running `each`, so it starts with `_` with the intention of "not using". ````ruby @g[q].each do |(to, _rev, cap)| ````
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
# 2-SAT It solves 2-SAT. For variables x_0, x_1, ..., x_N-1 and clauses with form (x_i = f) ∨ (x_j = g) it decides whether there is a truth assignment that satisfies all clauses. **Alias** `TwoSAT`, `TwoSat` <hr> ## Class Methods ### new(n) -> TwoSAT ```ruby ts = TwoSAT.new(n) ``` It creates a 2-SAT of `n` variables and `0` clauses. **Complexity** O(n) <hr> ## Instance Methods ### add_clause(i, f, j, g) -> nil `i: Integer`, `f: bool`, `j: Integer`, `g: bool` ```ruby ts.add_clause(i, true, j, false) ``` It adds a clause (x_i = f) ∨ (x_j = g). **Constraints** - `0 <= i < n` - `0 <= j < n` **Complexity** - `O(1)` amortized ### satisfiable? -> bool ```ruby ts.satisfiable? ``` If there is a truth assignment that satisfies all clauses, it returns `true`. Otherwise, it returns `false`. **Alias** `satisfiable?`, `satisfiable` **Complexity** `O(n + m)`, where `m` is the number of added clauses. ### answer -> Array(bool) ```ruby ts.answer ``` It returns a truth assignment that `satisfie` all clauses of the last call of satisfiable. If we call it before calling `satisfiable` or when the last call of `satisfiable` returns `false`, it returns the vector of length `n` with undefined elements. **Complexity** - `O(n)` ## Verified - [H - Two SAT](https://atcoder.jp/contests/practice2/tasks/practice2_h) - [163 ms](https://atcoder.jp/contests/practice2/submissions/16655036 ) ## Links - AtCoder Library(ACL) - [Documetn twosat.html](https://atcoder.github.io/ac-library/master/document_ja/twosat.html)
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
# Convolution Performs convolution. An array of `Integer` of length `N`, `a[0],a[1],... ,a[N - 1]` and an array of `Integer` of length `M`, `b[0],b[1],... ,b[M - 1]`, and returns it as `c`, an array of `Integer` of length `N + M - 1`. ## convolution ``ruby (1) conv = Convolution.new(m = 998244353) (2) conv = Convolution.new(m, primitive_root) `` It creates an object to compute the convolution with `mod m`. The `primitive_root` must be a primitive root for the method `m`. If it is not given, the minimal primitive root is computed internally. **constraints**. - `2 ≤ m`. - `m` is a prime number - ((2) only) `primitive_root` is the primitive root for law `m`. **computational complexity** 1. 1.`O(sqrt m)` 2. 2.`O(log m)`. ### Usage The actual computation is done as follows, using the object `conv` created above. ```ruby c = conv.convolution(a, b) ``` If at least one of `a` and `b` is an empty array, it returns an empty array. **constraints**. - There exists a `c` such that `2^c|(m-1)` and `|a|+|b|-1<=2^c`. **computational complexity**. - `O((|a|+|b|) log (|a|+|b|))` ## convolution_ll This can be handled by using a sufficiently large prime number as `m` in `convolution`. An example of an `NTT-Friendly` prime over `1e15` is `1125900443713537 = 2^29×2097153+1`. # Verified - [C - Fast Fourier Transform](https://atcoder.jp/contests/atc001/tasks/fft_c) - `m = 1012924417` [1272ms](https://atcoder.jp/contests/atc001/submissions/17193829) - `m = 1125900443713537` [2448 ms](https://atcoder.jp/contests/atc001/submissions/17193739) # Reference. - [Main ACL documentation Convolution](https://atcoder.github.io/ac-library/master/document_ja/convolution.html) Translated with www.DeepL.com/Translator (free version)
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
# Math It contains number-theoretic algorithms. - `pow_mod` - `inv_mod` - `crt` - `floor_sum` ## pow_mod ```ruby pow_mod(x, n, m) ``` It returns `(x**n) % m`. However, Ruby core has `Integer#pow`. Use it. **Constraints** - `n`, `m` are intergers. - `0 ≦ n`, `1 ≦ m` **Complexity** - `O(log n)` ## inv_mod ```ruby inv_mod(x, n, m) ``` It returns an integer `y` such that `0 ≦ y < m` and `xy ≡ 1 (mod m)`. If m is a prime number, Use `x.pow(m - 2, m)`。 **Constraints** - `gcd(x, m) = 1`, `1 ≦ m` **Complexity** - `O(log m)` ### Verified - [ABC186 E - Throne](https://atcoder.jp/contests/abc186/tasks/abc186_e) - [AC Code(59ms) 2020/12/20](https://atcoder.jp/contests/abc186/submissions/18898186) ## crt(r, m) -> [rem , mod] or [0, 0] Chinese remainder theorem Given two arrays `r`, `m` with length `n`, it solves the modular equation system `x ≡ r[i] (mod m[i]), ∀i ∈ {0, 1, …… n - 1}` If there is no solution, it returns `[0, 0]`. If there is a solution, all the solutions can be written as the form `x ≡ rem(mod)`. it returns `[rem ,mod]` ## Verified Problems - [No\.187 中華風 \(Hard\) - yukicoder](https://yukicoder.me/problems/no/187) ## floor_sum(n, m, a, b) $\sum_{i = 0}^{n - 1} \mathrm{floor}(\frac{a \times i + b}{m})$ It retrurns `Σ[k = 0 → n - 1] floor((a * i + b) / m)` **Complexity** - `O(log(n + m + a + b))` ## Verified [ALPC: C - Floor Sum](https://atcoder.jp/contests/practice2/tasks/practice2_c) - [AC Code 426ms 2020/9/14](https://atcoder.jp/contests/practice2/submissions/16735215) ## 参考リンク - ac-library-rb - codes in ac-library-rb - [Code pow_mod.rb](https://github.com/universato/ac-library-rb/blob/main/lib/pow_mod.rb) - [Code inv_mod.rb](https://github.com/universato/ac-library-rb/blob/main/lib/inv_mod.rb) - [Code crt.rb](https://github.com/universato/ac-library-rb/blob/main/lib/crt.rb) - [Code floor_sum.rb](https://github.com/universato/ac-library-rb/blob/main/lib/floor_sum.rb) - test in ac-library-rb - [Test pow_mod_test.rb](https://github.com/universato/ac-library-rb/blob/main/test/pow_mod.rb) - [Test inv_mod_test.rb](https://github.com/universato/ac-library-rb/blob/main/test/inv_mod.rb) - [Test crt_test.rb](https://github.com/universato/ac-library-rb/blob/main/test/crt.rb) - [Test floor_sum_test.rb](https://github.com/universato/ac-library-rb/test/main/lib/floor_sum.rb) - AtCoder Library - [Code math.hpp](https://github.com/atcoder/ac-library/blob/master/atcoder/math.hpp) - [Code internal_math.hpp](https://github.com/atcoder/ac-library/blob/master/atcoder/internal_math.hpp) - [Test math_test.cpp](https://github.com/atcoder/ac-library/blob/master/test/unittest/math_test.cpp) - [Document math.md](https://github.com/atcoder/ac-library/blob/master/document_ja/math.md) - [Document math.html](https://atcoder.github.io/ac-library/document_en/math.html) - [Relax the constraints of floor\_sum? · Issue \#33 · atcoder/ac-library](https://github.com/atcoder/ac-library/issues/33)
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }
# MinCostFlow It solves [Minimum-cost flow problem](https://en.wikipedia.org/wiki/Minimum-cost_flow_problem). ## Class Methods ### new(n) -> MinCostFlow ```ruby graph = MinCostFlow.new(10) ``` It creates a directed graph with `n` vertices and `0` edges. Verticle order is the 0-based index. **Constraints** - `0 ≦ n` **Complexity** - `O(n)` ## Instance Methods ### add_edge(from, to, cap, cost) -> Integer ```ruby graph.add_edge(0, 1, 5) ``` Adds an edge from vertex `from` to vertex `to` with maximum capacity `cap` and flow rate `0`. The return value is the number of edge added with 0-based index. ### flow(start, to, flow_limit = Float::MAX) -> [flow, cost] ### min_cost_max_flow(start, to, flow_limit = Float::MAX) -> [flow, cost] ```ruby (1) graph.flow(0, 3) (2) graph.flow(0, 3, flow_limit) ``` The internals are mostly the `slope` method, just getting the last element of the return value of the `slop` method. The constraints and computational complexity are the same as for the `slope` method. **Aliases** - `flow` - `min_cost_max_flow` ### slope(s, t, flow_limit = Float::MAX) -> [[flow, cost]] ### min_cost_slop(s, t, flow_limit = Float::MAX) -> [[flow, cost]] ```ruby graph.slop(0, 3) ``` **Complexity** - `O(F(n + m) log n)`, where `F` is the amount of the flow and `m` is the number of added edges. **Aliases** - `slope` - `min_cost_slope` ### get_edge(i) -> [from, to, cap, flow, cost] ### edge(i) -> [from, to, cap, flow, cost] ### [](i) -> [from, to, cap, flow, cost] ```ruby graph.get_edge(i) graph.edge(i) graph[i]. ``` It returns the state of the `i`-th edge. **Constraints** - `0 ≤ i < m`. **Complexity** - `O(1)` ### edges -> Array[from, to, cap, flow, cost] ```ruby graph.edges ``` It returns an array containing information on all edges. **Complexity** - `O(m)`, where mm is the number of added edges. ## Verified - [ALPC: E- MinCostFlow](https://atcoder.jp/contests/practice2/tasks/practice2_e) - [1213ms 2020/9/17](https://atcoder.jp/contests/practice2/submissions/16792967) ## Reference links - Our library: ac-library-rb - [Code: min_cost_flow.rb](https://github.com/universato/ac-library-rb/blob/main/lib/min_cost_flow.rb) - [Test code: min_cost_flow_test.rb](https://github.com/universato/ac-library-rb/blob/main/test/min_cost_flow_test.rb) - The original library: AtCoder Library(ACL) - [Documentat: mincostflow.md(GitHub)](https://github.com/atcoder/ac-library/blob/master/document_ja/mincostflow.md) - [Code: mincostflow.hpp(GitHub)](https://github.com/atcoder/ac-library/blob/master/atcoder/mincostflow.hpp) - [Test code: mincostflow_test.cpp(GitHub)](https://github.com/atcoder/ac-library/blob/master/test/unittest/mincostflow_test.cpp ) ## Questions and Answers ## The intent of the aliases is to The method name of the minimum cost flow of the original library is long, so I have an alias for it. The method name of the maximum cost stream in the original library is short, so it is strange. ### What is the purpose of using `Float::MAX` instead of `Float::INFINITY`? I haven't tested it specifically, so I'd like to verify what number is good. I felt that the `Integer` class would be fine. ### Don't use Struct on the edges. Using Struct makes the code slimmer and more advanced, and it looks better. However, I didn't use Struct because it was too slow as a result of measurement.
{ "repo_name": "universato/ac-library-rb", "stars": "58", "repo_language": "Ruby", "file_name": "all.rb", "mime_type": "text/plain" }