fryyyyy / fryatog Goto Github PK
View Code? Open in Web Editor NEWGoLang based IRC bot for looking up MTG Rules/Oracle
GoLang based IRC bot for looking up MTG Rules/Oracle
Since now the bot backfills Card objects with metadata, we want to make sure that we give back the "canonical" object with stuff in it.
e.g If we fuzzily retrieve a card, check the cache for card.Name (or ncn(card.Name)? ) and return that one rather than the new one.
Add to list of prod channels
e.g Dryad Arbor
Momir support
// TODO:
// '[603.10a.] Example: Two' with highlighting of rule name and example
Highlighted text should be from '[603.10a.] Example:' to match the formatting we've all come to know and love.
To avoid spamming regulars who are just greeting others
Disenchant {1}{W} · Instant · Destroy target artifact or enchantment. ·
IMA-C,PRM-C,CN2-C,TPR-C,PRM-C,ME3-C,ME2-C,P07-R,TSB-R,CST-C,F03-R,7ED-C,BRB-C,MMQ-C,6ED-C,ATH-C,USG-C,WC98-C,WC98-C,TMP-C,WC97-C,WC97-C,WC97-C,5ED-C,MIR-C,PARL-R,PTC-C,PTC-C,PTC-C,PTC-C,PTC-C,PTC-C,ICE-C,FBB-C,4ED-C,SUM-C,3ED-C,CEI-C,CED-C,2ED-C,LEB-C,LEA-C,A25-C · Vin,Leg,Mod
Maybe this should [...] after a while
t=2019-04-20T09:39:21+1000 lvl=dbug msg=Processing: Command="!ruling the wretched 3"
t=2019-04-20T09:39:21+1000 lvl=dbug msg=Dispatching index=0
t=2019-04-20T09:39:21+1000 lvl=dbug msg=Receiving index=0
t=2019-04-20T09:39:21+1000 lvl=dbug msg="In handleCommand" Message="ruling the wretched 3"
t=2019-04-20T09:39:21+1000 lvl=dbug msg="Done tokenising" Tokens="[ruling the wretched 3]"
t=2019-04-20T09:39:21+1000 lvl=dbug msg="Metadata query"
t=2019-04-20T09:39:21+1000 lvl=dbug msg="In a Ruling Query - Valid command detected" Command=ruling Card Name="the wretched" Ruling No.=3
t=2019-04-20T09:39:21+1000 lvl=dbug msg="In ReduceCard -- Tokens were" Tokens="[the wretched]" Length=2
t=2019-04-20T09:39:21+1000 lvl=dbug msg="Reverse descent" i=2 msg="the wretched"
t=2019-04-20T09:39:21+1000 lvl=dbug msg="Reverse descent" i=1 msg=the
t=2019-04-20T09:39:21+1000 lvl=dbug msg="Checking Scryfall for card" Name=thewretched
t=2019-04-20T09:39:21+1000 lvl=dbug msg="Checking cache for card" Name=thewretched
t=2019-04-20T09:39:21+1000 lvl=dbug msg="Card was cached"
==> /var/log/supervisor/fryatog-stderr---supervisor-87zKRe.log <==
panic: interface conversion: interface {} is *main.Card, not main.Card
goroutine 1201 [running]:
main.checkCacheForCard(0xc420552680, 0xb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/mnt/e/Temp/Code/src/fryatog/card.go:483 +0x6d2
main.getScryfallCard(0xc4205524e0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/mnt/e/Temp/Code/src/fryatog/card.go:509 +0x1a5
main.findCard(0xc420252480, 0x2, 0x2, 0x859d28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/mnt/e/Temp/Code/src/fryatog/main.go:615 +0x128
main.handleCardMetadataQuery(0xc4203976a1, 0x6, 0xc4203976a1, 0x15, 0x859d28, 0xc420010420, 0xc4200103a0)
/mnt/e/Temp/Code/src/fryatog/main.go:467 +0x655
main.handleCommand(0xc4203976a1, 0x15, 0xc420bc6300, 0x859d28, 0x859d20)
/mnt/e/Temp/Code/src/fryatog/main.go:405 +0x753
created by main.tokeniseAndDispatchInput
/mnt/e/Temp/Code/src/fryatog/main.go:371 +0x82c
So what is the right talking to my opponent ( first thank you very much !) To avoid judge calling
t=2019-02-26T13:31:51+1100 lvl=dbug msg="in lookupUniqueNamePrefix" Input=") To" NCN=to Length of CN=18911
t=2019-02-26T13:31:52+1100 lvl=dbug msg="Checking Scryfall for card" Name=
t=2019-02-26T13:31:52+1100 lvl=dbug msg="Checking cache for card" Name=
t=2019-02-26T13:31:52+1100 lvl=dbug msg="Not in cache"
t=2019-02-26T13:31:52+1100 lvl=dbug msg="fetchScryfallCard: Attempting to fetch" URL="https://api.scryfall.com/cards/named?fuzzy="
t=2019-02-26T13:31:52+1100 lvl=dbug msg="Getting Metadata"
t=2019-02-26T13:31:52+1100 lvl=info msg="fetchScryfallCard: Scryfall returned a non-200" Status Code=400
t=2019-02-26T13:31:52+1100 lvl=dbug msg="in lookupUniqueNamePrefix" Input= NCN= Length of CN=18911
t=2019-02-26T13:31:52+1100 lvl=dbug msg="In lookupUniqueNamePrefix" Gottem="To Arms!"
finds every card
10:47 <Fry_> !define detain
10:47 <Fryatog> Detain: A keyword action that temporarily stops a permanent from attacking, blocking, or having its activated abilities activated. See rule 701.28, "Detain."
10:47 <Fryatog> 701.28. Detain
For reminder text
<Volo> !ruin
t=2019-01-26T17:08:03-0600 lvl=dbug msg="In lookupUniqueNamePrefix" C="[Ruin Ghost Ruin Processor Ruin Raider Ruin Rat Ruin in Their Wake Ruination Ruination Guide Ruination Wurm Ruinous Gremlin Ruinous Minotaur Ruinous Path Ruins of Oran-Rief Ruins of Trokair]"
Currently a request like this just fizzles, because there's Too Much Stuff and none of them match the legendary-ish fuzziness.
Suggestion: add per-user menus if multiple things come back and we can't make a reasonable guess. Ex:
<Volo> teysa
-Datatog- 4 cards beginning with "teysa" found: (1) Teysa Karlov (2) Teysa, Envoy of Ghosts (3) Teysa, Orzhov Scion (4) Teysa, Orzhov Scion Avatar
Someone did "!702.133.1", and the bot immediately left IRC.
For tasty texts
Because we know the message is directed to us
05:34 <+Fryatog> Staunch: Duplicate response withheld. (Braid of Fire {1}{R} · Enchantment · Cumulative upkeep—Add {R}. (At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay its upkeep cost for each age counter on it.) · CSP-R · Vin,Leg,Mod ...)
05:34 <+Fryatog> Staunch: Caged Sun {6} · Artifact · As Caged Sun enters the battlefield, choose a color. \ Creatures you control of the chosen color get +1/+1. \ Whenever a land's ability causes you to add one or more mana of the chosen color, add one additional mana of that color. · CM2-R · Vin,Leg,Mod
Maybe check the exact first word to see if it's a match? I wonder how many cards have multiple word names where the first word is also a card?
10:34 < Garruk1> if !kinya of the old ways is in play enchanted with !lignify or imprisoned in the moon or song of the dryads and you cast !fractured identity .. your opponents will all get a normal nikya right?
10:34 <+Fryatog> Garruk1: Fractured Identity {3}{W}{U} · Sorcery · Exile target nonland permanent. Each player other than its controller creates a token that's a copy of it. · PZ2-R,C17-R · Vin,Leg
10:34 <+Fryatog> Garruk1: Imprisoned in the Moon {2}{U} · Enchantment — Aura · Enchant creature, land, or planeswalker \ Enchanted permanent is a colorless land with "{T}: Add {C}" and loses all other card types and abilities. · PEMN-R,EMN-R · Vin,Leg,Mod
10:34 <+Fryatog> Garruk1: Nikya of the Old Ways {3}{R}{G} · Legendary Creature — Centaur Druid · 5/5 · You can't cast noncreature spells. \ Whenever you tap a land for mana, add one mana of any type that land produced. · PRNA-R,RNA-R · Vin,Leg,Mod,Std
Use a channel rather than a set timeout
<Volo> Animate dead ETBing is a trigger. The *entire* trigger resolves like this: "Bring back Karmic guide. Fail to attach to Karmic Guide." State-based actions check and go "that's an aura not attached to anything!" and sends Animate Dead to the graveyard
<Fryatog> Volo: Animate Dead {1}{B}
Replace with separate commands
And replace https://github.com/Fryyyyy/Frytherer
Volo: Heart of Kiran {2} · Legendary Artifact — Vehicle · Flying, vigilance
People come into the channel and say things like "Hello"
Should Fryatog greet them with something like
"Hello! If you have a question, please go ahead and ask."
Figure out which one to pull up
Higher quality and can re-use code from Frytherer
So the user gets more/better feedback when not in channel
Can we save out the cache to disk when killed, and read it in on startup to preserve the data we've already gone and gotten
Coin/D6
See how much lag it causes, it's probably fine
e.g. Expansion//Explosion or Arlinn Kord currently show printing and legality for both sides. Redundant info, since obviously it's the same card with the same legality and printing(s).
<+Fryatog> Repudiate {G/UG/U}
Do we want to actually not munge mana costs and put it back to {G/U}{G/U}
Currently we have a single duplicate response cache, since we're only in one channel.
Once we join another one, it's possible that someone in chan 1 requests a card, and someone in chan 2 soon after would get 'Duplicate response withheld'
See if we can't get ahead of some parsing bugs
Something very large like !205.3m
(the list of creature types) spits the whole thing into the channel, which is... a lot. Maybe trim to two full outputs and then offer !next
to get the next page?
Should !define just give the actual rule (if one is referenced) rather than a slightly less technical definition that we just print the rule for anyway?
After we've brought up a card for the first time, launch a goroutine to fetch the rest of the printings using prints_search_uri
and fill in the Card object for the next time it's requested
23:31 < mjj29> !rule of law
23:31 < Fryatog> mjj29: Nonbasic Land: Any land that doesn't have the supertype "basic." See rule 205.4, "Supertypes."
23:31 < Fryatog> mjj29: 205.4. Supertypes
23:31 < mjj29> *sigh*
23:31 < mjj29> !card rule of law
23:31 < Fryatog> mjj29: Duplicate response withheld. (Nonbasic Land: Any la ...)
23:31 < mjj29> really fryatog
23:31 < mjj29> Yeti13: the oracle text of Rule of Law is "Each player can’t cast more than one spell each turn." (https://scryfall.com/card/10e/37/rule-of-law)
Should we have a custom list of definitions?
<Volo> !bushi tenderfoot
<Fryatog> Bushi Tenderfoot {W} | Creature — Human Soldier | When a creature dealt damage by Bushi Tenderfoot this turn dies, flip Bushi Tenderfoot. · CHK-U · Vin,Leg,Mod
END OF WHO can be handled before the last actual WHO messages due to goroutines.
Should do a LIST first and match the number of nicks to the number of WHOs.
Panics are probably going to happen, should try and recover gracefully
Straight into the Scryfall API
[[Multani, Yavimaya's Avatar]]:
should work
what?!? Why does
DBUG[01-20|13:23:30] in lookupUniqueNamePrefix Input="? Why do" NCN=whydo Length of CN=18911
DBUG[01-20|13:23:31] Attempting to fetch URL="https://api.scryfall.com/cards/named?fuzzy=%3F+Why"
DBUG[01-20|13:23:31] Card Func gave us CardID=8987644d-5a31-4a4e-9a8a-3d6260ed0fd6 Card="{Object:card ID:8987644d-5a31-4a4e-9a8a-3d6260ed0fd6 OracleID:adfe1b07-dd82-4c39-a7a6-ded0b1c39761 MultiverseIds:[74358] MtgoID:0 MtgoFoilID:0 TcgplayerID:37950 Name:Who // What // When // Where // Why
02:54 < Staunch> !702.53
02:54 <+Fryatog> 702.53: Bloodthirst
02:54 < Staunch> ugh
Check that our order is the same as Gatherer, so the index numbers align
!random
<Phasing12> Hello! I was wondering if Selvala, Explorer Returned flip triggers work. If I use Selvala and two nonlands are revealed, is that two triggers of life & mana gain or are they summe into <Fryatog> Phasing12: Mana Tithe {W} · Instant · Counter target spell unless its controller pays {1}. · PLC-C · Vin,Leg,Mod
Similar to what was added in #13.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.