Skip to content

Instantly share code, notes, and snippets.

@lynzrand
Created July 5, 2018 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynzrand/afabb11050028e8b0603affa40f897d3 to your computer and use it in GitHub Desktop.
Save lynzrand/afabb11050028e8b0603affa40f897d3 to your computer and use it in GitHub Desktop.
Rynco Bot Structure
Result:
type: string // maybe int from enum?
value: string // id
Trigger:
type: string
value: string
Reaction:
id: string
trigger: string | array<Trigger> | Trigger
reaction: string | array<Result> | Result
attachedTo: array<int32>
check: function(msg: TgMessage) => match: Regex_Match | null
exec: function(msg: TgMessage) => execStatus: number
RynReact:
reactions: object<key: string; value: Reaction>
exec: function(msg: Message) => {
foreach <key, value> in this.reactions { match += <id, match> }
reaction = randomlySelectOneReaction()
reaction.exec(msg)
return execStatus
}
add: function(trigger, reaction) => {
id = generateGUID()
this.reactions[id] = { id: id, trigger: trigger, reaction: reaction }: Reaction
}
del: function(id) => delete this.reactions[id]
modify: function(id, [newTrigger = null, newReaction = null]) => this.reactions[id].(modifiedObject) = (newObject)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment