Giter VIP home page Giter VIP logo

birc's People

Contributors

dragas avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

qial

birc's Issues

Websocket support

Currently there's no websocket driver for the Chatty bots, Currently it's just on backlog of features.

Update implementations to use chatty-core:2.0.0

With the release of chatty-core:2.0.0 there have been a lot of API changes, some of the removed, some added, some refined. chatty-irc and chatty-websocket should be updated to use them.

Requests aren't cloneable

While writing an application, there might be a caveat, where developer might want to use middlewares or test callbacks to modify request. By doing so, the request might fail possibly successful tests later down the pipeline, thus a good practice should be implementing a Cloneable interface on all Request objects.

chatty-discord fails to deserialize mentioned roles

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 188 path $.d.mention_roles[0] 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.Gson.fromJson(Gson.java:887) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.Gson.fromJson(Gson.java:852) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.Gson.fromJson(Gson.java:801) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.Gson.fromJson(Gson.java:773) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at lt.saltyjuice.dragas.chatty.v3.discord.adapter.DiscordAdapter.getFromJson(DiscordAdapter.kt:138) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at lt.saltyjuice.dragas.chatty.v3.discord.adapter.DiscordAdapter.deserialize(DiscordAdapter.kt:85) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at lt.saltyjuice.dragas.chatty.v3.discord.adapter.DiscordAdapter.decode(DiscordAdapter.kt:79) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at lt.saltyjuice.dragas.chatty.v3.discord.adapter.DiscordAdapter.decode(DiscordAdapter.kt:18) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.core.TyrusEndpointWrapper.decodeCompleteMessage(TyrusEndpointWrapper.java:439) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.core.TyrusSession.notifyMessageHandlers(TyrusSession.java:571) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.core.TyrusEndpointWrapper.onMessage(TyrusEndpointWrapper.java:879) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.core.TyrusWebSocket.onMessage(TyrusWebSocket.java:216) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.core.frame.TextFrame.respond(TextFrame.java:139) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.core.ProtocolHandler.process(ProtocolHandler.java:807) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.client.TyrusClientEngine$TyrusReadHandler.handle(TyrusClientEngine.java:747) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter$ProcessTask.execute(GrizzlyClientFilter.java:476) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.container.grizzly.client.TaskProcessor.processTask(TaskProcessor.java:114) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.container.grizzly.client.TaskProcessor.processTask(TaskProcessor.java:91) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter.handleRead(GrizzlyClientFilter.java:272) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at java.lang.Thread.run(Thread.java:745) 
Aug 26 20:43:27 bork-236 app/worker.1: Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 188 path $.d.mention_roles[0] 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385) 
Aug 26 20:43:27 bork-236 app/worker.1: 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213) 
Aug 26 20:43:27 bork-236 app/worker.1: 	... 40 more 

as seen on heroku.

Chatty/IRC implementations should have their own tests

Right now, Chatty/IRC implementations (bIRC in particular) have no tests, thus are subject to sudden API changes. Even though only controllers and middleware implementations are the things implementations should want to test, they should be present.

One shot routes

Sometimes, chat implementations require triggering particular route once (for example in 3 responses that match condition). Such logic can be implemented via controller routes, but that might cause a race in multithread environment.

Route incorrectly checks for types

In multiple type environment current checking for types is redundant and error prone. Instead it should involve lazy checking before evaluating if route's testCallback returns true, thus instead of

val isAssignable = type.java.isAssignableFrom(request.javaClass)
val canBeInvoked = testMethod.invoke(controllerInstance, request) as Boolean
isAssignable && canBeInvoked

It should be

type.javaObjectType.isAssignableFrom(request.javaClass) && testMethod.invoke(controllerInstance, request) as Boolean

Also fixes #17

Nicknames aren't used

Right now setting nicknames in settings.json is redundant as they are not used.

This leads to another issue as the framework fails to use other nicknames when logging in to server which uses the currently hard coded nickname. Should this functionality come from Route or should it be hardcoded?

Chatty/IRC tries to authenticate twice

Production conditions seem to prove that authenticating on NOTICE AUTH is bad, as this request is received twice. Which in turn causes USER and NICK commands to be sent twice.

Chatty/Core: input/output should be interfaces

Currently Input and Output classes in Chatty/Core are abstract and not interfaces. Since they are not that complex nor do they benefit from being abstract, they can be easily refactored into being interfaces.

Sadly this will be a breaking change.

Core doesn't work with java primitives

If you were to setup a client that listens for primitive values (int, float, etc) it wouldn't be able to deal with them due to current type checking.

Unify controller patterns

There should be a general Controller superclass, which declares how controllers should be defined. This would permit annotation scanning and declarative programming style. For example:

fun onAuthenticate(request : Request) : Response
...
router.add(router.builder().let {
                it.callback(instance::onAuthenticate)
                it.type(Command.RPL_WELCOME)
                it.build()
            })

Could be turned into

@Type(Command.RPL_WELCOME)
fun onAuthenticate(request: Request) : Response

or

fun onRandomRequest(request : Request) : Response?
...
router.add(router.builder().let {
                it.testCallback(pattern)
                it.middleware("DICEROLLAN")
                it.callback(instance::onRandomRequest)
                it.type(Command.PRIVMSG)
                it.build()
            })

Would become

@Pattern([some pattern])
@Type(Command.PRIVMSG)
@Middleware("DICEROLLAN")
fun onRandomRequest(request: Request) : Response?

Middlewares in Router

Since router should only find and test requests against route, it shouldn't have middlewares in it. Instead, Input implementation should either return the request or null, if it doesn't pass the global middleware. Same with Output implementations. It should not accept a response, if it fails the test against specified middlewares.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.