diff --git a/Modules/DiscordRelay.php b/Modules/DiscordRelay.php index d82e2cf..371d0bd 100644 --- a/Modules/DiscordRelay.php +++ b/Modules/DiscordRelay.php @@ -440,7 +440,7 @@ function cron($cron) $channel = $this->bot->core("settings")->get("discord", "ChannelId"); if ($channel>0 && $token!="") { if ($this->lastmsg>0) { $route = "/channels/{$channel}/messages?after=".$this->lastmsg; } - $route = "/channels/{$channel}/messages"; + else $route = "/channels/{$channel}/messages"; $result = discord_get($route, $token); if ($this->lastcheck==0) $this->lastcheck = date('Y-m-d').'T'.date("H:i:s").'.000000+00:00'; if(is_array($result)&&!is_null($result)) $invert = array_reverse($result); @@ -453,7 +453,10 @@ function cron($cron) if ($this->bot->core("settings")->get("discord", "IncLog")) $this->bot->log("DISCORD", "Incoming", ucfirst($msg['author']['username']).": ".strip_tags($msg['content'])); if(substr($msg['content'],0,1)!=$this->bot->commpre) { if(mb_detect_encoding($msg['content'], 'UTF-8', true)) $msg['content'] = mb_convert_encoding($msg['content'], 'ISO-8859-1', 'UTF-8'); - $sent = "[Discord] ".ucfirst($msg['author']['username']).": ".strip_tags($msg['content']); + $nickname = isset($msg['author']['global_name']) && $msg['author']['global_name'] !== null + ? $msg['author']['global_name'] + : $msg['author']['username']; + $sent = "[Discord] ".ucfirst($nickname).": ".strip_tags($msg['content']); $this->bot->send_output("", $sent,$this->bot->core("settings")->get("discord", "WhatChat")); if ($this->bot->exists_module("irc")&&$this->bot->core("settings")->get("Discord", "IrcRelay")) { $this->bot->core("irc")->send_irc("", "", $sent); @@ -799,4 +802,4 @@ function discord_sm() } -?> \ No newline at end of file +?>