abayomi185 / simple-pump-and-dump-bot

Simple pump-and-dump bot for Binance and Kucoin Cryptocurrency Exchange
Apache License 2.0
80 stars 21 forks source link

node_wip telegram error. #56

Open elliotks opened 2 years ago

elliotks commented 2 years ago

Hi,

I have been trying to get the telegram integration working and unable to resolve this error: image

I generated my telegram API from https://my.telegram.org/apps and included it in node_wip/conf.yaml I created a telegram group for testing messages as well - here is the telegram portion of the conf.yaml

Telegram integration

telegram:

Retrieved coin will be capitalised

api_id: "XXX" api_hash: "XXX"

Group names need to be single word or separated with underscores

groups: kucoin_pump: bot: Kucoin group_name: persocompump prefix: "Coin is: " # "The coin is: " in "The coin is DOGE" alt_prefix: "https://trade.kucoin.com/" # Alternative prefix special_character: "" # '$' in $DOGE suffix_to_split: "-USDT" # "-USDT" in DOGE-USDT => DOGE

I also noticed

Telegram has limited api requests and timeouts. Be conservative with this.

default_scraper_delay: 100 # Default delay in ms. Required to prevent hitting API rate limit.

is incorrect, "default_scraper_delay" is not used anywhere else. The correct config name is "scraper_delay" - also Telegram has a 1000ms api limit. So this should be

Telegram has limited api requests and timeouts. Be conservative with this.

scraper_delay: 1000 # Default delay in ms. Required to prevent hitting API rate limit.

Would you mind testing this? I am not sure how you are not getting the error.

abayomi185 commented 2 years ago

I seem to be getting the same issue. I'm testing it now but I'm getting rate limited so it might be a while.

elliotks commented 2 years ago

Yes, that is because of the scraper_delay value. Needs to be 1000 in the config. Latest version you pushed has default_scraper_delay: 100 - which is incorrect. Should be scraper_delay: 1000 since default_scraper_delay is not defined anywhere else but the config.

abayomi185 commented 2 years ago

Hey, I've just tested it again and it works without errors. I increased the history count to 8 for testing and nothing else.

I tested with breakpoints and don't see why there should be an issue.

From the error, it seems that .match() is not recognised perhaps because is not of type string which ideally shouldn't be the case.

Could you try type casting messageObject["message"] to string for match 1 to 4?

      const match1 = re1 && String(messageObject["message"]).match(re1);
      const match2 = re2 && String(messageObject["message"]).match(re2);
      const match3 = re3 && String(messageObject["message"]).match(re3);
      const match4 = re4 && String(messageObject["message"]).match(re4);