Closed alsoGAMER closed 3 years ago
Hello. As you can see from stacktrace there is the problem with spring cron expression. In this question on stackoverflow you can find the right format of spring cron expressions.
For example0 0/10 * * * *
- this expression equals every 10 min.
P.S. Basically, if you want to use this bot for the personal needs and you don't want to deploy it to free version of heroku you can just delete this service. It was added as a workaround because on free version of heroku application it goes to sleep after half an hour of inactivity, so I decided to ping myself every 20 minutes.
Hello. As you can see from stacktrace there is the problem with spring cron expression. In this question on stackoverflow you can find the right format of spring cron expressions.
For example
0 0/10 * * * *
- this expression equals every 10 min.
Oh ok, thanks!
P.S. Basically, if you want to use this bot for the personal needs and you don't want to deploy it to free version of heroku you can just delete this service. It was added as a workaround because on free version of heroku application it goes to sleep after half an hour of inactivity, so I decided to ping myself every 20 minutes.
I'll host this on my own vps, but i don't know what to delete from the sourcecode.
I'll host this on my own vps, but i don't know what to delete from the sourcecode.
service.ping
package is responsible for pinging.
This one?
Yes. But if first you can just try to add cron expression to your environment variables.
Yes. But if first you can just try to add cron expression to your environment variables.
Is working now, I've just added "0 0/10 " to dawg.ping.scheduled.cron in the application.properties file (like i did with the other options)
Oh there is a new error now:
2020-09-02 21:25:19.300 ERROR 220778 --- [legram Executor] o.t.t.u.DefaultBotSession : URI is not absolute
java.lang.IllegalArgumentException: URI is not absolute
at java.base/java.net.URL.fromURI(URL.java:692) ~[na:na]
at java.base/java.net.URI.toURL(URI.java:1116) ~[na:na]
at org.springframework.http.client.SimpleClientHttpRequestFactory.createRequest(SimpleClientHttpRequestFactory.java:145) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.http.client.support.HttpAccessor.createRequest(HttpAccessor.java:124) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:738) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:677) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:345) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at com.telegram.drb.client.DawgReputationBotClient.ping(DawgReputationBotClient.java:30) ~[main/:na]
at com.telegram.drb.command.HealthCheckCommand.execute(HealthCheckCommand.java:36) ~[main/:na]
at com.telegram.drb.command.handler.CommandHandler.handleMessage(CommandHandler.java:67) ~[main/:na]
at com.telegram.drb.bot.DawgReputationBot.onUpdateReceived(DawgReputationBot.java:62) ~[main/:na]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na]
at org.telegram.telegrambots.meta.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) ~[telegrambots-meta-4.9.jar:na]
at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:321) ~[telegrambots-4.9.jar:na]
I don't know which "URI" I've to check..
Great.
In fact, this application is a simple bot that can raise or lower a reputation if someone replies with special characters to another user's message in the Telegram bot, which was made for the own chat. So don't expect much functionality ;)
But in future I'm going to add some new interesting things, rewrite it with modern technologies and write proper installation guide.
I don't know which "URI" I've to check..
I think it's a problem with dawg.ping.url
property. It should be URI of your application. If it localhost then just add http://localhost:8080/
I don't know which "URI" I've to check..
I think it's a problem with
dawg.ping.url
property. It should be URI of your application. If it localhost then just addhttp://localhost:8080/
Is working now, thanks again! Other two things, how to use the database related functions (if any) of this bot? I've already set the credentials and the JDBC URL in the application configuration file
And, where I can report this warning? I'm using java 11 (the integrated JRE in IntelliJ idea to be clear)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/home/ag/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/4.2.2/6dacbe18e5eaa7f6c9c36db33b42e7985e94ce77/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
Other two things, how to use the database related functions (if any) of this bot?
If you add a bot to the Telegram chat and reply to someone's message, information about the user, chat, and users reputation will be automatically added to the database.
And, where I can report this warning?
You can ignore it, these are standard warnings
Other two things, how to use the database related functions (if any) of this bot?
If you add a bot to the Telegram chat and reply to someone's message, information about the user, chat, and users reputation will be automatically added to the database.
Oh ok! But I just tried to "increase" my reputation using "+" and in the console is appeared this error:
2020-09-02 21:43:31.901 ERROR 222851 --- [legram Executor] o.t.t.u.DefaultBotSession : PreparedStatementCallback; SQL [insert into user_reputations (user_id, chat_id, reputation_value, updated_date_time, updated_from_id) values (?,?,?,?,?)]; ERROR: duplicate key value violates unique constraint "user_reputations_pkey"
Detail: Key (user_id, chat_id)=(MY_ID, GROUP_CHAT_ID) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "user_reputations_pkey"
Detail: Key (user_id, chat_id)=(MY_ID, GROUP_CHAT_ID) already exists.
org.springframework.dao.DuplicateKeyException: PreparedStatementCallback; SQL [insert into user_reputations (user_id, chat_id, reputation_value, updated_date_time, updated_from_id) values (?,?,?,?,?)]; ERROR: duplicate key value violates unique constraint "user_reputations_pkey"
Detail: Key (user_id, chat_id)=(MY_ID, GROUP_CHAT_ID) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "user_reputations_pkey"
Detail: Key (user_id, chat_id)=(MY_ID, GROUP_CHAT_ID) already exists.
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:243) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:862) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:917) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:927) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at com.telegram.drb.repository.reputation.impl.UserReputationRepository.createUserReputation(UserReputationRepository.java:35) ~[main/:na]
at com.telegram.drb.repository.reputation.impl.UserReputationRepository$$FastClassBySpringCGLIB$$f0e05a31.invoke(<generated>) ~[main/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at com.telegram.drb.repository.reputation.impl.UserReputationRepository$$EnhancerBySpringCGLIB$$561916e2.createUserReputation(<generated>) ~[main/:na]
at com.telegram.drb.service.reputation.impl.UserReputationService.createUserRelation(UserReputationService.java:102) ~[main/:na]
at com.telegram.drb.service.reputation.impl.UserReputationService.manageUserReputation(UserReputationService.java:74) ~[main/:na]
at com.telegram.drb.service.reputation.impl.UserReputationService$$FastClassBySpringCGLIB$$2781c625.invoke(<generated>) ~[main/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366) ~[spring-tx-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99) ~[spring-tx-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at com.telegram.drb.service.reputation.impl.UserReputationService$$EnhancerBySpringCGLIB$$4a76468b.manageUserReputation(<generated>) ~[main/:na]
at com.telegram.drb.command.managing.ManageReputationCommand.executeChangingReputation(ManageReputationCommand.java:45) ~[main/:na]
at com.telegram.drb.command.managing.IncreaseReputationCommand.execute(IncreaseReputationCommand.java:24) ~[main/:na]
at com.telegram.drb.command.handler.CommandHandler.handleMessage(CommandHandler.java:67) ~[main/:na]
at com.telegram.drb.bot.DawgReputationBot.onUpdateReceived(DawgReputationBot.java:62) ~[main/:na]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na]
at org.telegram.telegrambots.meta.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) ~[telegrambots-meta-4.9.jar:na]
at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:321) ~[telegrambots-4.9.jar:na]
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "user_reputations_pkey"
Detail: Key (user_id, chat_id)=(MY_ID, GROUP_CHAT_ID) already exists.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477) ~[postgresql-42.1.4.jar:42.1.4]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190) ~[postgresql-42.1.4.jar:42.1.4]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300) ~[postgresql-42.1.4.jar:42.1.4]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428) ~[postgresql-42.1.4.jar:42.1.4]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354) ~[postgresql-42.1.4.jar:42.1.4]
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:169) ~[postgresql-42.1.4.jar:42.1.4]
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:136) ~[postgresql-42.1.4.jar:42.1.4]
at org.springframework.jdbc.core.JdbcTemplate.lambda$update$0(JdbcTemplate.java:867) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617) ~[spring-jdbc-5.2.2.RELEASE.jar:5.2.2.RELEASE]
... 34 common frames omitted
And also if I use the /myrep
command, this error appears in the console:
2020-09-02 21:44:08.038 ERROR 222851 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
And, where I can report this warning?
You can ignore it, these are standard warnings
Ok.
I'm running PostgreSQL 12.3, and I've just added to the bot to my group, so I don't know why there is another key for that group.
Unfortunately, I don't know why this happened. Obviously, there is a problem with duplicate primary keys in your db. Try to remove all data from tables and try again. How did you try to increase your reputation? It can be possible only if someone else will reply on your message.
Unfortunately, I don't know why this happened. Obviously, there is a problem with duplicate primary keys in your db. Try to remove all data from tables and try again.
Ok, I'll try now EDIT: All the tables are already empty, whaaat?....
How did you try to increase your reputation? It can be possible only if someone else will reply on your message.
Literally, by replying with "+" to one of my messages
PS: If you can give me your telegram username, I can contact you there so I can reply more quickly.
Literally, by replying with "+" to one of my messages
It's strange because I thought that I had added validation checks for it. I'll check it and fix, thanks
But it's strange because when if i do the same i don't have such errors.
PS: If you can give me your telegram username, I can contact you there so I can reply more quickly.
Sorry, it would be better to talk here because I don't always have free time to answer questions.
EDIT: All the tables are already empty, whaaat?....
You can ask someone to help you with testing, or you can create another Telegram account and test it yourself.
But it's strange because when if i do the same i don't have such errors.
Now I've tried to increase the reputation of one random user, and it worked, but I try to increase my reputation by replying to my messages, the message with the ""rankup"" of the previous user gets deleted, and I didn't get this error anymore.
EDIT: Also, if I try to increase/decrease the reputation of the bot itself, i get this error in the console:
2020-09-02 22:23:30.203 ERROR 222851 --- [legram Executor] o.t.t.u.DefaultBotSession : null
java.lang.NullPointerException: null
at com.telegram.drb.bot.DawgReputationBot.onUpdateReceived(DawgReputationBot.java:63) ~[main/:na]
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na]
at org.telegram.telegrambots.meta.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) ~[telegrambots-meta-4.9.jar:na]
at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:321) ~[telegrambots-4.9.jar:na]
However this isn't a real issue, cause try to do that is just very stupid lol
But the issue with the /myrep
command is still here, I wonder if is caused by the hardcoded username of your bot (@dawgReputationBot to be clear)
PS: If you can give me your telegram username, I can contact you there so I can reply more quickly.
Sorry, it would be better to talk here because I don't always have free time to answer questions.
Ok, don't worry :) Instead, thanks for your support
EDIT: All the tables are already empty, whaaat?....
You can ask someone to help you with testing, or you can create another Telegram account and test it yourself.
Yes, I'm already testing the bot in my private group
Now I've tried to increase the reputation of one random user, and it worked, but I try to increase my reputation by replying to my messages, the message with the ""rankup"" of the previous user gets deleted, and I didn't get this error anymore.
I'll add fixes for this. I found out the problem.
But the issue with the /myrep command is still here, I wonder if is caused by the hardcoded username of your bot (@dawgReputationBot to be clear)
Probably yes, the problem with username of my bot, thanks. I'll add some fixes and for this too. But for now, you can just write the your bot's username.
I thought that no one would use this except me, so I didn't really think about scalability and substitution by other bots. But in this case I will try to do everything right.
I thought that no one would use this except me, so I didn't really think about scalability and substitution by other bots. But in this case I will try to do everything right.
It's actually a very good project, however, the lack of an installation guide makes the whole bot hosting process difficult
however, the lack of an installation guide makes the whole bot hosting process difficult
Sure, I understand and I'll add it. By the way, you can try Combot. It's the real big project that has a various functionality.
But the issue with the /myrep command is still here, I wonder if is caused by the hardcoded username of your bot (@dawgReputationBot to be clear)
Probably yes, the problem with username of my bot, thanks. I'll add some fixes and for this too. But for now, you can just write the your bot's username.
I've replaced it but I got the same issue, here the console output:
2020-09-02 22:35:37.592 ERROR 229408 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 22:35:49.168 ERROR 229408 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
EDIT: I'm getting the same error with the /minrep
and /toprep
commands, I've already tried to insert the username of my bot, but this didn't help at all
however, the lack of an installation guide makes the whole bot hosting process difficult
Sure, I understand and I'll add it.
Great!
By the way, you can try Combot. It's the real big project that has a various functionality.
Yes, I already know and use combot, but for some groups, I want to use something that I host
I've replaced it but I got the same issue, here the console output:
Hm, and what about other commands? /minrep and /toprep?
I've replaced it but I got the same issue, here the console output:
Hm, and what about other commands? /minrep and /toprep?
Just tried and got the same issue, I wonder if is a markdownv2 related issue
Just tried
Try to debug it.
Just tried
Try to debug it.
How could I do?
How could I do?
You can use default Idea debugger and run the app in debug mode.
How could I do?
You can use default Idea debugger and run the app in debug mode.
Ok now I'm running the bot in debug mode, but i still get this errors in the console, and nothing else:
2020-09-02 22:56:27.757 ERROR 231820 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 22:57:02.725 ERROR 231820 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 22:57:08.318 ERROR 231820 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 22:57:12.732 ERROR 231820 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 22:57:16.806 ERROR 231820 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 22:57:52.386 ERROR 231820 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
You need to add some break point in the app, for example:
And you can read the guide for Intellij Idea debugger.
Also, if I try to increase/decrease the reputation of the bot itself, i get this error in the console:
By the way, I've fixed it. You can pull from master and check
Also, if I try to increase/decrease the reputation of the bot itself, i get this error in the console:
By the way, I've fixed it. You can pull from master and check
Done, now that issue is fixed, but the commands still doesn't work, i get the same error in the console:
2020-09-02 23:17:16.041 ERROR 234461 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 23:17:23.586 ERROR 234461 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 23:17:26.959 ERROR 234461 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 23:17:29.616 ERROR 234461 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 23:18:28.595 ERROR 234461 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
2020-09-02 23:18:32.706 ERROR 234461 --- [legram Executor] com.telegram.drb.bot.DawgReputationBot : Failed to send message due to error: Error sending message
But sadly I don't know how to use the debug features, I'm not a java developer/expert, so I don't know how to do that.
But sadly I don't know how to use the debug features, I'm not a java developer/expert, so I don't know how to do that.
Okay, I'll try to find the problem and fix it next but not now. If you find any more problems or find the reason of this issues - please write on this thread.
But sadly I don't know how to use the debug features, I'm not a java developer/expert, so I don't know how to do that.
Okay, I'll try to find the problem and fix it next but not now. If you find any more problems or find the reason of this issues - please write on this thread.
Ok, thank you for the support!
Ok, thank you for the support!
And thank you for using this and finding bugs :)
Every time I try to start the bot I receive this warning in the console, and then the bot crashes. How can I fix this?